News for hackers. Stuff that matters.
Re:WebSockets with Varnish and Nginx by otterley on Thursday May 17, 2012 @03:44PM (#3988697)
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.

Re:WebSockets with Varnish and Nginx by dolinsky on Thursday May 17, 2012 @05:48PM (#3989294)
To clarify (and answer @sureshv), Varnish allocates one worker-thread per session (active connection), but those threads are pooled by the managed thread pool @sureshv referred to. It's recommended to leave the thread_pool value at 2 and scale the thread_pool_min and _max values to suit your traffic.

As for the handling of the websockets, setting the pipe_timeout variable in the vcl file would release any persistent, yet silent, connections.

Re:WebSockets with Varnish and Nginx by pestaa on Thursday May 17, 2012 @03:58PM (#3988781)
Not only that, but letting all traffic through Varnish is not a good utilization of its resources at all.

The question is, how could I set up multiple servers on the same port? Or what else do I need to put in front of Varnish to route WebSocket connections elsewhere?

I'm starting to think this use case is not easy to solve under one IP address.

Re:WebSockets with Varnish and Nginx by sureshv on Thursday May 17, 2012 @07:52PM (#3989723)
Varnish sits in front on port 80 then proxies based on the VCL configuration, you can parse the HTTP headers/path to pass through appropriately.

https://www.varnish-cache.org/docs/trunk/tutorial/websockets...

Re:WebSockets with Varnish and Nginx by newman314 on Friday May 18, 2012 @01:18AM (#3990449)
One of the things I've debated back and forth personally is if it's better to put nginx in front of varnish or vice versa.

There are reasons to do either but I've not come up with a definitive reason to go one way or another.

Re:WebSockets with Varnish and Nginx by 2mur on Thursday May 17, 2012 @06:26PM (#3989439)
Node Http Proxy: https://github.com/nodejitsu/node-http-proxy

No need for Varnish for proxying your websockets.

Re:WebSockets with Varnish and Nginx by thruflo on Saturday May 19, 2012 @06:16PM (#3997244)
Thanks for the link. This looks like an ideal tool to fulfil the same role as Varnish (in the stack I'd outlined) without losing SSL support or allocating one thread per active connection.
Re:WebSockets with Varnish and Nginx by sureshv on Thursday May 17, 2012 @04:53PM (#3989044)
I don't see why Varnish would create one thread per allocation. They are using epoll/kqueue on an accept thread to handle new incoming requests. The requests themselves are handled by worker thread pool.