Bird
Raised Fist0
HLDsystem_design~12 mins

Social graph storage in HLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Social graph storage

This system stores and manages social connections between users, such as friendships or followers. It must handle fast queries to find friends, mutual connections, and support updates like adding or removing connections efficiently.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
+-------------------+       +----------------+
| Social Graph       |<----->| Cache (Redis)  |
| Service           |       +----------------+
| (Handles queries,  |
|  updates)          |
+-------------------+
          |
          v
+-------------------+
| Graph Database     |
| (e.g., Neo4j,      |
|  Cassandra with    |
|  graph model)      |
+-------------------+
Components
User
user
End user who sends requests to view or update social connections
Load Balancer
load_balancer
Distributes incoming user requests evenly to API Gateway instances
API Gateway
api_gateway
Entry point for client requests, handles authentication and routing
Social Graph Service
service
Processes social graph queries and updates, interacts with cache and database
Cache (Redis)
cache
Stores frequently accessed social graph data to reduce database load and improve response time
Graph Database
database
Stores the social graph data with relationships, supports complex graph queries
Request Flow - 10 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewaySocial Graph Service
Social Graph ServiceCache (Redis)
Cache (Redis)Social Graph Service
Social Graph ServiceGraph Database
Graph DatabaseSocial Graph Service
Social Graph ServiceCache (Redis)
Social Graph ServiceAPI Gateway
API GatewayUser
Failure Scenario
Component Fails:Graph Database
Impact:New updates to social connections fail; cache may serve stale read data
Mitigation:Use database replication for failover; serve reads from cache during outage; queue updates for retry
Architecture Quiz - 3 Questions
Test your understanding
Which component is responsible for distributing incoming user requests evenly?
ALoad Balancer
BAPI Gateway
CCache
DGraph Database
Design Principle
This architecture uses caching to reduce database load and improve response times for social graph queries. The load balancer and API gateway ensure scalable and secure request handling. The graph database stores complex relationships efficiently, while cache and replication improve availability and performance.