Case study · Stack

How Duolingo scaled from a Python backend to 500 services on AWS

Duolingo teaches languages, math and music to a huge audience through native mobile apps and the web. Its backend started in Python and grew into more than 500 services on AWS written in Python, Kotlin and Java, while the apps are native Swift and Kotlin and use AI from OpenAI.
Copy this stackduolingo.com Language learning app · United States · founded 2011

Language

  • Pythonblog.duolingo.com

    Original language of most of the backend and still central to many services.

Hosting

  • AWSblog.duolingo.com

    Cloud where Duolingo's backend runs.

  • Kubernetesinfoq.com

    Amazon EKS is becoming the platform for all backend services, replacing ECS.

    Why: They wanted blue-green and canary deploys, per-PR environments, IPv6 and a richer open source toolset.

Database

  • DynamoDBblog.duolingo.com

    Stores each learner's per-course scores for the Birdbrain personalization system.

    Why: Keeping each course's scores in a single row minimizes API latency.

  • Amazon Aurorablog.duolingo.com

    Relational database, with one switched to Aurora I/O-Optimized to cut costs.

Mobile framework

  • Kotlinblog.duolingo.com

    Language of the Android app and a first-class backend language alongside Python and Java.

    Why: It is far less verbose than Java and its null safety keeps crashes from reaching users.

  • Swiftcareers.duolingo.com

    Main language of the native iOS app.

Animation

  • Riveblog.duolingo.com

    Interactive animations for characters and the math course on every platform.

    Why: It works across platforms and moves part of the animation work from engineers to designers.

Data fetching

Backend framework

  • Flaskblog.duolingo.com

    Web framework of synchronous Python services, with Quart for the async ones.

  • Scalablog.duolingo.com

    Language of the Session Generator, the engine that builds lessons.

    Why: Python was too slow, not thread-safe for in-memory caching, and its dynamic typing let bugs reach production.

File storage

AI model

  • OpenAIblog.duolingo.com

    GPT-4 powers Duolingo Max features like Explain My Answer and Roleplay.

How they built it

Python first, Scala where speed mattered

Like most of Duolingo's backend, the Session Generator, the engine that builds each lesson, was first written in Python. In 2017 the team rewrote it in Scala. They pointed to three problems: Python was much slower, it was not thread-safe so in-memory caches were limited, and dynamic typing let many bugs slip into production.

The rewrite cut average latency from 750 ms to 14 ms and took uptime from 99.9% to 100% in the first months.

Sources:blog.duolingo.com

500 services, and a move to Kubernetes

Duolingo now has more than 500 backend services owned by 30 product teams, all on AWS. Python is still central, and Kotlin became a first-class backend language next to Python and Java, which took little effort because the team could reuse Java code and Android Kotlin tooling.

Most services ran on AWS ECS, and the platform team is moving them to Amazon EKS. They wanted blue-green and canary deploys, a temporary environment for each pull request, IPv6 support and a richer open source toolbox with Argo CD, Karpenter and KEDA. As of 2026 the move was still in progress, and every new service launches on EKS.

Sources:infoq.com blog.duolingo.com

Native apps, with Rive for the moving parts

Duolingo builds its mobile apps natively, Swift on iOS and Kotlin on Android. The Android app went fully Kotlin by 2020: less verbose code, fewer null pointer crashes and much happier developers. Converting a Java file cut its size by about 30%, and the codebase stayed the same size for two years even as contributors doubled.

For animation the team leans on Rive. When the math course moved from iOS to Android, the Swift visuals did not carry over, so Rive became the cross-platform answer and shifted part of the work from engineers to designers.

Sources:blog.duolingo.com blog.duolingo.com

Watching every dollar of cloud spend

In 2024 Duolingo cut its cloud spending by 20%. The team bought reserved capacity based on EC2, RDS and ElastiCache usage, moved one database to Aurora I/O-Optimized and saved several hundred thousand dollars a year, added expiry rules to DynamoDB and S3, and trimmed noisy CloudWatch logs.

In 2025 they tried async Python instead of rewriting a service in Go. The async version handled about 40% more requests per instance, around 30% less EC2 spend per migrated service, at a much lower cost than a rewrite.

Sources:blog.duolingo.com blog.duolingo.com

GPT-4 inside the lessons

In March 2023 Duolingo launched Duolingo Max, a tier above Super built on GPT-4 from OpenAI. Its first features, Explain My Answer and Roleplay, came after months of working closely with OpenAI to tune the technology.

Sources:blog.duolingo.com

Also detected on their website

Found on the homepage with the open Wappalyzer rules (HTML, scripts and headers). It shows what runs in the browser, not the whole backend.

  • Amazon CloudFront
  • Amazon Web Services
  • Envoy
  • Google Tag Manager
  • OneTrust
  • React