out of scope:
1 billion DAU - assume they're all chatting, average 10 message per day
10B messages ~ 10e9 msgs / 86e3 s ~ (10/86)e6 ~ 0.86e6 ~ 86e4 ~ 860e3 ~ 860K TPS
50e3 websockets per server ~ 10e9 users ~ 1/5 e6 ~ 20e3 ~ 20k servers
10e9 per day ~ 1KB per message ~ 10e9KB ~ 10e6MB ~ 10e3 GB ~ 10 TB per day
300 TB per month ~ 3600 TB per year ~ 3.6 PT per year ~ 10 years is 36 PT
for messages alone 100 petabytes if theres redundancy
metadata = 1e9 users ~ 1KB metadata ~ 10TB metadata
indexing:
1e9 users ~ 8B ~ 8e9B ~ 8e6KB ~ 8e3MB ~ 8GB for user index
messages ~ 10e9 * 365 * 10 ~ 4e2 * 10e9 * 10y * 8B ~ 4e4 * 10e9 * 8B ~ 32e4 * 10e9 ~ 320 e13B
320e3GB ~ 320TB alone to index the messages
1 PB to be generous
~ 1 exabyte can handle the system from our calculations
~ 2 exa if we want to be safe
We will use a relational DB for user metadata.
We will use a Nosql DB to store messages.
UserDB
Messages
Presence
UserServerDB
Please refer to the HLD
Please refer to the HLD
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
+
Message Storage
Sending a Message
choice for queue
choice for db
choice for websockets