Pregunta de entrevista de Intuit

How can you implement a rate limiter in Java? Need to call a rateLimiter function that return true if you can perform a request and false if you cannot. The rate limiter is limited by number of calls during X seconds, each caller has a unique id.

Respuesta de la entrevista

Anónimo

26 oct 2024

A map with key = unique Id, value = counter of calls and a thread running in the background that cleans the map each X seconds.