Architecture used by TikTok and Reels Fan Out on Read vs Fan out on Write
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
TikTok and Instagram Reels have grown exponentially in popularity, leading to vast amounts of data being generated and consumed globally. To manage such a large-scale system, effective data architecture strategies are crucial. Two prevalent strategies include Fan-Out on Read and Fan-Out on Write. Both approaches have their pros and cons and are employed depending on the specific requirements of the service. This article provides an in-depth look at how these approaches are utilized by platforms like TikTok and Instagram Reels.
Understanding Fan-Out on Read vs. Fan-Out on Write
Before diving deeper into how TikTok and Instagram Reels utilize these strategies, let's define what Fan-Out on Read and Write are.
- Fan-Out on Read: When a user performs a read action (e.g., viewing a feed), the system dynamically generates the content by retrieving data from multiple sources. This means data is pulled and aggregated in real-time.
- Fan-Out on Write: In contrast, this approach involves pre-compiling and storing the user's feed when content is posted. Thus, when a user requests to view certain content, the data is already pre-processed and quickly retrievable, leading to faster read times but higher data storage.
Application in TikTok and Instagram Reels
TikTok and Instagram Reels, where content is highly personalized and delivered in real-time, require robust systems to handle these operations.
TikTok
TikTok likely uses a hybrid model, but with a significant emphasis on Fan-Out on Write due to the nature of its content delivery and the need for high performance. When a user uploads a video on TikTok:
- The content is processed, including transcoding and applying metadata.
- The TikTok algorithm predicts potential interest from other users and pre-populates feeds accordingly, thus primarily using Fan-Out on Write to ensure that when users open the app, their feeds are ready with minimal delay.
Instagram Reels
Instagram Reels, being part of the Instagram ecosystem, might leverage Instagram's existing infrastructure which is known for using Fan-Out on Write, similar to TikTok. Instagram structures its data such that when new Reels are uploaded:
- They are immediately processed and tagged.
- Reels are then pushed into potential viewers' feeds based on predicted interests and engagements, optimizing for quick access when the user next accesses the platform.
Pros and Cons
| Feature | Fan-Out on Read | Fan-Out on Write |
| Response Time | Can be slower as data is aggregated in real-time | Generally faster as data is pre-prepared |
| Scalability | High, as data is not duplicated until needed | Lower, requires more storage and upfront processing |
| Data Freshness | High, updates are immediately available | Can be delayed, depends on update frequency |
| System Complexity | Lower, simpler data paths | Higher, more layers of caching and data management |
| Suitability | Best for systems with less frequent updates | Ideal for platforms with high read volume and personalization |
Technical Architecture and Examples
Both TikTok and Instagram Reels incorporate sophisticated distributed systems architectures that include data caches, load balancers, and massive storage solutions. They extensively use Content Delivery Networks (CDNs) and in-memory data stores (like Redis) to ensure that repeated reads are incredibly fast after the initial Fan-Out on Write.
For instance, when a TikTok user uploads a video:
- Transcoding: The video is converted into various formats suitable for different devices.
- Analysis: AI algorithms analyze the video’s content for appropriateness and tagging.
- Distribution: Based on the algorithm’s predictions, the video is pushed to various user feeds (Fan-Out on Write).
Conclusion
Choosing between Fan-Out on Read and Fan-Out on Write depends on the specific requirements of a platform, particularly in terms of read and write frequencies, data consistency needs, and latency sensitivity. For real-time, personalized content delivery platforms like TikTok and Instagram Reels, Fan-Out on Write offers an effective approach to manage vast user data and ensure a smooth user experience. However, the systems must be carefully managed to handle the storage and processing overhead that comes with this approach.

