Efficiency and Velocity: How Duolingo Adopted MVVM on Android

Posted by Kateryna Semenova, Android Developer Relations Engineer

illustration of hand holding up a chart with the Duolingo bird sitting on top

Government Abstract

Duolingo’s app started to expertise rising pains attributable to scalability points of their Android software program structure. They have been capable of remedy these efficiency issues and regain developer productiveness, by refactoring to a Mannequin-View-ViewModel structure and utilizing Android Jetpack’s Dagger and Hilt for dependency injection. To study extra about how this impacted their enterprise, learn the accompanying article here.


Duolingo is the world’s hottest language studying app, with over ten million each day learners, as a result of they’ve managed to make one thing folks discovered daunting really feel simple and enjoyable. This continued success depends on a relentless stream of improvements and updates — and a smooth-running app that may ship all of them. To Duolingo, a single unresponsive app in a tool anyplace on the earth may imply a learner probably discouraged. This commits them to app excellence, significantly on the Android units utilized by sixty % of their learners, together with their CEO, who retains monitor of the app from an entry-level cellphone. And so, when Duolingo’s Android improvement crew registered a rise in “App not Responding” errors, dropped frames — and even obtained a hand-written grievance — they took motion instantly.

Their scenario wasn’t that unusual. Apps that lack scalable structure and clear finest practices typically carry out effectively at the start however present indicators of technical debt as they develop. Duolingo’s Android codebase was designed to permit them so as to add and launch new options quickly, however the lack of an agreed-upon structure was manifesting in more and more frequent efficiency regressions. It was beginning to endure from unreliable body charges, visually inconsistent or damaged interactions, and a rising assortment of latest bugs. These regressions not solely inconvenienced learners but in addition price the crew substantial improvement effort to diagnose and restore. Duolingo’s Android improvement crew realized that in the event that they wished to maintain transport new options whereas offering the goal stage of person expertise, a brand new strategy to their codebase was wanted.


First, they needed to resolve what precisely was happening. A deep dive into the numbers uncovered that, as they added new performance, the app’s rendering efficiency was regressing 5-10% each month. The truth is, one significantly unwieldy launch had elevated crashes by 10%, slowed body renders by 25%, and noticed classes beginning 70% slower on entry-level units.

Additional evaluation of their code led them to the conclusion that many of the app’s points might be traced again to a single bottleneck: a worldwide state object known as DuoState, which was accountable for sustaining state throughout totally different options of the app. A variety of fashionable options (like expertise factors and each day streak monitoring) have been utilizing it to entry very important info. Centralizing their information on this method had as soon as enabled the crew to iterate quickly. They merely added properties to DuoState each time a brand new function wanted to share info throughout the app. However now the unoptimized and frequent entry to the item was inflicting growing efficiency regressions.

DuoState was so tightly coupled to your entire codebase that even small modifications may affect the remainder of the app. The crew feared {that a} minor new function may have the unexpected aspect impact of triggering many inner updates to the app, inflicting your entire launch to be too sluggish for a lot of units. These efficiency regressions turned extra frequent because the app grew, and the crew onboarded new engineers to maintain up with the accelerating product roadmap. In 2020, as they added extra builders, they have been beginning to see vital regressions cropping up as typically as each 90 days. Upon nearer inspection, the chance of a regression in a given launch was proportional to the variety of modifications it carried out. At this price, these regressions would fully derail the product roadmap inside just a few years.

This outdated structure had turn out to be a bottleneck for each the efficiency of the app and the rate of the crew. After a lot inner debate, they stopped improvement of latest options, together with some intently tied to their backside line. For 2 full months, Duolingo’s improvement crew went all-in on refactoring their Android app in an effort they known as the “Android Reboot”.

The Android Reboot

One of many crew’s first key takeaways was that their code lacked clear boundaries. The DuoState object was available at any level within the code, inviting builders to entry it incessantly in inefficient methods. They wanted to create a better separation of considerations throughout the codebase. They determined to tease aside every function into its personal, clearly-defined module, utilizing the Model-View-ViewModel architectural sample. MVVM allowed them to take away calls to the monolithic DuoState object, letting many modules work in separate threads.

