← Questions

Design a VM bandwidth rate limiter

0
DatabricksGoogleAmazon+1System design

A system design interview question asked at Databricks, Google, Amazon and 1 more company. It tests rate limiting, networking and cloud infrastructure.

Design a system that caps the network bandwidth each virtual machine may use in a cloud region, and enforces per-tenant limits that span many VMs on many hosts, without adding latency to packets.

Requirements

  • Functional: a bandwidth limit per VM (ingress and egress); an aggregate limit per tenant across all their VMs; limits that change when a tenant upgrades; burst allowance for short spikes; usage reporting.
  • Non-functional: enforcement on the packet path with no added latency for traffic within limits; a tenant cannot exceed the aggregate limit for more than a short time; scales to every host in the region; keeps enforcing when the control plane is unreachable.

Clarifying questions

  • Are limits in bits per second, packets per second, or both?
  • How strict is the aggregate tenant limit: exact, or within a few percent over seconds?
  • How many VMs can one tenant have, spread over how many hosts?
  • Should traffic over the limit be dropped, queued or marked?
  • Does traffic within the same host or region count?

What a strong answer covers

  • Per-VM enforcement on each host in the virtual switch or network card: a token bucket per VM per direction, with burst size and refill rate.
  • Aggregate tenant limits: a control plane that measures each host's usage for the tenant and redistributes the tenant's budget to hosts every few hundred milliseconds, giving more to busy VMs.
  • The trade-off between accuracy and coordination cost: local enforcement with periodic global rebalancing vs a central counter on the packet path, and why the latter does not work.
  • Behavior during control-plane failure: hosts keep their last allocation.
  • Fairness among VMs of one tenant, and handling new VMs that start mid-period.
  • Monitoring of drops and usage, and billing reports.

Follow-ups

  • A tenant with 10,000 VMs sends all its traffic from 3 of them.
  • Make limits apply per destination, such as internet vs internal traffic.
  • A host's clock drifts or its usage report is lost.
  • Allow a tenant to borrow unused bandwidth from a reserved pool.

Where it's asked

What it tests

rate limiting · networking · cloud infrastructure

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing