NGINX has created a complete Deployment Guide for using NGINX and NGINX Plus to load balance HTTP and HTTPS traffic across pools of Node.js® application servers.
This guide to Node.js load balancing applies to both on‑premises and cloud‑based Node.js deployments. It begins with the use of SSL/TLS certificates, basic load balancing for HTTP and HTTPS traffic, basic session persistence, content caching, and HTTP/2.
The guide goes on to describe enhanced Node.js load balancing with NGINX Plus using features including advanced session persistence, application health checks, live activity monitoring, and on‑the‑fly reconfiguration of upstream groups.
Best Practices for Node.js
The first step in load balancing Node.js application servers is to put a reverse proxy server in front of them running NGINX or NGINX Plus. Proxying the application servers offers many benefits, including:
- Protecting Node.js servers from direct exposure to Internet traffic
- Allowing flexibility in the use of multiple application servers
- Allowing implementation of SSL/TLS and HTTP/2
- Performance improvement by enabling caching at the proxy
- Enabling load balancing with both basic and advanced load balancing algorithms
NGINX Plus also proxies the Socket.IO server, as described in Using NGINX and NGINX Plus with Node.js and Socket.IO, the WebSocket API. This prevents dependence on a single port – port 80 for HTTP, or port 443 for HTTPS – for the communications needs of a busy app. Instead, NGINX Plus can dispatch traffic to multiple application servers.
All this, and more, is demonstrated in our Deployment Guide. We hope you find this material useful as you work to improve the performance, reliability, and scale of your Node.js applications.
This guide joins a number of other resources we’ve created for using Node.js and NGINX together:
- 5 Performance Tips for Node.js Applications, exploring ways to speed up Node.js using NGINX
- Using NGINX and NGINX Plus with Node.js and Socket.IO, the WebSocket API, explaining how to use WebSocket and Node.js with NGINX
- NGINX Plus Serves Breaking News for InkaBinka, a case study highlighting production use of Node.js
Special thanks to our friends at NodeSource, who helped us create this guide. NodeSource is the maker of N|Solid, a fully compatible Node.js runtime, enhanced to meet enterprise needs. NodeSource also offers support for both N|Solid and Node.js.