How web browsers use process & Threads

Chandima Maduwanthi
4 min readJul 17, 2020

In this article, let’s see how web browsers use processes and threads referring two modern browsers; Google Chrome & Firefox.

First of all, let’s take a look at what are processes and threads.

A process, in the simplest terms, is an executing program. One or more threads run in the context of the process. A thread is the basic unit to which the operating system allocates processor time. A thread can execute any part of the process code, including parts currently being executed by another thread.

When you start an application, a process is created. The program might create thread(s) to help it do work, but that’s optional. When you close the application, the process also goes away and the Operating System frees up the memory.

Now, let’s see how these processes and threads are used by web browsers.

Before modern browsers exist, we used the single-process browser. IE6 was the most popular one. There were no tabs in IE6. Each web page was allocated with a window because of the single-process limitation. In a single-process browser, the process needs to take care of everything, including page rendering, JavaScript execution, and more.

This architecture had few problems. As a solution, developers made multi-process browsers, also known as modern browsers such as Chrome and Firefox.

Google Chrome and Firefox now both support multi-threading, but they do it in different ways. Let’s see how those two browsers work.

Google Chrome

Multi-process architecture means that even if one process gets sick, the other two are immune.

The multi-process architecture of Google Chrome differentiates it from other browsers. Each tab has its own process, which runs independently from the browser. This allows one tab process to dedicate itself to a single web-application, thereby increasing browser performance.

There is one main process handling user interaction, the browser, operating system calls and persistent data; that being the “browser” process. This browser process contains several threads , each with different responsibilities, but the only one we need to focus on at this level is the I/O thread. The I/O thread maintains links to all spawned processes and handles all communications with other modules.

The threading model used by Chrome

Almost every time a new tab is opened in the browser, a new “Renderer” process is created.This renderer process is what is sandboxed for security, and it contains its own rendering engine, JavaScript interpreter, XML parser and some components from the display backend.

Firefox

Mozilla introduced the multi-process architecture in the Firefox web browser in 2016. Firefox would use multiple processes to divide loaded sites between them and use different processes for the browser’s own functionality.

While that increased memory usage, it also meant that Firefox would become more stable in the process and less prone to site crashes taking the entire browser with them. Mozilla’s implementation was different to Google’s. Chrome uses one process per site, Firefox puts multiples sites in a single process.

Firefox’s Multi-process architecture received numerous improvements over the years. Mozilla added more processes to it and introduced a sandbox security feature later on that depended on it.

The new Firefox 54 is capable of using multiple threads simultaneously. Going forward, Mozilla is launching a new initiative, dubbed Project Quantum, to focus on optimizing the browser engine that runs within a content process.

--

--

Chandima Maduwanthi

BSc.(Hons) Software Engineering Undergraduate | University Of Kelaniya