Category: System Design

  • Rate Limiter #3 – Sliding Window Algorithm

    Advantages / Disadvantages Advantages Disadvantages Implementation Implementation – Output FollowUp Questions #1. How does your Sliding Window Counter implementation handle memory consumption, especially with high request rates or large window sizes? Are there optimizations to reduce memory usage? #2. The same FollowUp Question #1~#5 in https://willtheguruhome.wordpress.com/2025/01/12/rate-limiter-token-bucket-algorithm/ is possible

  • Rate Limiter #2 – Leaky Bucket Algorithm

    Advantages / Disadvantages Advantages Disadvantages Implementation Implementation – Output FollowUp Question #1. In your outflow() method, you calculate secondsSinceOutflow by dividing the time difference in milliseconds by 1_000. Is this approach accurate for refilling the bucket? Why or why not? #2. How efficient is your LeakyBucketRateLimiter implementation in terms of…

  • Rate Limiter #1 –Token Bucket Algorithm

    Advantages / Disadvantages Advantages Disadvantages Implementation Implementation – Output FollowUp Question #1. Is it thread-safe? How does it handle concurrent requests? #2. Can you implement a lock-free approach for Rate Limiter? #3. How would you adapt your rate limiter to function correctly in distributed system? #4. How should you update…

  • Scalability – Harvard Web Development by David Malan

    Vertical Scaling Horizontal Scaling RAID(Redundant Array of Independent Disks) Sticky Session Replication Load Balancer Redundancy Partitioning Reference

  • Push & Pull Technologies

    Pull Technology #1. Short Polling #2. Long Polling Short Polling vs Long Polling Push Technology #1. WebSocket How does WebSocket work? Advantages of WebSocket #2. Server-Sent Events Advantages & Disadvantages of Server-Sent Events Advantages Disadvantages Reference

  • Peer Discovery

    Service Discovery Services(A,B,..) can discover each other through service registry servers How does service registry server know each other? 2. Using DNS (TXT record) Gossip Protocol Peer discovery can be accomplished through gossip protocol, which is actually being used from Apache Cassandra. How does Gossip Protocol works on Apache Cassandra?…

  • Service Discovery

    For services to discover other services, they need to know others’ IPs and Ports, which can be done through service discovery on either client side or server side. Client Side Server Side Reference

  • Message push vs pull model

    Push model is a model that broker pushes the message to the consumer, while pull model is a model that consumer pulls the message from the broker whenever consumer wants. Pros and Cons Push model Pull model Reference

  • Designing a key-value database

    Designing a simple key-value database using Log Compaction While read and write is both fast for the above design, as Create/Update/Delete operation keeps add new record to the list and consumes memory, we need to improve the memory usage. To achieve that, we can use ‘Log Compaction’ to improve it.…

  • Thread Pool

    Thread per Request Thread Pool How to size a thread pool? #1. CPU-bound task #2. I/O-bound task Graceful Shutdown Graceful Shutdown Sequence Reference