Migrating Essential Site visitors At Scale with No Downtime — Half 1 | by Netflix Know-how Weblog | Could, 2023

Shyam Gala, Javier Fernandez-Ivern, Anup Rokkam Pratap, Devang Shah

Lots of of thousands and thousands of consumers tune into Netflix every single day, anticipating an uninterrupted and immersive streaming expertise. Behind the scenes, a myriad of techniques and companies are concerned in orchestrating the product expertise. These backend techniques are constantly being developed and optimized to fulfill and exceed buyer and product expectations.

When endeavor system migrations, one of many primary challenges is establishing confidence and seamlessly transitioning the site visitors to the upgraded structure with out adversely impacting the client expertise. This weblog sequence will study the instruments, methods, and methods we’ve got utilized to realize this objective.

The backend for the streaming product makes use of a extremely distributed microservices structure; therefore these migrations additionally occur at totally different factors of the service name graph. It may well occur on an edge API system servicing buyer units, between the sting and mid-tier companies, or from mid-tiers to information shops. One other related issue is that the migration may very well be taking place on APIs which can be stateless and idempotent, or it may very well be taking place on stateful APIs.

We’ve got categorized the instruments and methods we’ve got used to facilitate these migrations in two high-level phases. The primary part includes validating purposeful correctness, scalability, and efficiency issues and making certain the brand new techniques’ resilience earlier than the migration. The second part includes migrating the site visitors over to the brand new techniques in a way that mitigates the chance of incidents whereas regularly monitoring and confirming that we’re assembly essential metrics tracked at a number of ranges. These embrace High quality-of-Expertise(QoE) measurements on the buyer system degree, Service-Degree-Agreements (SLAs), and business-level Key-Efficiency-Indicators(KPIs).

This weblog submit will present an in depth evaluation of replay site visitors testing, a flexible method we’ve got utilized within the preliminary validation part for a number of migration initiatives. In a follow-up weblog submit, we’ll deal with the second part and look deeper at a number of the tactical steps that we use emigrate the site visitors over in a managed method.

Replay site visitors refers to manufacturing site visitors that’s cloned and forked over to a unique path within the service name graph, permitting us to train new/up to date techniques in a way that simulates precise manufacturing situations. On this testing technique, we execute a replica (replay) of manufacturing site visitors in opposition to a system’s present and new variations to carry out related validations. This method has a handful of advantages.

  • Replay site visitors testing allows sandboxed testing at scale with out considerably impacting manufacturing site visitors or buyer expertise.
  • Using cloned actual site visitors, we are able to train the range of inputs from a wide selection of units and system utility software program variations in manufacturing. That is significantly vital for advanced APIs which have many excessive cardinality inputs. Replay site visitors gives the attain and protection required to check the flexibility of the system to deal with occasionally used enter mixtures and edge instances.
  • This method facilitates validation on a number of fronts. It permits us to say purposeful correctness and gives a mechanism to load check the system and tune the system and scaling parameters for optimum functioning.
  • By simulating an actual manufacturing atmosphere, we are able to characterize system efficiency over an prolonged interval whereas contemplating the anticipated and surprising site visitors sample shifts. It gives a superb learn on the supply and latency ranges underneath totally different manufacturing situations.
  • Gives a platform to make sure that related operational insights, metrics, logging, and alerting are in place earlier than migration.

Replay Answer

The replay site visitors testing answer contains two important parts.

  1. Site visitors Duplication and Correlation: The preliminary step requires the implementation of a mechanism to clone and fork manufacturing site visitors to the newly established pathway, together with a course of to file and correlate responses from the unique and various routes.
  2. Comparative Evaluation and Reporting: Following site visitors duplication and correlation, we’d like a framework to match and analyze the responses recorded from the 2 paths and get a complete report for the evaluation.
Replay Testing Framework

We’ve got tried totally different approaches for the site visitors duplication and recording step via varied migrations, making enhancements alongside the best way. These embrace choices the place replay site visitors technology is orchestrated on the system, on the server, and through a devoted service. We are going to study these alternate options within the upcoming sections.

System Pushed

