{"id":26417889,"url":"https://github.com/yogain123/workers-pool","last_synced_at":"2025-06-13T15:10:11.358Z","repository":{"id":55069109,"uuid":"210767660","full_name":"yogain123/Workers-Pool","owner":"yogain123","description":"Workers Pooling in NodeJS","archived":false,"fork":false,"pushed_at":"2019-12-10T07:40:31.000Z","size":101,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T20:51:11.956Z","etag":null,"topics":["javascript","nodejs","worker-pool"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yogain123.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-25T06:05:39.000Z","updated_at":"2023-03-26T05:14:47.000Z","dependencies_parsed_at":"2022-08-14T11:00:45.645Z","dependency_job_id":null,"html_url":"https://github.com/yogain123/Workers-Pool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yogain123/Workers-Pool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogain123%2FWorkers-Pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogain123%2FWorkers-Pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogain123%2FWorkers-Pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogain123%2FWorkers-Pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yogain123","download_url":"https://codeload.github.com/yogain123/Workers-Pool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yogain123%2FWorkers-Pool/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259668577,"owners_count":22893131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nodejs","worker-pool"],"created_at":"2025-03-18T01:16:23.169Z","updated_at":"2025-06-13T15:10:11.315Z","avatar_url":"https://github.com/yogain123.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Handling NodeJS C.P.U Intensive Task\n\nNodeJS is frequently referred to as single-threaded. This is true - but there's a catch.\nNode has Single \"Main\" Thread to handle all Client Request.\nWhen a Blocking request comes it actually delegates it task to the worker thread present in thread pool,\nSo we can conclude that NodeJS Is \"not\" totally end to end Single Threaded.\n\n**Note: Worker thread are not the main thread.**\n\nOkay , Thats Fine but If we say this about NodeJS that :\n\nIn Node.js everything runs in parallel, except your code.\nWhat this means is that:\n\u003cb\u003eAll I/O code that you write in Node.js is non-blocking, while (conversely) all non-I/O code that you write in Node.js is blocking. \u003c/b\u003e\nIf the above statement is true (Obviously its true) then What if a very very heavy CPU task comes as a client request ,then What ?\nYou can't do anything but wonder if you could have used another language.\nBut , No We can even delegate this CPU extensive task to worker thread .\n\n**How do we do that ??**\nI will explain this with a proper example here\nAs you can see I have created a function called heavyTask Which runs a for loop for 5000000000000 times , \nThe main thread will be busy for a long time and it will deny to serve any other client request.\nHow do we delegate this CPU task to one of the worker thread present in thread pool.\nworker-pool offers an easy way to create a pool of workers for both dynamically offloading computations \nas well as managing a pool of dedicated workers. It basically implements a thread pool pattern.\nThere is a pool of workers to execute tasks.\nNew tasks are put in a queue.\nA worker executes one task at a time, and once finished, picks a new task from the queue.\n\nIn the above example there is a function heavyTask, \nwhich is offloaded dynamically to a worker to be executed for a given set of arguments.\n\nThis is how you can handle CPU Intensive Task by offloading that work to the worker thread. \u003cbr/\u003e\nhttps://levelup.gitconnected.com/handling-nodejs-c-p-u-extensive-task-aa559452eca8\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyogain123%2Fworkers-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyogain123%2Fworkers-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyogain123%2Fworkers-pool/lists"}