Introduction:
Microblogging platforms have become a crucial part of our online social interactions. In this blog post, we will delve into the design considerations and architecture for creating a highly scalable, available, and consistent micro-blogging platform to meet the demands of a large user base.
Functional Requirements:
- User Actions:
- Users can create public or followers-only posts.
- Following other users.
- Like and comment on posts.
- Reply to comments.
- Edit and delete your own comments.
- Sort comments based on time or likes.
- View trending tweets/posts.
Non-functional Requirements:
- High Availability:
- The system should be available 24/7 to accommodate users from different time zones.
- Low Latency:
- Users should experience minimal latency when creating and viewing posts.
- Eventual consistency is acceptable for some features.
Capacity Estimations:
- Daily Active Users (DAU):
- 10 million users.
- Estimated Queries Per Second (QPS): 115.
- Posts:
- 5% create posts, 30% engage with posts, and the rest are viewers.
Storage Estimations:
- Post Storage:
- 5TB per day.
- Total storage for 5 years: 9125TB.
- Post Storage:
- 5TB per day.
- Total storage for 5 years: 9125TB.
Database Design:
- User Table (SQL):
- Unique identifier (Mobile/Email).
- First/Last Name.
- Post Table (SQL)
- Post ID.
- User ID.
- Comment ID.
- Media link (Stored in GCS/S3)
- Comment Table (SQL):
- Comment ID.
- User ID.
- Comment content.
- Reply Table (SQL):
- Reply ID.
- Comment ID.
- Reply content.
- Connection Table (SQL):
- User ID.
- Followed User ID.
- Like Table (HBase):
- User ID.
- Post ID.
- Like count.
Data Storage:
- GCS/S3:
- For static media associated with posts.
- Feed DB:
- Batch job-based storage for the user feed.
APIs:
- Create Post:
- Endpoint: /create_post
- Parameters: Token, Message, Media.
- Returns: JSON.
- Follow:
- Endpoint: /follow
- Parameters: Token, UserID.
- Returns: Boolean.
- Like:
- Endpoint: /like
- Parameters: Token, PostID, Count.
- Comment:
- Endpoint: /comment
- Parameters: Token, PostID, Comment.
- Reply:
- Endpoint: /reply
- Parameters: Token, CommentID, Reply.
- Update:
- Endpoint: /update
- Parameters: Token, PostID, Operation (Edit/Delete).
- Get Feed:
- Endpoint: /get_feed
- Returns: JSON (trending with posts).
- Search:
- Endpoint: /search
- Returns: User/Post information.
High-Level Design:

Conclusion:
Designing a micro-blogging platform involves meticulous planning to handle the immense user base and their interactions. By incorporating scalable database structures, distributed storage, and efficient APIs, we can create a system that fulfills the functional and non-functional requirements, providing users with a seamless and engaging experience.