0

I currently have a 4-core windows server. On this server, I installed a nodejs Server (API rest).

It works perfectly without latency. However when I start a windows update for the server, nodejs becomes very slow. Even for an HTTP request returning a JSON {test}, it takes about 30s to respond.

As if the windows update process was taking up all the CPU load. (Nodejs is not multi threaded) I don't know if I should do something on the windows server or in the Node JS code.

Windows update takes about 40% and nodejs 1% of CPU. When the update is complete, everything returns to normal. What to do ? Thanks for your help.

Thomas

Oytoch
  • 1
  • 2
  • This sounds like the Windows update is plugging up access to some system resources needed by nodejs (perhaps networking or file access) that affects things more than just the CPU percentage. I doubt there is anything you can do on the nodejs side of things other than performance optimize it on its own (independent of the update). – jfriend00 Dec 14 '19 at 18:59
  • Thank you for your reply. As you say, it may be the network. If I find a solution, I will return it to you. – Oytoch Dec 14 '19 at 19:21

1 Answers1

0

One possibility if you need to run node on Windows, would be to run your web services on multiple machines behind a load balancer.

Then you can stagger updates between the machines using a group policy and disable the web service while updates are running. This way users don't have to hit your service while Windows Updates are running.

Mikael H
  • 5,031
  • 2
  • 9
  • 18
  • So if I understand : It is better to have two server of 2 cores than one server of 4 cores ? How can I make a load balancer ? with nginx ? So I need third server to create the route ? Thank you – Oytoch Dec 16 '19 at 18:16
  • In a virtualized environment I prefer to keep machines as small as possible but not smaller. Windows (unless you run a Core installation) will often feel cramped with less than two CPU cores assigned. As you wrote, NodeJS doesn't use more than one thread per instance. So yes, two cores should be OK. – Mikael H Dec 16 '19 at 20:35
  • As for making a load balancer, there are several options, with HAProxy, Nginx and Apache probably the most common ones. And yes, you'll likely want to set up a third server for the load balancer, not least because you'll likely want to run it on Linux rather than in Windows, for performance and overhead reasons. – Mikael H Dec 16 '19 at 20:39
  • Thank you Mikael. The only downside is the cost: I need two more VMs (4vCPU + 8GB of RAM) . I will try your solution and give you feedback. My constraint is that my servers are windows servers. – Oytoch Dec 22 '19 at 10:02
  • For the load balancer you should be fine with a considerably smaller VM: Without knowing the specifics for Windows, my hunch is that if you run something like Nginx on a Server Core installation you will probably be able to handle quite a lot of concurrent connections within the limits of a single core and a couple of GB of memory. The HAProxy LB pair that sees the most traffic in my systems does fine with 1 vCPU and 1 GB of RAM per node, though for practical reasons I run a number of LB/reverse proxy pairs for different environments. – Mikael H Dec 22 '19 at 12:53