Duolingo's Implementation of Optimistic Locking to Solve Database Contention in Notification System
By
Caleb Noble
Front-window bakery material. Catches the eye, delivers the goods.
Summary
Duolingo engineers implemented optimistic locking to solve database contention issues in their notification scheduling system. The system, called 'comeback', schedules hundreds of millions of daily notifications by calculating reminder times when users complete lessons. Traditional pessimistic locking was causing performance bottlenecks and high computing costs. By switching to optimistic locking with version numbers, they eliminated contention, improved performance, and reduced infrastructure costs while maintaining data consistency.
Key quotes
· 4 pulledIn order to schedule and send hundreds of millions of notifications each day, we use a system known as comeback.
When a user does things like finishing a lesson, we will calculate when we should send them reminders for the following days and store that schedule of reminders as a row in our database.
Here's how we used *optimism* to fix our notifications service and save computing costs.
The Duolingo app is famous for encouraging users to do their lessons. While Duo the owl's methods vary, the most effective method for reminding users about their learning goals is via notifications.
You might also wanna read
Optimizing .NET APIs for High Throughput: Techniques for 1M Requests Per Minute
Article discusses techniques for designing high-throughput .NET APIs capable of handling 1M requests per minute. It covers horizontal scalin
SQLite as a Viable Alternative for Durable Workflow Execution
The article argues that SQLite can replace complex orchestration systems for durable workflow execution in many cases. It builds on DBOS's a
JWT vs Opaque Tokens: A Technical Comparison for API Security Architecture
This article compares JWT (JSON Web Tokens) and opaque tokens for API security, clarifying the common confusion between bearer tokens and JW
How Frontend State Management Becomes a Distributed Monolith as Apps Scale
This article discusses how frontend state management in growing applications can evolve into a "distributed monolith" — where state becomes
A Field Guide to Production-Ready AI Agents: Context Windows, Security, and Drift Monitoring
Karl Mehta presents a field guide for building production-ready AI agents, focusing on four key engineering challenges: context-window disci
The Convergent Architecture of Frontier Agentic Systems
This article from Veso Research analyzes the emerging universal architecture across frontier agentic systems (Claude Code, OpenAI Codex, Gem
