Understanding System Design Fundamentals

1. Understanding Scalability Concepts

TypeApproachTrade-offs
Vertical (Scale Up)Increase CPU/RAM/disk on single nodeSimple, hard limit, single point of failure, expensive
Horizontal (Scale Out)Add more nodes behind LBLinear cost, complex coordination, requires statelessness
DiagonalVertical until limit, then horizontalPragmatic hybrid, common in practice
Functional DecompositionSplit by feature/serviceMicroservices, independent scaling
Data PartitioningShard data across nodesScales storage + writes; cross-shard joins hard
Note: Scalability is measured by throughput (RPS), latency at p95/p99, and concurrent users. Always define scaling target before designing.

2. Understanding Availability Requirements

SLA TierUptime %Downtime/YearDowntime/Month
Two nines99%3.65 days7.2 hours
Three nines99.9%8.77 hours43.8 min
Four nines99.99%52.6 min4.38 min
Five nines99.999%5.26 min26.3 sec

Example: Composite availability of dependent services

Service A (99.9%) → Service B (99.9%) → Service C (99.9%)
Composite = 0.999 × 0.999 × 0.999 = 0.997 (99.7%)
Mitigation: redundancy, async fallback, circuit breakers

3. Understanding Reliability Patterns

PatternPurposeExample
RedundancyEliminate SPOFsN+1 servers, multi-AZ DB
ReplicationData durability + read scaling3-way replicated storage
FailoverAutomatic switch on failureActive-passive DB, VRRP
Health checksDetect failure fastK8s liveness/readiness
Retries + backoffHandle transient errorsExponential backoff + jitter
Circuit breakerStop cascading failureResilience4j, Hystrix
BulkheadIsolate failure domainsPer-tenant thread pools

4. Understanding Consistency Models

ModelGuaranteeUse Case
Strong (Linearizable)All reads see latest write immediatelyBanking, inventory
SequentialAll clients see same orderDistributed locks
CausalCausally related ops in orderComments, social feeds
Read-your-writesClient sees own writesUser profile updates
Monotonic ReadsNo going back in timeTimeline views
EventualReplicas converge eventuallyDNS, S3, Cassandra

5. Understanding CAP Theorem

ChoiceSacrificeExamples
CPAvailability during partitionHBase, MongoDB (default), ZooKeeper, etcd
APStrong consistencyCassandra, DynamoDB, Riak, CouchDB
CAPartition tolerance (only single-node)RDBMS on single node
Warning: Network partitions are inevitable in distributed systems. CA is not realistic — you must choose CP or AP during partitions.

6. Understanding PACELC Theorem

SystemPartition (P)Else (E)
DynamoDBPAEL (low latency over consistency)
CassandraPAEL
MongoDBPCEC
SpannerPCEC (TrueTime keeps latency low)
CockroachDBPCEC
Note: PACELC extends CAP: if Partition then A or C; else if no partition, choose Latency or Consistency.

7. Understanding Latency vs Throughput Trade-offs

MetricDefinitionOptimization
LatencyTime per single request (ms)Caching, CDN, reduce hops, faster algorithms
ThroughputRequests per second (RPS)Batching, parallelism, async I/O
p50/p95/p99Percentile latencyReduce tail: hedged requests, isolation
Little's LawL = λ × W (concurrency = arrival × wait)Reduce W or limit L for predictability

8. Understanding Fault Tolerance Principles

PrincipleImplementation
Fail fastShort timeouts, reject early
Fail safeDefault to safe state on failure
Graceful degradationReduced functionality vs total outage
Self-healingAuto-restart, auto-replace nodes
IdempotencySafe retries
IsolationBulkheads prevent cascade

9. Understanding Data Redundancy and Replication

StrategyConsistencyUse Case
Synchronous replicationStrongFinancial txns; higher write latency
Asynchronous replicationEventualRead replicas; risk of data loss on failover
Semi-syncBounded stalenessWait for ≥1 replica ack
Multi-leaderEventual + conflictsMulti-region writes
Leaderless (quorum)Tunable (R+W>N)Cassandra, Dynamo

10. Understanding Single Points of Failure (SPOF)

SPOFMitigation
Single DB instancePrimary + replicas, multi-AZ
Single load balancerPair with VRRP/keepalived; managed LB
Single regionMulti-region active-active or active-passive
DNS providerMulti-DNS (Route53 + NS1)
Shared cacheCluster mode + replication
Cert authorityMultiple CAs, automated rotation

11. Understanding Trade-offs in System Design

Trade-offPick APick B
Consistency vs AvailabilityRDBMS, bankingSocial feed, catalog
Latency vs ThroughputReal-time APIBatch ETL
Read-heavy vs Write-heavyCache, replicasSharding, LSM stores
SQL vs NoSQLACID, joins, schemaScale, flexible schema
Sync vs AsyncImmediate responseDecoupling, resilience
Build vs BuyCore differentiatorCommodity infra

12. Understanding SLA and SLO Design

TermMeaningExample
SLIIndicator (measurement)Request success rate, p99 latency
SLOInternal objective99.95% success/30d, p99 < 200ms
SLAExternal contract w/ penalties99.9% uptime or refund
Error Budget1 - SLO; budget for risk0.05% downtime/month allowed
Note: SLA < SLO < SLI accuracy. Buffer SLA below SLO. Halt feature releases when error budget burns too fast.