Modeling API Rate Limits as Diophantine Inequalities

2025-06-30

This article explores a mathematical approach, specifically using Diophantine inequalities, to solve API rate limiting problems. The author uses a scenario with a 10-requests-per-hour limit and three retry attempts per task as an example, demonstrating how to transform the task scheduling problem into an integer feasibility problem. By analyzing the task retry pattern and time windows, the author establishes an inequality model and uses Go to write a program that determines whether a new task can be safely scheduled without exceeding the rate limit. The article also mentions optimizing the algorithm to reduce time complexity from O(n^2) to O(n*log(n)).

Read more

Grokking NAT: Linux's Clever Workaround for IPv4 Exhaustion

2025-06-18

Imagine your home Wi-Fi network: all devices share the same public IP address. This is thanks to Network Address Translation (NAT). With limited IPv4 addresses, NAT cleverly maps private IPs to a single public IP on your router, letting multiple devices share a single public IP. This article dives into NAT's workings, exploring different types (Full Cone, Restricted Cone, Symmetric NAT) and its Linux implementation (using nftables), illustrated with a Docker example. While NAT temporarily solves IPv4 exhaustion, it introduces limitations like breaking end-to-end connectivity and complicating encryption. Ultimately, widespread IPv6 adoption is the true solution.

Read more
Development