Design a Microservices Security Gateway

Medium45 min
1 / 30
System design answer

Design a Microservices Security Gateway

Medium45 min30 sections
understanding•6 min read

Problem Statement: A Policy Enforcement Point In Front of Every Service

Frames the gateway as a per-workload security data plane, not an edge load balancer with a WAF bolted on.

Problem statement

Design a microservices security gateway: a specialized proxy that sits immediately in front of every microservice instance and independently authenticates the caller, verifies request signatures, validates the request against that service's declared schema, optionally inspects the payload for malicious content, enforces per-service rate and concurrency limits, and emits a security decision record for every rejection. The application behind it should be able to assume that anything reaching its handler has already passed identity, integrity, shape, and quota checks.

How this differs from an edge API gateway

An edge API gateway terminates public traffic, routes by hostname or path, and applies coarse controls once per external call. In a 600-service estate, one external call becomes eight to fifteen internal hops. If only the edge is defended, every internal hop trusts every other hop, and a single compromised low-value service becomes a lateral movement platform. The microservices security gateway moves the enforcement point to the workload boundary, so each hop re-verifies identity and authorization for its own resource. This is the practical expression of Google's BeyondProd model, which argues that trust attaches to a cryptographically identified workload rather than to a network location.

The three properties that make it hard

  1. It is on the critical path of every internal call. At an assumed 1.2M aggregate requests per second, a 1 ms regression costs 1,200 vCPU-seconds of added latency budget per second of wall clock and multiplies through fan-out. Security that doubles p99 gets disabled by service owners.
  2. It must fail closed. The brief is explicit: if the gateway fails, traffic is blocked. That inverts the usual availability instinct. A crashed sidecar must not become an open port, and a policy engine outage must not silently convert to permit-all.
  3. Its configuration is production traffic. A bad rule pushed to 12,000 enforcement points is a self-inflicted, perfectly correlated outage. Cloudflare's own 18 November 2025 postmortem describes a bot-management feature file that grew past a hard limit in the proxy and produced global 5xx errors. The control plane is a availability-critical system, not a config repo.

What the answer must produce

A design with an explicit enforcement pipeline and its ordering, a per-stage latency budget, a policy object model with versioned rollout, a distributed rate-limiting scheme with a defensible accuracy claim, a fail-closed failure matrix, and an audit trail that survives the gateway that produced it.

Key Highlights

  • •Enforcement moves from the network edge to the workload boundary: every internal hop re-authenticates, because one external call fans out to 8-15 internal hops.
  • •Assumed scale: 600 services, 12,000 workload pods, 1.2M req/s aggregate east-west peak, 120K req/s north-south.
  • •Fail-closed is a requirement, not a preference: a dead enforcement proxy must not expose the application port.
  • •Policy distribution is a correlated-failure risk; Cloudflare's 18 November 2025 outage began as a configuration file exceeding a proxy limit.
  • •Budget the synchronous path at p50 0.8 ms and p99 5 ms or service owners will route around the gateway.
Lead With the Trust Boundary
Say in the first minute that the application listener is unreachable except through the enforcement proxy, and that every internal hop re-verifies identity. That single sentence separates this answer from a load-balancer answer.
Do Not Design One Big Gateway
A centralized security tier for 600 services becomes a shared fate domain and a latency tax on every hop. Distribute enforcement, centralize authoring.

Section Rescue Kit

Buzzwords to use:

Policy Enforcement PointFail-Closed

Safe statements:

  • "Let me first define what the application is allowed to assume about a request that reaches it."
  • "I will separate the enforcement data plane from the policy control plane before choosing any product."
Design a Microservices Security Gateway - System Design | WinJob | WinJob