Algorithm · Databricks · Medium
Design a lightweight in-memory monitor for a service’s request load. The monitor has two operations: record(timestamp): register one incoming request at the given second. getQPS(timestamp): return the average requests per second over the five-minute interval ending at timestamp. For a query time $$t$$, the value to return is $$ \text{QPS}(t)=\frac{ \{x \mid x \text{ is a recorded timestamp and } t-300 < x \le t\} }{300}. $$ All timestamps are integer seconds and appear in…
Checking your access…