Live data from Hacker News

WebSockets with Varnish and Nginx

thruflo.com

1–10 of 20 posts

Re: WebSockets with Varnish and Nginx

#3

If you have Varnish then why have nginx? Is there an advantage to having nginx do the request routing?

nginx can compress your HTTP traffic, while Varnish can't. So there are some things you would need nginx for.

However, I really think that nginx should implement proper support for WebSockets by now. I have requested this previously, but the request got unanswered.

Re: WebSockets with Varnish and Nginx

#4

If you have Varnish then why have nginx? Is there an advantage to having nginx do the request routing?

I would think nginx would be better for holding open long "keep alive" connections than Apache or IIS if you are doing long polling etc.

Of course if you are just forwarding to another backend you may lose this.

Re: WebSockets with Varnish and Nginx

#5
post #3

If you have Varnish then why have nginx? Is there an advantage to having nginx do the request routing?

nginx can compress your HTTP traffic, while Varnish can't. So there are some things you would need nginx for. However, I really think that nginx should implement proper support for WebSockets by now. I have requested this previously, but the request got unanswered.

FYI, compression was added to Varnish in 3.x:

https://www.varnish-cache.org/docs/3.0/tutorial/compression....

Re: WebSockets with Varnish and Nginx

#8
post #7

this does not address the problem with ssl-traffic. varnish will delegate it to a reverse proxy _in front_ of itself. i usually deploy nginx. looks like a catch-22 for websockets ;).

So how do you handle the case of SSL in front of web traffic and web socket traffic? I need to handle both SSL and non-SSL. Right now I just use another port, but my users behind a firewall can't access the websocket.

Re: WebSockets with Varnish and Nginx

#10
Varnish allocates one thread per connection. Even if it supports websockets, it's not going to scale well across tens of thousands of simultaneous persistent connections. The context switch and memory overhead will be considerable.

For now, Java-based servers (using netty) and node.js may be a better idea.

Post reply on HN