Implement and Test a Sliding-Window Rate Limiter

Quick Overview

Design an in-memory limiter with `allow(key, timestamp)` for a configurable maximum number of requests in the preceding window. Make the API or object boundaries explicit, then cover invariants, edge cases, testing strategy, and operational trade-offs.

Implement and Test a Sliding-Window Rate Limiter

Company: Snowflake

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

# Implement and Test a Sliding-Window Rate Limiter Design an in-memory limiter with `allow(key, timestamp)` for a configurable maximum number of requests in the preceding window. ### Constraints & Assumptions - Timestamps for one key are nondecreasing. - Rejected requests do not consume capacity. ### Clarifying Questions to Ask - Is the interval left-open or left-closed? - Is the limit per process or global? ### What a Strong Answer Covers - Per-key eviction, boundary semantics, concurrency, and cleanup. - Focused tests for bursts and exact cutoffs. ### Follow-up Questions - How would you distribute the limiter? - What changes if rejected requests count?

Quick Answer: Design an in-memory limiter with `allow(key, timestamp)` for a configurable maximum number of requests in the preceding window. Make the API or object boundaries explicit, then cover invariants, edge cases, testing strategy, and operational trade-offs.

|Home/Software Engineering Fundamentals/Snowflake
Snowflake logo
Snowflake
Jun 2, 2026, 12:00 AM
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
0
0

Implement and Test a Sliding-Window Rate Limiter

Design an in-memory limiter with allow(key, timestamp) for a configurable maximum number of requests in the preceding window.

Constraints & Assumptions

  • Timestamps for one key are nondecreasing.
  • Rejected requests do not consume capacity.

Clarifying Questions to Ask Guidance

  • Is the interval left-open or left-closed?
  • Is the limit per process or global?

What a Strong Answer Covers Guidance

  • Per-key eviction, boundary semantics, concurrency, and cleanup.
  • Focused tests for bursts and exact cutoffs.

Follow-up Questions Guidance

  • How would you distribute the limiter?
  • What changes if rejected requests count?
Loading comments...