system design cheat sheet Flashcards

(7 cards)

1
Q

CAP Theorem

A
  • Consistency (C) → Both branches must always show the same account balance.
  • Availability (A) → You can always withdraw money at any branch.
  • Partition Tolerance (P) → Sometimes the network between branches fails.

Consistent when Partitioned (CP)

  • Not available for writes
  • However, data is consistent

Available when Partitioned (AP)

  • Available for writes
  • However, data is inconsistent
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Data Storage

A

Relational DB (RDS, Postgres, MySQL) → Strong consistency, joins, transactions.

NoSQL (MongoDB, DynamoDB, Cassandra) → Flexible schema, high write/read throughput, denormalization.

Object storage (S3, GCS) → Cheap, durable, good for files/blobs.

Time-series DB (InfluxDB, TimescaleDB) → Optimized for append-only, temporal queries.

Rule of thumb: Store metadata in DB, large blobs in S3.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Caching

A

Where?

  • Client-side → browser/app.
  • CDN → static content close to users (CloudFront, Akamai).
  • App-level → Redis, Memcached.
  • DB query caching.

Eviction policies: LRU, LFU, TTL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Estimation (quick math for interviews)

A

Storage:
* 1 KB ≈ 1,000 bytes; 1 MB ≈ 1M bytes; 1 GB ≈ 1B bytes.
* Text row (id + timestamp + ~200 chars) ≈ 1 KB
* Photo (JPEG, compressed) ≈ 200 KB
* 1 minute of video (Full HD 1080p) ≈ 10 MB

Cache:
* 20% of total for 99% hit rate
* Each machine 1TB ram

RPS estimation:
* Lambda ≈ 1000; EC2 ≈ 500 (t3.medium) - 10,000 (c6i.4xlarge)
* DAU × requests/user ÷ seconds in a day.
* Example: 10M DAU × 20 req ÷ 86,400 ≈ 2,300 RPS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

AWS Services Use Cases

A
  • Storage → S3, DynamoDB, RDS
  • Messaging → SNS, SQS, Kinesis
  • Processing → Lambda, Step Functions, ECS
  • Security/Identity → IAM, Cognito, KMS
  • Analytics → Athena, Redshift, QuickSight
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When stuck

A

Storage, throughput, consistency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Steps

A
  1. Clarify (ask questions)
  2. Define Requirements (functional and non-functional)
  3. Identify Core Components (API Gateway, Lamdba, RDS, etc)
  4. Draw a High-Level Architecture and Discuss Data Storage & Flow
  5. Dive Into Critical Paths (ex: Feature Flags: flag evaluation is critical — focus on low-latency reads and cache invalidation)
  6. Sketch 2–3 sample API endpoints
  7. Handle Scaling & Reliability
  8. Trade-offs & Alternatives
  9. Wrap-Up & Questions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly