System Design Flashcards
Single Server Design
HTTP Server, database, single point of failure
Single server design with separated db
Two servers, Better resilency, single point of failure
Resilience
The capacity to withstand or recover from difficulties
Vertical Scaling
Make web server bigger, or db bigger, pros: not a lot of things to maintain
Horizontal Scaling
Load Balancer, More servers if traffic grows, web servers are stateless
Where do servers come from?
Own Data centers, Cloud Services, Serverless
Failover Servers: Cold Standby
Do a periodic backup of DB, have a semi-ready instance of the db, redirect traffic to that db in case of failure. CONS: take long, data after backup lost. PROS: Cheap and simple
Failover Servers: Warm Standby
DB is getting replicated live, switch to that db in case of failure
Failover Servers: Hot Standby
Server writes to both dbs, read from second if main is down
Failover DB: Horizontal Scaling
Sharding, a shard is an horizontal partition of your db, every shard has a backup.
What is a hotspot shard?
The shard that is receiving most traffic
Normalized DB
Data distributed across tables, relational Db. Less storage space, more lookups, updates in one place.
Denormalized DB
Have everything in one query, data in one table, more storage, updates are hard.