3 ms·
We use nginx 0.7.x as a load balancer and have no complaints. A pair balance 25M+ requests a day. It's certainly not a full-featured load balancer -- nothing
by jbyers 17y ago
We use nginx 0.7.x as a load balancer and have no complaints. A pair balance 25M+ requests a day.
It's certainly not a full-featured load balancer -- nothing like the visibility and control you get with haproxy or similar -- but for us it's never been a problem. Our backends handle up to 100 concurrent requests and we use straight round-robin across a large pool. In ~2 years, nginx has never hung, mis-balanced requests, or skipped a beat. One node failed once because of human error during a binary upgrade, and I was pissed -- I thought I could keep the thing running forever.
Many of the horror stories I used to see on the nginx lists were in cases where each backend could only handle one request at a time, which I think was the genesis of upstream_fair. I suspect this is a big reason for the bad load balancing reputation.
What's missing is easily taking servers out of rotation and non-trivial health checks. Both can be done with config file changes, and nginx's graceful restart mechanism is very robust. But there's no side-channel for changing upstreams on the fly.
nginx + haproxy is a fine choice if you need more control, and I've seen haproxy on both sides. Haven't used SSL support in haproxy, but it's good in nginx.
- whyleyc 17y agoOut of interest how beefy are the servers you are using to run nginx ? We're looking at it for a deployment and I'm wondering if you had any tips about whether it's a particularly RAM or CPU-hungry beast ?
- jbyers 17y agoWe have single-processor 4GB AMD 1216 and 1354s running nginx. Neither one goes above 20% CPU while doing a few hundred req/s. If we were doing a lot more SSL the picture might change, but nginx seems very efficient.
- whyleyc 17y agoThanks - very helpful to know. One follow-on question - you mention you use 2 machines, is this in a failover capacity or do you use another piece of hardware/software to balance in front if nginx ?
- piotrSikora 17y agoJames, if you are using supervisord for managing backends, you could take servers out of rotation with help of (shamelessly advertised) ngx_supervisord+upstream_fair combo. Side-channel for changing upstreams on the fly (with no entires in nginx configuration) is on the roadmap for ngx_supervisord-2.0, but sadly I don't see this happening in the foreseeable future... Also, could you explain what do you mean by non-trivial health checks?
- piotrSikora 17y agoJames, I've just added way for "easily taking servers out of rotation" to ngx_supervisord.