VOOZH about

URL: https://thenewstack.io/wix-multithreaded-node-js-to-cut-kubernetes-pod-costs/

⇱ Wix Multithreaded Node.js to Cut Kubernetes Pod Costs - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2022-10-11 09:00:34
Wix Multithreaded Node.js to Cut Kubernetes Pod Costs
sponsor-netapp,sponsored-topic,
Frontend Development / Kubernetes / Software Development

Wix Multithreaded Node.js to Cut Kubernetes Pod Costs

Oct 11th, 2022 9:00am by Jessica Wachtel
👁 Featued image for: Wix Multithreaded Node.js to Cut Kubernetes Pod Costs

By adding worker threads to its Node.js servers, Wix decreased its Kubernetes pod usage by ~70%, giving the website building service the stats to prove Node.js is indeed suited for CPU-intensive high-throughput work.

Wix runs CPU-intensive JavaScript operations on Node.js’s single thread as part of its Server-Side-Rendering-Execution platform (SSRE). SSRE is a multipurpose code execution platform that renders React.js server side.

But a single thread can only do so much as Guy Treger, Software Developer, explains in his recent blog post. Once traffic reached a total of 1 million RPM, it required a “more than accepted” number of production Kubernetes pods to properly serve it.

And suddenly there was a problem of unmanageability. Too many pods and a high volume of CPU-intensive tasks running on a single thread that was built into the architecture of how Wix ran. The most logical solution? Add more threads to separate the workload.

Since the goal is always more traffic, not less, the company’s engineers needed a new solution that would scale. And it’s a rare case when a company can rebuild the entire architecture and this wasn’t an instance of that. So the best thing to do was to add more threads since it was the single thread that was causing the most pain. The goal of adding more threads was to offload the work to other compute units so multiple threads can run partially on hardware that includes multiple CPU cores.

Spot by NetApp enables cloud operations teams to deliver scalability, performance and security for cloud infrastructure and applications — at the lowest possible cost — through continuous automation and optimization combined with deep visibility and governance. Learn more at spot.io.
Learn More
The latest from NetApp

Node.js’s built-in multiprocessing capabilities were “overkill” for what Wix’s engineering team was looking for. They were looking for a solution that would require fewer resources, maintenance, and orchestration.

worker-threads  👁 Image

Per the Node.js docs:

The worker_threads module enables the use of threads that execute JavaScript in parallel. Workers (threads) are useful for performing CPU-intensive JavaScript operations. They do not help much with I/O-intensive work. The Node.js built-in asynchronous I/O operations are more efficient than Workers can be.

Unlike child_processes or cluster, worker_threads can share memory.

A new feature, becoming Stable in v14 (LTS) released in Oct 2020, Node.js does offer native support but it’s pretty new and lacks in maturity. In order for Wix to fully implement into production-level code, the company’s engineers had to add additional open source packages. They originally searched for one package to tie everything together but found that adding individual packages was best suited for their needs.

Hurdles and Open Source Solutions

Two major hurdles awaited the Wix team when adopting Node.js multithread: task pool capabilities and supporting inter-thread communications.

Task Pool Capabilities

👁 Image

Out-of-the-box: manually spawn worker threads and manually maintain lifecycle.

Hurdle: It’s a large undertaking to constantly make sure there’s enough, re-create worker threads when they die, implement different timeouts, and take on all other responsibilities with manual maintenance

Open Source Solution: generic-pool (npmjs) — The thread-pool results were achieved by adding this popular pooling API.

RPC-like Inter-Thread Communication

👁 Image

Out-of-the-box: Threads can communicate between themselves (eg main threads and their spawned workers) using an async messaging technique.

Hurdle: Dealing with the messaging would make the code harder to head and maintain. The engineers were looking for a package that allowed threads to “call a method” on another thread and receive results asynchronously.

Open Source Solution: comlink (npmjs) Inter-thread communication in the code was made more consider and elegant as a result of adding this package. This package is known for its RPC communication in the browser with long-existing JS web workers. Its compatibility with Node.js workers was recently added.

The code with all packages looks similar to the image below.

👁 Image

Usage in the web-server level looks like image below.

👁 Image

Results and Takeaways

Node.js is indeed suitable for CPU-bound high-throughput services. Overhead infra management was reduced. Their modest goal was overshadowed by substantial gains. SSRE pod count dropped by ~70% with RPM per pod improving by 153%. There was better SLA and a more stable application with response time p50 dropping by ~11% and response time p95 dropping by ~20%. The error rate decreased by 10x. Direct SSRE compute cost went down by about 21%.

It was worth it but not easy. Adding worker_threads to an existing environment isn’t a straightforward add. At times considerable refactoring is needed because logic objects (JavaScript functions) can’t be passed back and forth between threads. Define clear concrete pure-data-based APIs in the code for communication between the workers and adjust accordingly.

Now that there is a working system in place, the Wix team is working on optimization. Areas where optimization is being explored are refactoring applications to make workers to pure CPU work, researching memory sharing to avoid large object cloning between threads, and finding the optimal number of CPU cores per machine to possibly allow for non-constant size thread pools. There is also an exploration of the potential to apply this solution to other major Node.js-based applications in Wix.

Spot by NetApp enables cloud operations teams to deliver scalability, performance and security for cloud infrastructure and applications — at the lowest possible cost — through continuous automation and optimization combined with deep visibility and governance. Learn more at spot.io.
Learn More
The latest from NetApp
TRENDING STORIES
Jessica Wachtel is a developer marketing writer at InfluxData where she creates content that helps make the world of time series data more understandable and accessible. Jessica has a background in software development and technical journalism.
Read more from Jessica Wachtel
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: Pragma.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.