Docker (and Kubernetes) vs node.js threads/clusters (puppeteer)

1/28/2022

I'm building a web app where I'm using puppeteer to emulate website navigation. Each process takes about 10 minutes to complete, checking all the spots on the websites (logging in/out, clicking links, waiting for the response, responding, further navigation and so on). It's a reasonably heavy-CPU app, due to chromium and puppeteer. And due to the nature of the navigation, each navigation process needs to open a separate headless browser (not use more tabs).

I finished the script for the single-threaded app. But this app needs to take care of multiple orders at the same time. I've been trying to split the app into multiple threads using Worker Threads and Clusters in Node.js. But I've been thinking about splitting threads into docker containers and use Kubernetes to spawn and manage them.

Due to the fact that node.js is single-threaded and there's no real concurrency mode (at least not in comparison to C/C++, Rust, Go, etc.), isn't the better option to use separate docker containers to "imitate" threads and run the script with a custom load balancer?

-- Mateusz KÅ‚usek
docker
kubernetes
multithreading
node.js
puppeteer

0 Answers