Search⌘ K
AI Features

Feature #4: Request Limiter

Explore how to implement a request limiter that throttles API calls for specific Status IDs by using hash tables. Learn to accept or reject requests based on their timestamps and handle concurrency for multiple IDs. Understand the constant time complexity approach and optimize space usage for scalable request handling.

Description

The Facebook Status API queues requests using the requested Status ID and a timestamp. We want to implement a throttling mechanism on the requests that limits one request for a particular Status ID at a pre-configured time interval. Any additional requests for the same Status ID in this interval will be dropped. Multiple requests for different Status IDs can occur at the same time.

We’ll be provided with the name of the request and the time it arrived. Our system will have to decide whether to accept the request or reject it based on its arrival time. In this scenario, we’ll use a time limit of five days before a similar request can be sent from the same or different platform.

Solution

The hashtable data structure will be used to implement this feature. This data structure can ...