I recently asked a question about how to keep a backend connection persistent using Nginx, but found out it wasn't possible anyway,

It is an HTTP/1.0 proxy without the ability for keep-alive requests yet. (As a result, backend connections are created and destroyed on every request.)

It works all fine right now (since the connection between client and Nginx is kept alive and the result is simply the same), but I don't want to establish a new connection every single time a new request is received ,even if it's on a unix domain socket.

So, what software (preferably open-source and not too tedious to configure) do you recommend to accomplish that such connections ?


I think they're working on putting that in haproxy.

Keep in mind tcp setup on a LAN (=low latency) is usually not a problem, all modern operating systems have this worked out well. Sure it would be nicer just to have open backend connections, but that makes the code of the frontend (nginx or haproxy in this case) a lot more complex in surprising ways.

  • I'm beginning to think zed shaw is right with his mongrel2 architecture. It solves the same kind of problem in a much more elegant way. – Joris Sep 14 '10 at 19:56
  • I agree. But how many keep alive connections is suitable for the backend if the backend upstream is connected over the internet? – CMCDragonkai Apr 15 '14 at 4:29

Apache Traffic Server is an HTTP 1.1 proxy, both front and back-end as I recall. Also a cache and static web server.

  • I'll try it out first on a relatively weak VPS ; is it "heavyweight" like Apache HTTP Server is compared to Nginx ? – felace Sep 15 '10 at 12:25
  • It is heavy compared with nginx, but probably not as beastly as Apache HTTP server. It came from Yahoo, who uses it extensivley internally. That said, nginx not using keepalives on the back-end is NOT a problem if the proxy and target are on a LAN. We handle 275 requests/sec from one nginx on a single core system load-balancing to six Tomact servers. TCP connection setup and teardown is measured in microseconds on a gigabit LAN with modern hardware. – rmalayter Sep 15 '10 at 13:13

I'd vote for varnish, especially if you don't need SSL or are willing to run something else directly on 443 for HTTPS service. http://www.varnish-cache.org/


It depends on what kind of application is running behind your nginx. I've ran with unicorn behind it and using the UNIX socket. That worked like a charm. Now I'm running a Jruby application with Trinidad that goes over HTTP, which sort of works. There is a mod_ajp for nginx that you should be able to use if you run your backend app in Tomcat. Afaik it keeps a AJP persistent connection.

  • That still isn't keep-alive though. Nginx's mod_proxy opens and closest the connection for every request. – Hongli Lai Oct 1 '10 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.