On this possibility, the system makes a request on the manufacturing path and the replay path, then discards the response on the replay path. These requests are executed in parallel to attenuate any potential delay on the manufacturing path. The collection of the replay path on the backend will be pushed by the URL the system makes use of when making the request or by using particular request parameters in routing logic on the applicable layer of the service name graph. The system additionally features a distinctive identifier with similar values on each paths, which is used to correlate the manufacturing and replay responses. The responses will be recorded on the most optimum location within the service name graph or by the system itself, relying on the actual migration.

System Pushed Replay

The device-driven method’s apparent draw back is that we’re losing system sources. There may be additionally a danger of influence on system QoE, particularly on low-resource units. Including forking logic and complexity to the system code can create dependencies on system utility launch cycles that typically run at a slower cadence than service launch cycles, resulting in bottlenecks within the migration. Furthermore, permitting the system to execute untested server-side code paths can inadvertently expose an assault floor space for potential misuse.

Server Pushed

To handle the issues of the device-driven method, the opposite possibility we’ve got used is to deal with the replay issues solely on the backend. The replay site visitors is cloned and forked within the applicable service upstream of the migrated service. The upstream service calls the present and new alternative companies concurrently to attenuate any latency enhance on the manufacturing path. The upstream service data the responses on the 2 paths together with an identifier with a typical worth that’s used to correlate the responses. This recording operation can be completed asynchronously to attenuate any influence on the latency on the manufacturing path.

Server Pushed Replay

The server-driven method’s profit is that the whole complexity of replay logic is encapsulated on the backend, and there’s no wastage of system sources. Additionally, since this logic resides on the server aspect, we are able to iterate on any required adjustments sooner. Nonetheless, we’re nonetheless inserting the replay-related logic alongside the manufacturing code that’s dealing with enterprise logic, which can lead to pointless coupling and complexity. There may be additionally an elevated danger that bugs within the replay logic have the potential to influence manufacturing code and metrics.

Devoted Service

The most recent method that we’ve got used is to fully isolate all parts of replay site visitors right into a separate devoted service. On this method, we file the requests and responses for the service that must be up to date or changed to an offline occasion stream asynchronously. Very often, this logging of requests and responses is already taking place for operational insights. Subsequently, we use Mantis, a distributed stream processor, to seize these requests and responses and replay the requests in opposition to the brand new service or cluster whereas making any required changes to the requests. After replaying the requests, this devoted service additionally data the responses from the manufacturing and replay paths for offline evaluation.

Devoted Replay Service

This method centralizes the replay logic in an remoted, devoted code base. Other than not consuming system sources and never impacting system QoE, this method additionally reduces any coupling between manufacturing enterprise logic and replay site visitors logic on the backend. It additionally decouples any updates on the replay framework away from the system and repair launch cycles.

Analyzing Replay Site visitors

As soon as we’ve got run replay site visitors and recorded a statistically vital quantity of responses, we’re prepared for the comparative evaluation and reporting element of replay site visitors testing. Given the size of the information being generated utilizing replay site visitors, we file the responses from the 2 sides to a cheap chilly storage facility utilizing know-how like Apache Iceberg. We are able to then create offline distributed batch processing jobs to correlate & examine the responses throughout the manufacturing and replay paths and generate detailed experiences on the evaluation.


Relying on the character of the system being migrated, the responses would possibly want some preprocessing earlier than being in contrast. For instance, if some fields within the responses are timestamps, these will differ. Equally, if there are unsorted lists within the responses, it is likely to be greatest to kind them earlier than evaluating. In sure migration situations, there could also be intentional alterations to the response generated by the up to date service or element. For example, a subject that was an inventory within the unique path is represented as key-value pairs within the new path. In such instances, we are able to apply particular transformations to the response on the replay path to simulate the anticipated adjustments. Based mostly on the system and the related responses, there is likely to be different particular normalizations that we’d apply to the response earlier than we examine the responses.


After normalizing, we diff the responses on the 2 sides and verify whether or not we’ve got matching or mismatching responses. The batch job creates a high-level abstract that captures some key comparability metrics. These embrace the overall variety of responses on either side, the rely of responses joined by the correlation identifier, matches and mismatches. The abstract additionally data the variety of passing/ failing responses on every path. This abstract gives a superb high-level view of the evaluation and the general match charge throughout the manufacturing and replay paths. Moreover, for mismatches, we file the normalized and unnormalized responses from either side to a different massive information desk together with different related parameters, such because the diff. We use this extra logging to debug and establish the basis reason for points driving the mismatches. As soon as we uncover and handle these points, we are able to use the replay testing course of iteratively to deliver down the mismatch proportion to an appropriate quantity.


