PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Coding & Algorithms/Microsoft

Implement a rate limiter at scale

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of algorithmic and system-level design for per-key rate limiting, including data structures, time/space complexity, concurrency, hot-key mitigation, and distributed deployment in the Coding & Algorithms domain.

  • medium
  • Microsoft
  • Coding & Algorithms
  • Software Engineer

Implement a rate limiter at scale

Company: Microsoft

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

## Problem Design and implement a **rate limiter** that enforces request limits per key (e.g., per user ID or API key). ### Requirements - Implement `allow(key, timestamp)` → returns `true` if the request is allowed, else `false`. - Support a policy like: **at most N requests per sliding window of W seconds** (you may choose fixed-window vs sliding-window, but state it clearly). - Handle many distinct keys. ### Follow-up (scale) How would you adapt the design/implementation if the service must handle **100K QPS**? Discuss: - Data structures and time/space complexity - Concurrency/thread safety - Distributed deployment (multiple instances) and correctness trade-offs - Hot-key mitigation and storage choices ### Constraints (assumptions you may make explicit) - Timestamps are in milliseconds or seconds (choose one). - Keys are strings. - Memory is limited; old state should expire.

Quick Answer: This question evaluates understanding of algorithmic and system-level design for per-key rate limiting, including data structures, time/space complexity, concurrency, hot-key mitigation, and distributed deployment in the Coding & Algorithms domain.

Related Interview Questions

  • Return Top K Open Businesses - Microsoft (hard)
  • Implement Memory Allocation and In-Memory Records - Microsoft (medium)
  • Implement K-Means and Detect Divisible Subarrays - Microsoft (medium)
  • Sort Three Categories In Place - Microsoft (medium)
  • Retain Top K Elements - Microsoft (medium)
Microsoft logo
Microsoft
Jan 22, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
6
0
Loading...

Problem

Design and implement a rate limiter that enforces request limits per key (e.g., per user ID or API key).

Requirements

  • Implement allow(key, timestamp) → returns true if the request is allowed, else false .
  • Support a policy like: at most N requests per sliding window of W seconds (you may choose fixed-window vs sliding-window, but state it clearly).
  • Handle many distinct keys.

Follow-up (scale)

How would you adapt the design/implementation if the service must handle 100K QPS? Discuss:

  • Data structures and time/space complexity
  • Concurrency/thread safety
  • Distributed deployment (multiple instances) and correctness trade-offs
  • Hot-key mitigation and storage choices

Constraints (assumptions you may make explicit)

  • Timestamps are in milliseconds or seconds (choose one).
  • Keys are strings.
  • Memory is limited; old state should expire.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Microsoft•More Software Engineer•Microsoft Software Engineer•Microsoft Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.