← Reddit Interview InsightsSoftware Engineer

Reddit·Software Engineer·Onsite - Coding / Algorithms·Senior

SeniorPrefer not to say
Jun 2026

Summary

Reddit coding round for a software engineer role, one open-ended problem on rate limiting that was way more design-heavy than I expected from a coding interview. They basically handed you a blank canvas and wanted you to drive the whole thing yourself.

Questions Asked (1)

Q1

Implement a RateLimiter class with an allow(key) method that returns whether a request from a given key is permitted under a configured policy. You're expected to drive the design choices yourself, including algorithm selection, thread safety, state model, failure behavior, and configuration.

System DesignTechnical Trade-offsAlgorithms & Data Structures
Author's notes

I went with a sliding window counter because it felt like the right middle ground between accuracy and memory, but I fumbled explaining why I wasn't using a token bucket.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (e.g., rate limit policy, distributed vs. single-node, failure semantics) and then propose a concrete design using a token bucket or sliding window algorithm. Walk through the implementation details, emphasizing thread safety, state management, and configuration, and discuss trade-offs and failure behavior.

Pro tip: Demonstrate awareness of production concerns by mentioning metrics, logging, and graceful degradation (e.g., fail-open vs. fail-closed) and how you'd test the limiter under concurrency.

1. Clarify Requirements and Constraints

Ask questions to understand the expected scale, whether the limiter is distributed, the desired algorithm (e.g., token bucket, sliding window), and failure semantics (e.g., fail-open or fail-closed).

2. Choose Algorithm and State Model

Select a rate limiting algorithm (e.g., token bucket for burstiness, sliding window for precision) and define the state per key (e.g., tokens, timestamps) and how it's stored (in-memory or external store).

3. Design Thread-Safe Implementation

Explain how to ensure thread safety (e.g., using locks, atomic operations, or concurrent data structures) and handle concurrent access to shared state.

4. Define Configuration and Failure Behavior

Describe how the limiter is configured (e.g., rate, burst size) and what happens on failures (e.g., if the backing store is unavailable, do you allow or deny requests?).

5. Discuss Trade-offs and Extensions

Compare your choices with alternatives (e.g., distributed vs. local, different algorithms) and mention potential improvements like metrics, logging, and dynamic configuration.

Key Points to Mention

  • Algorithm selection: token bucket vs. sliding window vs. fixed window, and their trade-offs (burstiness, memory, precision).
  • Thread safety: use of locks, atomic types, or concurrent data structures; avoid race conditions.
  • State model: per-key state (e.g., tokens, last refill time) and cleanup of stale keys to prevent memory leaks.
  • Failure behavior: fail-open vs. fail-closed, and how to handle backing store failures (e.g., Redis down).
  • Configuration: how rate limits are set (e.g., per key, global) and whether they can be changed dynamically.
  • Distributed considerations: using a centralized store (e.g., Redis) with atomic operations or Lua scripts for consistency.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.