← Akuna Capital Interview Insights
The API signature they gave was basically RateLimit(maxMsgCount, windowMs) and a checkRateLimit(suggestOrders, timestamp) that returns how many messages are actually allowed.
Start by clarifying requirements and constraints, then propose a design using a timestamp queue or token bucket with sliding window semantics. Discuss trade-offs between precision, memory, and performance, and outline test cases covering edge conditions and concurrency.
Pro tip: Emphasize thread safety and atomicity for batch sends—many candidates overlook that checking and sending must be atomic to avoid race conditions in a trading engine.
Ask about expected throughput, precision needs, whether limits are per-client or global, and if batch sends should be atomic. Confirm that the window is continuous (sliding) and not fixed buckets.
Propose a timestamp queue (e.g., deque) storing send times, or a token bucket with sliding window approximation. Discuss trade-offs: exactness vs. memory, and O(1) vs. O(n) operations.
Define methods like canSend(n), recordSend(n), or trySend(n) that atomically check and update state. Include configuration for limit and window size, and ensure thread safety with locks or atomic operations.
Explain how to check if a batch of size n can be sent: either check if n messages fit within the window, or if partial sends are allowed, return the maximum allowed. Ensure atomicity for the batch.
List tests: single send under/over limit, batch sends, sliding window expiry, concurrent sends, and edge cases like zero limit or large batch. Include performance tests if needed.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.