Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web Worker overhead metrics

I'm working on a project that may require multiple web workers and I need to know whether it's affordable to have multiple operating at the same time (as in more than 4 or 8 workers) and what the cost is in both cpu and ram to start them up and have them lingering.

I've been googling and searching but I haven't found any metrics on their cpu and memory overhead. I've found some benchmarks for performance, but that's not what I'm interested in.

Can anyone point me to either a spec or study that gives at least approximate values? I need to at least have some ballpark values to work with, rather than just assume whatever I see from Process Explorer is accurate or reliable.

edit - It seems people are getting the wrong impression. I'm not asking for advice on how to solve a problem but sources of technical information on web worker overhead, if they exist.

like image 924
mechalynx Avatar asked Jun 02 '15 03:06

mechalynx


People also ask

How many web workers can run concurrently?

How many web workers can run concurrently JavaScript? A web worker is a JavaScript program running on a different thread, in parallel with main thread. The browser creates one thread per tab. The main thread can spawn an unlimited number of web workers, until the user's system resources are fully consumed.

Should I use Webworkers?

Web Workers help in making use of multi-core processors efficiently, otherwise, JavaScript Application ends up running on the single main thread. If you put this code into the browser console in Developer Tools, you will see that the page becomes unresponsive which is due to the code blocking the main thread.

Are web workers multithreaded?

Developers have been solving this problem in desktop applications for a long time with multithreading. Web Workers bring multithreading to JavaScript web applications. Different parts of code can run simultaneously without blocking each other and communicate using message passing techniques.

What is the difference between service worker and web worker?

What is a Service Worker? Unlike Web Workers, Service Workers have a dedicated role of being a proxy between the network and the browser and/or cache. Similar to Web Workers, they are registered in the primary JavaScript file as a dedicated worker.


1 Answers

The Workers API spawns real OS threads, so a lot of that performance bottleneck might not even be at the browser level.

Understandably, you still want metrics to see how much overhead a browser adds. You're either on your own if you want objective results.

Some blog posts might give you a good starting point: https://hacks.mozilla.org/2015/07/how-fast-are-web-workers/

(EDIT: actually keep reading the link, and you'll find he has open-sourced the metric tooling used for the blog post: https://github.com/gmarty/web-workers-benchmark)

like image 182
Toby Liu Avatar answered Sep 17 '22 16:09

Toby Liu