How web browsers use process & Threads

Thiluxan
5 min readJul 16, 2020

--

In the initial times, web browsers supported single process at a time while browsing. In such cases there was no concept of multiple tabs in a browser. There will be only one page in the browser and the user had to roam through that page for the desired web pages. With the development of processes and threads, web browsers took a new dimensions. Before going into the web browsers, let’s take a look at what are processes and threads.

A process can be described as an application’s executing program. A thread is the one that lives inside of process and executes any part of its process’s program. When an application or request is made in a web processor, a process will be started to execute that. Then the process may create threads to make the task easier or not. When the application is closed, the process will be also finished. A process can trigger the operating system to start another process.

Web browsers use the concept of process and thread for their core function. But there is no standard practice or way within browsers regarding them. There may be browsers have one process with many threads or many processes with few threads. The approach will vary within browsers. As stated earlier, initially browsers used single process architecture. When time progresses, for making efficient use, multi-process browsers were made.

Let’s take the Chrome browser and see about the multi-process architecture. On top of all the processes, there will be a main process called browser process. Browser process then will be divided into Render Process, Utility Process, GPU Process, and Plugin Process. Render Process will be divided into more processes and each process will be opened in separate tabs.

Render Process is responsible for displaying multiple web pages requested by the user. Plugin process is responsible for the plugins running in the background, while GPU process is responsible for handling requests from multiple apps and drawing them in the same surface.

The main advantage of multi-process architecture is that, when one process becomes unresponsive, it will not affect other processes. Another advantage of multiple processes is security and sand-boxing. When Chrome is running on a powerful hardware, the multi-process architecture allows it to split the process into many, and it will make efficient use of main memory, without consuming over.

Multi-Process Architecture in Google Chrome

Google Chrome also uses multi-threads inside processes. Each process contain a main thread. Then there will be an IO thread in each process. In render processes, IO thread is responsible for Inter-Process Communication. Also it handles the network requests in browser process. Other than these two main threads, there are few more special threads and a pool of general purpose threads.

Then we move on to the Firefox browser. Initially, it was a single-process browser. It easily freezes the UI, and it might not be optimal from a security point of view, either. Then Firefox started to work on multi-process architecture in a project called Electrolysis and it implemented it through nine versions.

Multi-Process Approach in Firefox

Following that browser UI and web content run in separate processes. In the current iteration of this architecture, all browser tabs run within the same process and the browser UI runs in its own individual process. Now they are focusing on involving more than one process to exclusively handle web content.

Like Chrome, Firefox also using the concepts of multi-threading inside each process. With the release of Firefox 54, Mozilla has completed its transition to a multi-threaded web browser. But the multi-threading concept in Firefox is bit different with that of Chrome. In Chrome it initialize separate process for each tabs. If 5 tabs are opened, then there will be 5 render processes running. It will result it consuming memory, when the no. of processes get increased.

Difference between Multi-Process approach in Chrome and Firefox. Credits : https://medium.com/mozilla-tech/the-search-for-the-goldilocks-browser-and-why-firefox-may-be-just-right-for-you-1f520506aa35

For this problem, Firefox implemented a conservative approach. There will be 4 new processes created for 4 new processes. If an additional tab is opened, it will run using threads within the existing processes. Multiple tabs within a process share the browser engine that already exists in memory, instead of each creating their own. This will reduce the consumption of memory, as more memory needed if no. of processes increased.

Like these two major web browsers, other web browsers also using the concept of multi-processing and multi-threading for increasing efficiency. For example, Microsoft has recently updated their Microsoft Edge browser based on Chromium open-source project.

References:

--

--

Thiluxan
Thiluxan

Written by Thiluxan

Software Engineering undergraduate at University of Kelaniya https://www.kln.ac.lk/

No responses yet