This question evaluates a candidate's ability to design and implement a thread-safe per-user API rate limiter, focusing on concurrency control, synchronization techniques, and time-based request accounting in the Coding & Algorithms domain.
Design and implement a per-user API rate limiter.
Requirements:
boolean allow(String userId, long nowMillis)
returns whether the request is allowed at time
nowMillis
.
Follow-ups:
allow
for the same
userId
)?
ConcurrentHashMap
, atomics) and performance implications.