Chrome Multi-Processor Architecture
Tags: computerscience, architecture, chrome, multiprocess
Published: 2020-04-16 08:21:59


##### In this article, I would like to share my experience, which I came across accidentally while killing a task, I found below the list of Google chrome tasks, though I have opened like 4–5 tabs.

![Chrome browser](https://dev-to-uploads.s3.amazonaws.com/i/p72wmmqetv4caaxurzzy.png)

So, I have tried to find out what is happening with this chrome processes. I started with our favorite Google Search and within minutes I came to know that reason is fairly simple.

It is because of Chromium Multi-process architecture and its __S__-speed, __S__-secure and, __S__-safe principles.

So, let’s start our quest of questions about what leads to this design and why is this even required.

## __Different types of Processes in chrome__

1. __One Browser process__ — _This process is created when we start the Browser._
2. __One GPU process.__
3. __One Process per Utility.__
  * 👉__Network service Utility__ — _responsible for chrome detecting casting devices._
  * 👉__V8 proxy Resolver__ — _Not sure about this. something to do with PAC file._
  * 👉__Audio Service Utility__ — _helps to play audio 🎵 on the browser. for more info check this out → chrome://media-internals/_
  * 👉__Windows Utilities__ — _this process will be created when the user open file explorer while saving or uploading files_
4. __One process per Tab__ — _Every site you visit creates a new process. (more than 20 tabs leads to a different behavior)_
5. __One Process per sub-frame__ — _subframe is a frame or iframe element inside a web page._
  * 👉 _Frames share a process with their page if the frame and the page are from the same site (based on the URL)._
  * 👉_Frames from cross sites create a new process._
6. __One process per extension__ — _Which you installed on chrome._

***
> 🔭 Shortcut to check chrome task manager 
> _(shift + esc) or Menu -> More tools -> Task manager_

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/t43891hl1gi9t2x0d7rs.png)

> You can disable this multi-processes behavior using launch parameter --single-process. [🔗](https://www.chromium.org/developers/design-documents/process-models)

> 📢 This is just to simulate single process behavior, but don’t make it as default. As your site behaves really strange once user uses it in real environment.

```bash
c:\path-to-chrome\chrome.exe  --disable-plugins --single-process
```
***
> __🔥 Firefox Facts__ 
> + _Firefox worked on an internal project called Electrolysis to implement Multi-Process Architecture. To know more please read [Electrolysis or e10s](https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Multiprocess_Firefox)._
> + _FireFox released new versions with multi-process architecture but it is not the same as chrome._
> + _Firefox nightly builds ships with [fission](https://wiki.mozilla.org/Project_Fission) which enables site isolation._ 
>
> __🌐 IE Facts__
> + _IE's multi-process architecture was introduced with IE8. It makes use of two types of processes_
      1. _One main process_
      2. _Zero or More Tab processes(based on configuration)_

***

### Till now we understood about __what / when__ processes are created. Now we will ask our-self a quite interesting question.

> __But Why we need a multi-process Architecture ?__
> _🤔 Take time to think before you go through the explanation. 🤔_


## __Benefits of Multi-process Architecture in a nutshell__

![Extracted from google](https://dev-to-uploads.s3.amazonaws.com/i/3nluwftz80n8u4dl56z0.png "Multi-threaded vs Multi-processes (Extracted from google)")

1. __Sand-boxing__ — _Important aspect of security mechanism, which in simple terms says your code will run in its own process. So your creativity doesn’t bother other's creativity. want to know more?_ ( 👉 [🔗](https://chromium.googlesource.com/chromium/src/+/master/docs/design/sandbox.md))
2. __Black Sheep Detection__ 😝 — _If one of the pages is unresponsive, then the browser can easily delete that particular process and saves the life of User. (Definitely, you might have faced one, while processing Bank transaction and suddenly browser crashes..)_
3. __Optimal memory footprint__ — _Helps in setting priory on tabs which are not active._
4. __Private Data__ — _Web pages will have their own memory. By now, you must understand why stored objects in local-storage on one tab doesn’t available in another tab._
5. __Site Isolation__ — _When Site Isolation is enabled, each renderer process contains documents from at most one site. This means all navigation's to cross-site documents cause a tab to switch processes._ (👉 [🔗](https://security.googleblog.com/2018/07/mitigating-spectre-with-site-isolation.html))

![Extracted from google](https://dev-to-uploads.s3.amazonaws.com/i/fgc1y00g8gj6g1murgwq.png "Extracted from google")

***
Its Time for Next Important question …

## __How does this mechanism work?__
Prior knowledge of Browsers is an added benefit to understanding this mechanism.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/nvj07mj2hwn89vukf0tx.jpeg "updated with new features(Not included IE)")

I will try to summarize this mechanism in my perspective. 😅

Let’s assume, below steps were performed by you to watch a YouTube video and Twitter page on an exciting day.

1. __You have opened a chrome browser.__
  * 👉 _A browser process will be created and two threads namely main/UI and IO threads are created._
  * 👉 _Browser process will check for all extensions and create one process per extension._
2. __Type youtube.com in your URL bar.__
  * 👉 _The browser will check whether it is a search query or URL. If it is URL, it will be passed to IO thread (Network handling happens here)_.
  * 👉_Then ResourceDispatcherHost(This object will be there in IO thread) checks for valid network response and pass it to main/UI thread._
  * 👉 _Then UI thread request to create new Render process and maps that process with RenderViewHost(This object will be there in Main/UI Thread of browser process), which creates 2 new threads in corresponding render process namely Main Thread and Render thread*._
  * 👉 _Main thread uses for inter-process communication._
  * 👉 _Render Thread consists of all Blink and v8 implementations(this is the place where all exciting stuff happens)._
3. __Type twitter.com on a new tab.__
👉 _sub-steps in step-2 will be repeated._
👉 _a new instance of RenderViewHost will be created to handle this tab within the same browser process._

_If you want to explore more about it, then I strongly suggest you to visit Chromium’s official docs [🔗](https://www.chromium.org/developers/design-documents/multi-process-architecture) or this medium post [🔗](https://medium.com/@zicodeng/explore-the-magic-behind-google-chrome-c3563dbd2739)._

***

### __I hope now we can answer the below questions.__

1. What are the different types of Processes? ✔️
2. When they are created?✔️
3. Why is it required?✔️
4. How this Mechanism Works. ✔️

***

## __Learned something? help others find this article.__

## References
- [Google Developer page](https://www.chromium.org/developers/design-documents/multi-process-architecture)
- [Chrome official paper](https://cisctbd.github.io/Report.pdf)