Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Priority-Aware Database Request Gateway

Protect a capacity-limited database while giving higher-priority calls faster service without starving ordinary traffic.

Problem statement

Design a service that handles calls of different priority when offered load exceeds database capacity. For this exercise, assume three priority classes, per-tenant quotas, reads and idempotent writes, and a database whose safe concurrency and throughput limits are measured continuously.

Higher priority should receive lower queueing delay, but admitted normal work must make bounded progress. The gateway must return explicit admitted, queued, rejected, timed-out, and uncertain-write outcomes.

Cover admission, scheduling, backpressure, database concurrency control, fairness, retries, overload signaling, observability, and recovery. Changing the database engine or business query semantics is outside scope.

What to build

  1. Authenticate, classify, and admit work according to priority, tenant quota, deadline, and measured database capacity.
  2. Serve higher-priority work sooner while guaranteeing bounded progress for already admitted normal work.
  3. Enforce global and query-class concurrency budgets so overload does not collapse the database.
  4. Expose queue, rejection, timeout, retry, and uncertain-write outcomes with traceable reasons.

At scale

  • For this exercise, assume 100,000 incoming calls per second against a database safe at 20,000 operations per second and 2,000 concurrent queries.
  • For this exercise, urgent work targets 200 milliseconds p95 queue time, normal work two seconds p95, and bulk work may wait longer but must not starve.
  • For this exercise, queued work has caller deadlines and a bounded durable or reconstructable admission record; an expired request never reaches the database later.
  • For this exercise, one tenant may burst to 40 percent of offered load and a single expensive query class may consume ten times ordinary capacity.