All practice tasks

Low Level Design

Low-Level Design: Api Design

Apply independent quotas to incoming actions during fixed time windows.

Interface

Export create_rate_limiter(limit, window_ms, now=None). It returns allow(key), which returns a dictionary such as {"allowed": true}. A limit of 1 in a 1,000 ms window accepts key a at both 1,999 and 2,000 ms.

Implement the contract in the supplied source file using Python 3. Discuss framework integration in design.md.

Behavior

  • [R1] Reject limit and window_ms unless they are positive integers up to 2**53 - 1. Boolean values are invalid. Raise ValueError.
  • [R2] Use fixed half-open windows aligned to time zero. The boundary starts a new window.
  • [R3] Count accepted calls independently per key. Return {"allowed": true} until its limit and {"allowed": false} for additional calls in that window.
  • [R4] Call now for each request. It returns nonnegative, nondecreasing integer milliseconds. Default to the current time in milliseconds when omitted. Keys are nonempty strings. Instances have independent state.

Design and verification

  • Place the component in Django services, views and repository boundaries and explain the adapter/core boundary.
  • Describe who supplies the key and the clock a

What this task practices

Low-Level Design: Api Design is a low level design interview exercise that trains prompt interpretation, explicit assumptions, a concrete response, and a clear explanation of tradeoffs. The catalog marks it as hard difficulty. It focuses on Testing, Tradeoffs, Validation. The signed-in workspace provides the tools for the round and evaluates the attempt against task-specific criteria. Reference solutions, hidden checks, evaluator instructions, and candidate work remain private.

Sign in to startThe workspace and evaluation open after sign in.