View organization page for AKCoding.com

1,218 followers

𝗧𝗼𝗽 𝟱 𝗥𝗮𝘁𝗲 𝗟𝗶𝗺𝗶𝘁𝗶𝗻𝗴 𝗔𝗹𝗴𝗼𝗿𝗶𝘁𝗵𝗺𝘀 𝗬𝗼𝘂 𝗦𝗵𝗼𝘂𝗹𝗱 𝗸𝗻𝗼𝘄: 1) 𝐓𝐨𝐤𝐞𝐧 𝐁𝐮𝐜𝐤𝐞𝐭 A bucket fills with tokens at a fixed rate. Each request consumes one token. If the bucket is empty (tokens run out) → request is throttled. Great when you want to allow short bursts while enforcing an average request rate. 2) 𝐅𝐢𝐱𝐞𝐝 𝐖𝐢𝐧𝐝𝐨𝐰 𝐂𝐨𝐮𝐧𝐭𝐞𝐫 Divides time into fixed windows (e.g., per minute). Counts requests in the current window. If the count exceeds the limit → block. Simple to implement, but suffers from burst spikes at window edges. 3) 𝐋𝐞𝐚𝐤𝐲 𝐁𝐮𝐜𝐤𝐞𝐭 Think of a queue that leaks at a constant rate. If new requests exceed queue capacity → they are dropped. Produces a smooth and predictable request flow. 4) 𝐒𝐥𝐢𝐝𝐢𝐧𝐠 𝐖𝐢𝐧𝐝𝐨𝐰 𝐋𝐨𝐠 Stores a timestamp for each request. For every new request, removes old timestamps outside the window and count the rest. Highly accurate, but expensive in memory for high-traffic systems. 5) 𝐒𝐥𝐢𝐝𝐢𝐧𝐠 𝐖𝐢𝐧𝐝𝐨𝐰 𝐂𝐨𝐮𝐧𝐭𝐞𝐫 Hybrid of Fixed Window + Log. Splits the window into smaller buckets and uses a weighted sum to estimate the rate. Provides good balance between accuracy and memory efficiency. Which of these do you use most often in production? ♻️ Repost to help more engineers learn this. #java #programming #software

To view or add a comment, sign in

Explore content categories