Take the 2-minute tour ×

I've been trying to find out just how capable web workers are of distributing processor load. I've yet to find any demos that seem to be able to get my quad core 2600k to even 50%, let alone 100%.

Here's a web worker demo I've tried to max my CPU on:


(If you go into the page's HTML with firebug /chrome-inspect-element and make the canvas larger, you can make it raytrace a much larger image - I set mine to 1920 x 1080)

Even with 4, 8, 16 workers selected, I can't get my CPU utilization above around 25% per core.

Does anyone know if you can utilize 100% of the CPU through web workers?

(I'm using Google Chrome.)

share|improve this question
Other than curiosity why would you want to use up 100% of your browser's cpu? what about the other apps (/browser tabs) that the user has running? do they not deserve some cpu love? –  scunliffe Aug 8 '12 at 19:11
I would never plan to actually steal 100% of the CPU, but I want to know that I have the capability of fully utilizing the available hardware (this is for a game). I probably never will use 100% of every core, but I don't want to be limited to a small amount of each core's power. Apparently, as demonstrated by Esailija, web workers can utilize 100%, so problem solved. –  BumbleShrimp Aug 8 '12 at 19:18
The raytracer completes in 0.4 seconds for me when using 4 workers so maybe it's too quick to show up? The while loops took several seconds before using 100% –  Esailija Aug 8 '12 at 19:20
@Esailija yes, that raytracer's default image size is too small to see your processor peak out, you have to go into the page's HTML and set the canvas width and height to something much much larger in order to get enough processing time to see it max out. –  BumbleShrimp Aug 8 '12 at 19:37
I'm not sure if you guys could clarify this for me, but does creating a web worker automatically use a free cpu core? Or is it just another thread on the same core? –  Ouwen Huang Jul 16 at 18:08

2 Answers 2

up vote 8 down vote accepted

This uses 100% on my 2500K:

var code = "while(true){}";
var BB = window.WebKitBlobBuilder || window.MozBlobBuilder || window.OBlobBuilder || window.BlobBuilder,
    URL = window.webkitURL || window.URL,
    bb = new BB();
code = URL.createObjectURL(bb.getBlob("text/javascript"));
new Worker(code);
new Worker(code);
new Worker(code);
new Worker(code);​


share|improve this answer
Here's "pics or didn't happen": i.imgur.com/gfwg0.png –  Esailija Aug 8 '12 at 19:17
Yep, I updated your code to run 8 workers instead of 4 because I have hyper-threading enabled, and sure enough 100% usage. Thank you for enlightening me –  BumbleShrimp Aug 8 '12 at 19:36
@JonathonG oh actually I have 2500K (no hyper-threading support :() so 4 was enough for me :D –  Esailija Aug 8 '12 at 19:39

I have re-written Esailija's answer using the new blob constructor. BlobBuilder is now outdated, so you must use Blob() instead, see here for the deets: http://updates.html5rocks.com/2012/06/Don-t-Build-Blobs-Construct-Them

window.URL = window.URL || window.webkitURL;

var blob = new Blob(["while(true){}"], {type: 'text/javascript'});

code = window.URL.createObjectURL(blob);

new Worker(code);
new Worker(code);
new Worker(code);
new Worker(code);


share|improve this answer
Thanks for looking into this even after so long. –  BumbleShrimp Jun 11 '13 at 21:41
I just checked your jsfiddle, and this definitely gets the job done! –  BumbleShrimp Jun 11 '13 at 21:48

Your Answer


