Brifing

ZGateway: Meta's Proxy Layer for Managing ZippyDB Traffic

The architecture and benefits of the proxy layer handling billions of operations

Engineering at Meta3 min

1Origins of ZGateway

ZGateway was developed to manage millions of clients in front of ZippyDB, Meta's most widely used key-value store. The proxy layer solves the challenge of making quick changes across client fleets owned by hundreds of different teams. It centralizes operations like connection pooling, routing, and admission control from a single control point.

2Scalability Challenge

In ZippyDB, each client directly connected to required database servers. A single client could access tens of thousands of distinct shards spread across hundreds of thousands of servers. The resulting dense connection mesh caused both resource waste and system fragility, becoming a reliability limit at scale.

3Connection Storm Risk

In the direct-access model, sudden connection refresh waves in client fleets could impact the entire system. For example, a routing bug causing every client to connect to every shard could exhaust server file descriptor limits, triggering reboot loops. ZGateway contains such events at the proxy layer.

4Architectural Advantages

ZGateway operates as a stateless proxy between clients and database layers. It centralizes TLS termination, ACL validation, and tenant-specific admission control. Deployed in regional tiers discovered via ServiceRouter, it ensures clients connect to their nearest gateway.

5Performance Gains

ZGateway currently handles 40% of ZippyDB traffic, expected to exceed 60%. While adding just 6% computational overhead in average cases, it significantly improves overall system reliability. The proxy can process over 1 billion operations per second.

6Connection Management

The proxy layer reduces the dense connection mesh between clients and database servers to two bounded hops. Instead of tens of thousands of connections per endpoint, manageable numbers are maintained. Connection pooling and failover logic now resides in a single centralized layer rather than millions of clients.

7Request Batching

ZGateway groups and coalesces requests targeting the same shard, sending fewer but larger requests to database servers. This batching optimizes network traffic and CPU usage, particularly benefiting write-heavy operations with significant performance improvements.

8Scale Economics

The proxy layer solves shared workloads in one place, enabling substantial resource savings. For example, TLS handshake counts are dramatically reduced. Database server resource consumption doesn't increase as client fleets grow, since new clients share existing proxy connections.

9Observability

ZGateway enables monitoring the entire workload from a single point. Real-time tracking shows which clients generate how much load. Behavior changes can be implemented at the proxy layer within minutes, eliminating the need for slow client fleet rollouts.

10Future Extensions

ZGateway currently operates in two modes: pure proxy and read-through cache. The architecture was designed for easy addition of new features like advanced shaping algorithms, intelligent routing rules, and novel caching strategies.

11Industry Example

Meta's solution demonstrates the importance of proxy layers in large-scale distributed systems. It provides a reference architecture for companies facing similar challenges, particularly in scenarios with large, diverse, and uncontrollable client populations.

12System Reliability

ZGateway's most significant contribution has been improving ZippyDB infrastructure reliability. The proxy layer has dramatically reduced risks of connection storms, resource exhaustion, and cascading failures, making this critical component powering Meta's global products more resilient.

Original article: Engineering at Meta — Meta'nın ZippyDB Trafiğini Yönetmek İçin Geliştirdiği ZGateway