Bird
Raised Fist0
HLDsystem_design~20 mins

Social graph storage in HLD - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Social Graph Storage Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Architecture
intermediate
2:00remaining
Designing a scalable social graph storage system

You need to design a system to store and query a social graph with billions of users and their connections. Which architecture best supports fast retrieval of a user's friends and mutual friends?

AUse a relational database with tables for users and friendships, indexed by user IDs.
BUse a key-value store where each user ID maps to a list of friend IDs.
CUse a graph database optimized for traversals, storing users as nodes and friendships as edges.
DUse a document database storing each user document with embedded friend lists.
Attempts:
2 left
💡 Hint

Think about which storage type naturally represents relationships and supports fast graph queries.

scaling
intermediate
2:00remaining
Scaling social graph storage for high write throughput

Your social graph system must handle millions of new friendship connections per minute. Which approach best supports this write load while maintaining query performance?

AUse a single master database to serialize all writes and replicate to read replicas.
BPartition the graph by user ID ranges and distribute partitions across multiple servers.
CStore all friendships in a single large cache to speed up writes.
DBatch all writes and apply them once per hour to reduce load.
Attempts:
2 left
💡 Hint

Consider how to distribute data to avoid bottlenecks and allow parallel writes.

tradeoff
advanced
2:00remaining
Tradeoffs between consistency and availability in social graph storage

In a distributed social graph system, which choice best describes the tradeoff when prioritizing availability over consistency?

AUsers may see stale friend data during network partitions but the system remains available.
BUsers always see the most up-to-date friend list but the system may be unavailable during network issues.
CThe system rejects writes during network partitions to maintain consistency.
DThe system duplicates data to all nodes synchronously to ensure consistency.
Attempts:
2 left
💡 Hint

Think about the CAP theorem and what happens when availability is prioritized.

🧠 Conceptual
advanced
2:00remaining
Choosing data models for social graph storage

Which data model best supports efficient queries for "friends of friends" in a social graph?

ARelational tables with join queries on user and friendship tables.
BKey-value store with user IDs as keys and friend lists as values.
CDocument store with embedded friend lists inside user documents.
DGraph model with nodes representing users and edges representing friendships.
Attempts:
2 left
💡 Hint

Consider which model naturally expresses multi-level relationships.

estimation
expert
3:00remaining
Estimating storage requirements for a social graph

Estimate the storage needed to store a social graph with 1 billion users, each having an average of 200 friends. Assume each user ID and friend ID requires 8 bytes, and each friendship is stored bidirectionally.

AApproximately 3.2 terabytes
BApproximately 1.6 terabytes
CApproximately 6.4 terabytes
DApproximately 12.8 terabytes
Attempts:
2 left
💡 Hint

Calculate total friendships, multiply by bytes per friendship, and consider bidirectional storage.