The optimal number of web workers

Suppose you have a task on your webapp that requires maximum performance. The task is very parallelizable: you can divide it into, say, 500 independent sub-tasks. What is the best solution?

  • (A) Just create 500 web workers.
  • (B) Create a small number of t web workers and make them consume 500 tasks.

If (B) is the way, how can you determine (if possible, empirically) the best value for t ? Is there any library to solve this particular problem?

+4
source share
1 answer

Use navigator.hardwareConcurrency for the optimal number of web workers.

Browser Support - http://caniuse.com/#search=hardwareConcurrency

Polyfill for unsupported browser versions - https://oswg.oftn.org/projects/core-estimator/demo/

+3
source

All Articles