How Duolingo Reduced Cloud Costs by 20%: 10 Key Strategies

Duolingo has become a household name for language learning, known for its innovative features like Stories, DuoRadio, and Adventures. But even as the product evolved, one significant challenge arose: the soaring costs of maintaining these features on the cloud. At the start of 2024, Duolingo embarked on a mission to reduce cloud spending without compromising its product’s quality. The result? A remarkable 20% annualized savings in just a few months.

Here are the top strategies that made this possible:

1. Improve Observability

Understanding cloud expenses is the first step toward managing them effectively. Duolingo leveraged CloudZero, a third-party tool, to break down cloud costs into queryable line items. This allowed teams to:

  • Identify anomalies in spending, such as a staging environment costing more than production.

  • Expand monitoring to include non-AWS services like OpenAI.

  • Integrate cost data into existing metrics dashboards and send weekly spending reports to teams.

2. Eliminate Unused Resources

Just like unsubscribing from unused services saves money at home, cleaning up unused resources significantly reduced Duolingo’s cloud costs. Examples include:

  • Removing outdated ElastiCache clusters, databases, and entire microservices.

  • Deleting unnecessary data, such as revision histories in S3 buckets.

  • Adding lifecycle rules to automatically purge old data in storage.

3. Optimize Data Storage

Data storage can silently rack up costs. Duolingo tackled this with:

  • Time-To-Live (TTL) rules for DynamoDB to delete stale records automatically.

  • Reducing verbose production logs that unnecessarily inflated CloudWatch costs.

  • Avoiding logging stack traces in production, which are large and expensive to store.

4. Right-Size Compute Resources

Over-provisioned services were identified and adjusted to match actual usage. Key actions included:

  • Reducing memory allocation for services running at low usage.

  • Configuring most services to operate comfortably at 90–95% memory utilization.

  • Adjusting autoscaling policies to lower task counts and scale more conservatively.

5. Leverage Built-In AWS Optimizations

Duolingo identified cost-saving AWS configurations that aligned with specific usage patterns:

  • Switching databases to Aurora I/O optimized instances.

  • Using autoscaling and task scheduling to handle traffic spikes efficiently without overcommitting resources.

6. Refine Reserved Instances (RI) Strategy

By analyzing baseline compute usage, Duolingo strategically invested in Reserved Instances for EC2, RDS, and ElastiCache, saving significant costs compared to on-demand instances.

7. Reduce Cloud Traffic

Every unnecessary request in a microservice architecture adds costs. Duolingo reduced traffic by:

  • Refactoring legacy code to eliminate 2.1 billion unnecessary API calls per day.

  • Extending cache TTLs from 1 minute to 1 hour for resources that rarely changed, cutting request volume by over 60%.

8. Simplify and Clean Up Tech Debt

Cleaning up technical debt proved to be a dual benefit: improved code health and reduced costs. Simplifying complex systems eliminated inefficiencies and streamlined operations.

9. Incorporate Cost Awareness in Culture

Cost optimization became a team-wide responsibility. Duolingo:

  • Trained engineers to include cost estimations in design documents.

  • Conducted quarterly reviews to identify high-ROI cost-saving opportunities.

  • Integrated cloud cost monitoring into the engineering workflow.

10. Adopt Autoscaling and Scheduling

To avoid running at full capacity 24/7, Duolingo implemented:

  • Autoscaling policies to dynamically handle traffic spikes.

  • Task scheduling to reduce compute usage during off-peak hours.

Conclusion: Cost Optimization and Code Health Go Hand in Hand

Duolingo’s journey to reduce cloud costs underscored the connection between cost optimization and engineering excellence. By cleaning up tech debt, simplifying code, and fostering a culture of cost awareness, the company not only saved millions but also improved its codebase’s health. For organizations aiming to optimize their cloud spending, Duolingo’s approach offers valuable lessons: invest in observability, right-size resources, and integrate cost considerations into your engineering culture.