tags:

views:

23

answers:

1

I am using ngnix infront of 4 instances of node.js apps running on 1 machine (quad core), can any ngnix experts give me any advice on how to configure this to get the most out of the web app. I am using connect/express frameworks on node and I think they allow smart caching etc, but I am not sure which bits to let ngnix do and which bits to let the frameworks handle. Any guidance on getting the most out of this setup will be a great help, thanks.

+2  A: 

You need to take into account that any one Node instance will use several threads, and will probably keep at least one thread occupied with I/O. So say that you run 4 instances on a quad core, that means that all 4 instances will produce blocking threads, meaning that you have at least 4 blocking threads (if you have a busy server) meaning that you will at some point block all activity for short periods.

I would suggest not starting more than (number of cores)-1 instances of Node, to be half sure that at least something always keeps moving.

I do assume that there is one blocking thread per Node instance, but I could be wrong. There could be more. But the point remains the same. The more "free" threads you start, the more "blocking" threads will be created as well.

Tor Valamo
Interesting, I am now thinking of going down to one instance then. The web app has nothing blocking as far as I can see. As I have other stuff running on the server (being a cheapskate) like mongodb and redis. I may even need ffmpeg or some such later. Do you think 1 behind ngnix ok? Would you considen dropping nginx altogether?
dryprogrammers
i haven't used connect or express so i can't say what it can or cannot do compared to nginx.
Tor Valamo