service-topology

2 posts

netflix

Building Service Topology at Scale: Architecture, Challenges, and Lessons Learned (opens in new tab)

The post explains how Netflix built a real-time service topology system capable of processing millions of network-flow records per second at production scale. Its core design combines streaming ingestion, reactive backpressure, physically separate data layers, and a distributed aggregation pipeline that resolves network intermediaries into meaningful service dependencies. The system favors slightly delayed but complete updates over stale batch data or incomplete results caused by dropping records. ## The Need for Real-Time Topology - Traditional topology tools rely on hourly or daily batch processing, making their data outdated during incidents. - Netflix combines: - eBPF network flows - IPC metrics delivered through Server-Sent Events - Distributed tracing data - These sources are stored in separate graph or columnar storage layers and can be queried independently or merged. - The goal is near-real-time freshness, faster incident response, blast-radius analysis, and immediate change validation. ## Backpressure for Reliable Streaming - Processing millions of flow records per second creates a risk that downstream systems will become overwhelmed. - Common alternatives are inadequate: - Unbounded queues eventually exhaust memory. - Dropping records produces incomplete topology. - Batch processing introduces unacceptable delays. - Reactive streams propagate slowdown upstream: - A graph database signals Stage 2. - Stage 2 slows Stage 1. - Stage 1 pauses Kafka consumption. - Kafka retains the data until capacity returns. - This allows the system to degrade gracefully during traffic spikes, garbage-collection pauses, or temporary storage slowdowns. - Updates may be delayed by seconds or minutes, but the data remains substantially more complete than a dropped or hourly-processed stream. ## Physically Separate Topology Layers Netflix keeps each data source in storage optimized for its characteristics: - **Network layer:** eBPF flow logs provide broad coverage but limited application context. - **IPC layer:** Application metrics offer detailed endpoint information but cover only instrumented services. - **Tracing layer:** Parquet-based distributed traces show actual request paths but are sampled. - Separate storage enables each layer to evolve and scale independently. - Queries can run in parallel and merge results while preserving sub-second response times. ## Three-Stage Distributed Aggregation The network layer uses a distributed pipeline to transform individual network hops into logical service dependencies. - Cloud traffic commonly passes through load balancers, NAT gateways, API gateways, and proxies. - Flow logs therefore show relationships such as: - `App A → Load Balancer` - `Load Balancer → App B` - The useful topology must infer the logical dependency: `App A → App B`. ### Stage 1: Initial Flow Aggregation - Consumes flow logs from Kafka across four regions. - Filters invalid records. - Groups data into five-minute windows. - Creates initial aggregators for each window. - Uses consistent hashing to distribute aggregators. - Streams the results to Stage 2 through SSE. ### Stage 2: Intermediary Resolution - Receives the initial aggregators from Stage 1. - Groups flows by intermediary components. - Resolves multi-hop network paths into application-level relationships. - This prevents infrastructure components from dominating the resulting service graph. ## Engineering Trade-offs - Streaming provides much fresher data than batch processing but introduces greater operational and conceptual complexity. - Backpressure is essential for stability at Netflix’s scale, even though reactive pipelines are harder to reason about than synchronous systems. - The architecture prioritizes reliable, complete topology updates over perfectly immediate processing. - Production behavior differed substantially from local testing: consumers lagged, memory was exhausted, traffic became unevenly distributed, and garbage collection consumed significant resources. Netflix’s approach demonstrates that large-scale real-time topology requires streaming ingestion, end-to-end backpressure, specialized storage, and staged aggregation. For similar distributed systems, the practical recommendation is to design explicitly for overload and partial slowdown rather than relying on unbounded buffering, dropped data, or stale batch snapshots.

netflix

From Silos to Service Topology: Why Netflix Built a Real-Time Service Map (opens in new tab)

Netflix built Service Topology to give engineers a real-time, unified view of dependencies across its thousands of microservices. Traditional metrics, logs, and traces provide isolated signals but do not reveal the broader service relationships needed to diagnose failures or assess blast radius. The system combines multiple dependency sources into a living map that supports fast, context-rich troubleshooting. ## The Observability Problem - Netflix’s distributed architecture involves thousands of services and complex chains of calls for actions such as playback, authentication, recommendations, and optimization. - During incidents, engineers need to determine: - Which services depend on one another - What the potential blast radius is - Whether a failure originates locally or upstream - Existing observability tools show symptoms, logs, or individual request paths, but not the complete steady-state topology. - Manually combining information from different tools is slow and error-prone, especially during urgent incidents. ## Why Real-Time Service Mapping Matters - Frequent deployments and changing traffic patterns make static architecture diagrams quickly obsolete. - Netflix’s Live programming and advertising-supported plans increase the need for rapid diagnosis and operational awareness. - Engineers repeatedly asked about dependencies, failures, maintenance impact, unknown metrics, and recent call-path changes. - These recurring questions demonstrated the need for accurate, near-real-time dependency information. ## Lessons from Earlier Approaches - Netflix evaluated vendor platforms, graph databases, and internal prototypes before developing Service Topology. - Key lessons included: - Dependency data must update in near real time. - Storage and query systems must operate at Netflix’s scale. - The solution should integrate with existing observability workflows. - Incorrect or incomplete topology data can mislead engineers during incidents. - No single data source captures every aspect of service relationships. ## Requirements for a Living Map Service Topology was designed to provide: - Real-time updates as services deploy and dependencies change - Sub-second queries for traversing service call graphs - Both network-level and application-level views - Context such as health, availability tiers, ownership, and business domains - A visual interface for engineers and programmatic APIs for automation, resilience systems, and blast-radius analysis ## Combining Multiple Sources of Truth Netflix separates dependency information into physically distinct graphs so each layer can evolve and be queried independently. When a unified view is requested, the system traverses the layers in parallel and merges the results to maintain fast response times. ### eBPF Network Flows - eBPF captures network activity at the kernel level, recording which services communicate over the network. - This provides broad coverage, including services that lack application instrumentation. - It supports both cluster-level and application-level topology. - Its limitation is that network traffic alone does not provide application-specific context, such as the APIs or endpoints involved. Netflix’s approach is to combine complementary perspectives rather than rely on a single imperfect dependency source, producing a more complete and actionable service map.