The Netflix client architecture was designed to mimic the flexibility of Web browsers in allowing updates to various devices. The company started with a special browser that wrapped WebKit around the core code supporting the UI. This made it easier for Netflix engineers to update the UI like any application on the Web.
This approach helped Netflix to create a UI, but it did not work well on older devices. Creating applications that were consistent across devices was hard because operations like DOM manipulation had to traverse a giant tree to insert UI elements. So Netflix had to decide whether they needed the entire DOM and all of the baggage that came with it, Purewal said.
The way they worked around this was to build a custom rendering engine. This architecture works sort of like Node.js, but on the client rather than the server, Purewal said. This approach allows the main rendering application to access system resources for the Netflix platform across the various devices from high performance gaming platforms to basic TVs.
It needed to handle system related functions like video decoding and playback, networking, logging, security, content control and caching. This approach allows Netflix to innovate on all of the other features and services rendered across this common platform. For example, they have tried out new ways to make movies start faster, secure information, adaptively stream and log.
"Our code was leaner, more organized and more testable."
Semmy Purewal, Senior software engineer, Netflix
The perils of too much connection
This is the same problem that can occur with object-oriented programs with a giant class hierarchy. Developers have to include a giant code base to get to one class. These are all anti-patterns relating to wide scope, Purewal observed. The real problem was that developers did not have access to the same language features that existed in C++. All of the other modern programming languages have an idea of maintaining independence.
Modular programming is a superset of class based object oriented programming. It is possible to make a module export a specific class. Modular programming is also a subset of procedural programming. Procedures should be collected in terms of modules. The benefit of using this style of programming is that developers can do development independently of systems. They are small, concrete and can be put into package managers.
This approach supports two of the good ideas of OO programming around programming by contract and programming to an interface, Purewal said. This makes it easier for a developer to change one module without affecting others and allows the use of package managers like npm.
After this transition, Netflix moved from three week cycles, to daily deployment. “It was kind of a game changer for us,” Purewal said. “Our code was leaner, more organized and more testable.”
Could Netflix be a pioneer for new model, highly available cloud apps?
Learn more about Netflix and Security Monkey