0
0
LLDsystem_design~12 mins

Immutability for safety in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Immutability for safety

This system demonstrates how immutability helps keep data safe and consistent. It ensures that once data is created, it cannot be changed, preventing accidental or malicious modifications. The system supports multiple users reading data safely while updates create new versions without altering existing ones.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
Immutable Service
  |
  +----------------+
  |                |
  v                v
Immutable Store   Cache
(Database with     (Read-only
append-only data)  cache for
                   fast reads)
Components
User
client
Initiates requests to read or write data
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Routes requests to the Immutable Service and handles authentication
Immutable Service
service
Processes requests, enforces immutability by creating new data versions instead of modifying existing ones
Immutable Store
database
Stores data in an append-only manner to preserve history and prevent changes to existing data
Cache
cache
Provides fast read access to frequently requested immutable data
Request Flow - 11 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayImmutable Service
Immutable ServiceCache
CacheImmutable Service
Immutable ServiceImmutable Store
Immutable StoreImmutable Service
Immutable ServiceCache
Immutable ServiceAPI Gateway
API GatewayLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Immutable Store
Impact:New writes fail because data cannot be appended; reads may still succeed if cache has data
Mitigation:Use database replication and failover to a standby immutable store; cache serves stale data during failover
Architecture Quiz - 3 Questions
Test your understanding
Which component ensures that data once written cannot be changed?
ALoad Balancer
BImmutable Service
CCache
DAPI Gateway
Design Principle
This architecture uses immutability to ensure data safety by never modifying existing data. Instead, new versions are appended, preserving history and preventing accidental changes. Caching immutable data improves read performance without risking stale or inconsistent data.