When evaluating responses, a typical supply of noise arises from the utilization of non-deterministic or non-idempotent dependency information for producing responses on the manufacturing and replay pathways. For example, envision a response payload that delivers media streams for a playback session. The service accountable for producing this payload consults a metadata service that gives all out there streams for the given title. Numerous components can result in the addition or removing of streams, equivalent to figuring out points with a selected stream, incorporating assist for a brand new language, or introducing a brand new encode. Consequently, there’s a potential for discrepancies within the units of streams used to find out payloads on the manufacturing and replay paths, leading to divergent responses.

A complete abstract of information variations or checksums for all dependencies concerned in producing a response, known as a lineage, is compiled to deal with this problem. Discrepancies will be recognized and discarded by evaluating the lineage of each manufacturing and replay responses within the automated jobs analyzing the responses. This method mitigates the influence of noise and ensures correct and dependable comparisons between manufacturing and replay responses.

Evaluating Stay Site visitors

Another technique to recording responses and performing the comparability offline is to carry out a stay comparability. On this method, we do the forking of the replay site visitors on the upstream service as described within the `Server Pushed` part. The service that forks and clones the replay site visitors straight compares the responses on the manufacturing and replay path and data related metrics. This selection is possible if the response payload isn’t very advanced, such that the comparability doesn’t considerably enhance latencies or if the companies being migrated will not be on the vital path. Logging is selective to instances the place the previous and new responses don’t match.

Replay Site visitors Evaluation

Load Testing

Apart from purposeful testing, replay site visitors permits us to emphasize check the up to date system parts. We are able to regulate the load on the replay path by controlling the quantity of site visitors being replayed and the brand new service’s horizontal and vertical scale components. This method permits us to judge the efficiency of the brand new companies underneath totally different site visitors situations. We are able to see how the supply, latency, and different system efficiency metrics, equivalent to CPU consumption, reminiscence consumption, rubbish assortment charge, and so on, change because the load issue adjustments. Load testing the system utilizing this system permits us to establish efficiency hotspots utilizing precise manufacturing site visitors profiles. It helps expose reminiscence leaks, deadlocks, caching points, and different system points. It allows the tuning of thread swimming pools, connection swimming pools, connection timeouts, and different configuration parameters. Additional, it helps within the dedication of affordable scaling insurance policies and estimates for the related price and the broader price/danger tradeoff.

Stateful Techniques

We’ve got also used replay testing to construct confidence in migrations involving stateless and idempotent techniques. Replay testing may also validate migrations involving stateful techniques, though further measures should be taken. The manufacturing and replay paths should have distinct and remoted information shops which can be in similar states earlier than enabling the replay of site visitors. Moreover, all totally different request varieties that drive the state machine should be replayed. Within the recording step, other than the responses, we additionally wish to seize the state related to that particular response. Correspondingly within the evaluation part, we wish to examine each the response and the associated state within the state machine. Given the general complexity of utilizing replay testing with stateful techniques, we’ve got employed different methods in such situations. We are going to take a look at one among them within the follow-up weblog submit on this sequence.

We’ve got adopted replay site visitors testing at Netflix for quite a few migration tasks. A latest instance concerned leveraging replay testing to validate an in depth re-architecture of the sting APIs that drive the playback element of our product. One other occasion included migrating a mid-tier service from REST to gRPC. In each instances, replay testing facilitated complete purposeful testing, load testing, and system tuning at scale utilizing actual manufacturing site visitors. This method enabled us to establish elusive points and quickly construct confidence in these substantial redesigns.

Upon concluding replay testing, we’re prepared to start out introducing these adjustments in manufacturing. In an upcoming weblog submit, we’ll take a look at a number of the methods we use to roll out vital adjustments to the system to manufacturing in a gradual risk-controlled approach whereas constructing confidence through metrics at totally different ranges.