App Modularization and Module Lazy Loading at Instagram and Beyond
Article Summary
Instagram's app was getting bloated. More engineers, more features, slower cold starts, and ballooning app size threatened the lean experience users loved.
The Instagram engineering team tackled this by modularizing their codebase and implementing lazy loading for feature modules. This 2017 article breaks down their approach to keeping the app fast as it scales, focusing primarily on Android implementation.
Key Takeaways
- Modularization creates strict boundaries between features to prevent unnecessary code loading at startup
- Lazy loaded modules compile to separate dex files, loaded only when needed
- On Dalvik, this approach reduces multidex performance penalties significantly
- Instagram open sourced their framework: ig-lazy-module-loader on GitHub
- Modules load with under 50ms latency at p99, enabling seamless user experience
Critical Insight
By separating features into lazily loaded modules, Instagram improved cold start times, reduced disk footprint, and maintained developer velocity as the codebase grew.