Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
Client
load balancer
web service
sql database
redis for friends (read replica)
cdn
kafka to handle writes into the db, like following operation
because the tweets and users have known schema.
tweet -> id, message, owner_id (foreign key on user.id), likes
user -> id, name, lastname, email, picture_url, friend_id (foreign key on user.id)
we need some sharding given the volume of data. We could shard the users by region, so clients in one region access their info from a closer database in their region. It is also a legal requirement for the GDPR regulation in EU. To handle friend relationship (followers and followed) without fetching data across multiple db shards, we need a table owned by every user, where we store the following relationship. For that we can use a graph database, which is quite good for modelling these types of relationship