Leaking Bucket Algorithm

We have a bucket (queue FIFO) that can holds n requests. The queue will process the request at a fixed rate, for example 1 request per second/minute/hours
Pasted image 20230303164648.png

Parameters

  • BucketSize(QueueSize): how many requests can you hold to be processed at a fixed rate
  • Outflow rate: how many requests can be processed at fixed rate, usually in second

Pros and Cons

Pros

  • Memory efficient because of limited queue size
  • Requests are processed at a fixed rate, suitable for stable outflow rate

Cons

  • Because it's fixed rate, it's not well support for burst traffic
    • Why? - A burst traffic goes in and fills up the queue, new requests will be dropped
  • Hard to tune 2 parameters