Basic Concepts:
- Communication within a cluster (among the nodes in cluster):
- Tell everyone everything (not scalable O(n^2))
- Gossip Communication
- Distributed Cache
- Coordination Service: Leader Election
- Leader Election (Zookeeper/ Kubernetes):
- Paxos
- Raft
- Rate Limiting: (All 5 explained quite well in https://www.youtube.com/watch?v=mhUQe4BKZXs) https://engineering.classdojo.com/blog/2015/02/06/rolling-rate-limiter/
- Token Bucket: Can be implemented with Redis.
- Leaky Bucket
- Fixed Window Counter
- Sliding Window Counter
- Sliding Window Log
- Caching
- Strategies
- Read Through
- Write Through
- Write Behind
- Refresh Ahead
- Eviction Policies:
- LRU
- LFU
- MRU
- FIFO
- Load Balancing (Can be applied with Haproxy, Nginx):
- Consistent Hashing
- Round Robin
- Connection Types
- LongPoling
- WebSockets
- HTTP2
- Server Sent Events
- Replication, Partitioning & Sharding
- FLP Impossibility & CAP Theorem
- Guarantees:
- 100% Delivery of message
- At least once
- At most once
- Exactly Once
Specific Problems:
- Search TypeAhead
- Streaming DataTop K problem/ Heavy Hitters (Count Min sketch)
- Check if exists: (BloomFilter)
- Chat Service
- LeaderBoard
- File Storage
- Instagram/FB/Twitter Feed
- Ride Sharing
How to approach a problem:
- Capacity Estimation
- List out all the component:
- Load Balancer
- Major microservices
- Persistent DB
- Cache
- Queues
- CDN
- Media storage/ S3
- Rate Limiter: which one
- Analytics, Aggregation, Log collection & tracing
- Concepts to consider:
- RDBMS with sharding or NoSQL: Table Structures
- What kind of cache: Caching Strategy
- What Kind of data structures in cache
- What kind of load balancer: (sticky or round-robin)
- Connection Types: TCP/HTTP/WebSocket/SSE
- Push vs Pull of data: Fanout
- Hot users/nodes/
- Performance Optimisation
- consistent hashing for having in memory cache per node thus reducing network calls
- DB indexing, Primary & Secondary Indexes
- fast path, slow path approach for certain analytics and aggregation
- bloom filter & count min sketch approach