Instagram Tommy Crush Oct 3, 2023

Making Direct Messages Reliable and Fast

Article Summary

Instagram DMs handle millions of messages per second. How do they make every send feel instant, even when your network drops mid-tap?

Instagram's engineering team built a centralized Mutation Manager to solve two critical problems: making network requests feel instantaneous and ensuring messages never get lost, even across app crashes. This deep dive reveals the architecture behind reliable, fast messaging at scale.

Key Takeaways

Critical Insight

By separating optimistic state from server data and centralizing mutation logic, Instagram made DMs feel instant while guaranteeing delivery reliability across all network conditions.

The article reveals how Instagram's compiler enforces good patterns and makes adding new mutation types almost foolproof for growing teams.

About This Article

Problem

Mobile apps lose users when network latency and request failures slow down Direct Messages. Users notice the delay between tapping a button and seeing the result on screen, especially on spotty connections.

Solution

Tommy Crush's team built optimistic state patterns that update the UI right away with what should happen, before the server confirms it. This made the app feel nearly instant to users.

Impact

The Mutation Manager stopped state conflicts from overwriting each other and made it easier for developers to get up to speed. It enforced the same retry and state-management patterns everywhere in the product, so teams didn't have to write custom merging logic.