Search⌘ K

Feature #4: Request Limiter

Explore how to implement a request limiting feature for Facebook's Status API using hash tables. This lesson guides you through controlling request frequencies by storing and checking timestamps, ensuring repeated requests for the same status ID are throttled efficiently and only allowed after a five-day interval.

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 uniquely store all of the incoming requests while simultaneously taking care of the duplicate requests. The requests will be ...