Diagram showing before and after implementing the Model-View-ViewModel architectural pattern

The crew’s familiarity with MVVM, and Google’s assist for it, made it an apparent selection. It allowed them to obviously doc what logic ought to go into what recordsdata (together with views, view fashions and repositories). This helped make their function structure extra constant. With a transparent path to observe, the crew rapidly started refactoring their monolithic code into units of courses with clear boundaries and duties.

Together with MVVM, the crew used Dagger and Hilt (additionally included in Android Jetpack) to implement repository patterns to switch DuoState. Dagger generates clear readable code that gives verbose error logging designed to assist builders perceive precisely what their code is doing, eliminating useless stack traces to mirrored properties; and Hilt reduces the quantity of boilerplate code wanted to jot down for this.

This new structure allowed the crew to separate DuoState into smaller objects. This instantly diminished pointless coupling between domains. For instance, the code accountable for monitoring a person’s progress may now entry their expertise factors however not the variety of occasions they’ve logged in throughout a month. These new structure pointers meant that whereas no single factor was too tough to vary, it took coordination and planning to vary it throughout the app. Implementing the brand new structure throughout the code base drove vital efficiency beneficial properties in mixture.

MVVM structure facilitates a separation of considerations between the area information, the interface the learners see, and the logic for a way these two realms work together. It gave Duolingo’s builders a extra deliberate strategy to management how the app responds to inner state updates. They may now develop extra complicated person experiences with out the danger of triggering regressions, or affecting the underlying enterprise guidelines.

Developer Productiveness

Up to now, inconsistent software of improvement patterns made totally different components of the codebase tougher to grasp and preserve. With out consensus, every developer carried out code as they noticed match.

MVVM, Dagger, and Hilt, offered the crew with a extra detailed understanding of how new options ought to be carried out. Following these finest practices made the code simpler and extra predictable. Builders may now help in debugging options that they hadn’t initially labored on. And new builders might be onboarded extra effectively; so long as they understood the structure, they might contribute meaningfully instantly. This new readability considerably boosted the crew’s improvement velocity.

Making certain High quality

Crucially, the brand new structure additionally revealed that sure animation options within the app have been underperforming on entry-level units. Accordingly, the opposite core focus of the Android Reboot was the discount of jank, dropped frames, and “App Not Responding” (ANR) errors. The crew used repository patterns to assist streamline the sharing of information between threads. These patterns ensured that they might extra effectively use gadget assets with a number of threaded modules. Shifting work off the primary thread improved responsiveness, total body price, and led to smoother animations on entry-level units. Efficiency on flagship units improved as effectively.

A Higher General Android Expertise

Within the six months working with the brand new structure, Duolingo’s Android crew has continued to ship new options with out recording vital efficiency regressions. The times the place they needed to halt function manufacturing to hunt and repair bugs are safely behind them.

The app’s each day ANR price dropped 41%. The share of time that the app’s body price fell under goal decreased by 28%. And importantly, customers skilled a 40% improve in velocity when scrolling via classes, the leaderboard, and tales within the app.

The reboot allowed Duolingo to constantly present their trademark enjoyable, efficient, and pleasant language studying expertise on a a lot wider vary of Android units.


Duolingo’s dedication to their mission made them the world’s prime app within the language studying area. Their dedication to app excellence — creating innovative academic experiences with out compromising accessibility — is what saved them there.

For those who’re concerned with getting your crew on board in your personal Android Reboot, try our condensed case research for product house owners and executives linked here.

Recent Articles

Fb Whistleblower Says She Invested in Crypto on the Proper Time

Fb's former product supervisor turned whistleblower Frances Haugen has revealed that her refuge in Puerto Rico is "fantastic for the foreseeable future" due...

These are the most effective circumstances for the Amazon Hearth HD 10

Finest Amazon Hearth HD 10 & 10 Plus circumstances Android Central 2021 Whereas Amazon Fire Tablets aren't the costliest tablets round, they are not low cost both. So...

greatest puzzle journey video games

For correct use of this web site, you might want to allow javascript in your browser! Finest Level &...

Related Stories

Stay on op - Ge the daily news in your inbox