System Design Flashcards
ACID
ACID:
- Atomicity
- Consistency
- Isolation
- Durability
(traditional RDBMS)
ACID vs. BASE
- ACID ensures strong consistency.
- BASE favors availability and partition tolerance.
BASE
BASE:
- Basically Available
- Soft state
- Eventual consistency
(NoSQL)
ACID applies to ___ DBMS
Traditional Relational
BASE applies to ___ DB
NoSQL
Microservice
Microservices: small, independently deployable services.
Monolith
Monolith: single deployable artifact with all functionality.
Microservices vs. Monolith
Microservices scale independently but add complexity in communication and deployment
REST
REST: resource-based, typically over HTTP with JSON.
RPC
RPC: direct function calls (e.g., gRPC) often with protocol buffers.
REST vs. RPC
- REST is simpler, more flexible.
- RPC can be more efficient and strongly typed.
CAP Theorem
Definition:
In a distributed system, you can guarantee ONLY TWO of:
- Consistency
- Availability
- Partition Tolerance
If a network is partitioned, systems choose to be CP (consistent, not fully available) or AP (available, not fully consistent).
AP systems are ___ but not ___ (Partitioned network)
AP systems are AVAILABLE but not fully CONSISTENT
CP systems are ___ but not ___ (Partitioned network)
CP systems are CONSISTENT but not fully AVAILABLE
Scaling - Horizontal
Horizontal: adding more machines
Scaling - Vertical
Vertical: adding more resources (CPU/RAM) to existing machines
Horizontal vs. Vertical Scaling
Horizontal scaling is generally better for elasticity and resilience.
Definitions:
- Horizontal: adding more machines.
- Vertical: adding more resources (CPU/RAM) to existing machines.
Load Balancer
Definition:
Distributes network or application traffic across multiple servers.
- Improves scalability, fault tolerance, and availability.
- Can operate at different layers (L4 vs. L7).
Rate Limiter
Definition:
A mechanism or service that limits the number of requests a client can make in a defined time window.
- Prevents abuse or DoS (Denial of Service) attacks by throttling excessive requests.
- Common algorithms include Token Bucket or Leaky Bucket.
Redis
Definition:
An in-memory key-value data store used for caching, messaging, and fast data operations.
- Offers high throughput and low latency.
- Supports data structures (strings, lists, sets, hashes) and persistence options.
- Often used for session management, leaderboards, rate limiting, etc.
APIs
Definition:
Application Programming Interfaces provide a contract for how different software components communicate.
- Often exposed as REST, SOAP, GraphQL, or gRPC endpoints.
- Require versioning, authentication, and rate limiting considerations in production.
Transactions
Definition:
A sequence of operations performed as a single logical unit of work, which must either fully complete or fully fail (rollback).
- In relational databases, transactions follow ACID properties.
- Distributed transactions can be more complex (e.g., two-phase commit).
Primary Key
Definition:
A column (or set of columns) in a relational table that uniquely identifies each row.
- Ensures uniqueness of records.
- Cannot contain NULL (in most SQL implementations).
- Often indexed for fast lookups.