Let's calculate the storage requirements for storing tweets. Assuming each tweet has an average length of 280 characters and each character occupies 1 byte (assuming Unicode characters), and we expect to have 1 million users, with each user making 5 tweets on average.
Total characters per tweet = 280 bytes Average tweets per user per day = 5 Total tweets per day = 1,000,000 users * 5 tweets/user = 5,000,000 tweets Total characters per day = 5,000,000 tweets * 280 bytes/tweet = 1,400,000,000 bytes
Converting bytes to GB: Total storage per day = 1,400,000,000 bytes / (1024^3) GB = 1.305 GB
Therefore, we would need approximately 1.305 GB of storage per day to store tweets from 1 million users. We can scale up the storage infrastructure accordingly based on user growth projections and expected tweet frequency.
/register: Registers a new user./login: Logs in an existing user./profile: Retrieves and updates user profile information./post: Creates a new tweet./delete: Deletes a tweet.Timeline Service:
/timeline: Retrieves the timeline of tweets for a user.Follow Service:Responsibilities:Manages user relationships: Handles user follow/unfollow actions.
/follow: Follows a user./unfollow: Unfollows a user./followers: Retrieves followers of a user./following: Retrieves users being followed by a user./like: Likes a tweet./comment: Adds a comment to a tweet./likes: Retrieves likes for a tweet./comments: Retrieves comments for a tweet./sendNotification: Sends a notification to a user./getNotifications: Retrieves notifications for a user.
In our Twitter-like application, we leverage Redis for storing tweets and ensuring real-time updates to user timelines. Here's a detailed overview of how we handle tweet distribution, timeline generation in Redis, and address challenges, particularly for celebrity users with a large follower base:
By leveraging Redis for storing tweets, generating timelines, and implementing optimizations for scalability, our Twitter-like application delivers a reliable and responsive experience to users of all sizes, including celebrity users with large follower bases.
retry flow
log system and mintor system