Reputation: 6657
I'm using python (Tornado) on server side and some javascript on a client side. I have the common situation - one user send a message to another. And I want server to notify client's browser (reciever of the message) about new message. How can I do it? Should I establish long-alive connection with client (maybe using websocket) or something else?
PS For establishing conenction via websocket I found good library TornadIO
PS2 So, due to high load of project establishing connection betwebb server and each client looks suspicious. I afraid of c10k problem. May be it's only lack of my knowledge.
Upvotes: 4
Views: 1914
Reputation: 15467
I'm using python (Tornado) on server side and some javascript on a client side. I have the common situation - one user send a message to another. And I want server to notify client's browser (reciever of the message) about new message. How can I do it? Should I establish long-alive connection with client (maybe using websocket) or something else?
Using a realtime web server such as Tornado - yes. TornadIO looks like a good solution since it'll use socket.io which has fallback options for older browsers.
The Wikipedia entry on the C10k issues provides a list of servers that have resolved this problem:
A few web servers have been developed to counter the C10K problem:
- nginx, which relies on an event-driven (asynchronous) architecture, instead of threads, to handle requests (WordPress.com uses nginx to solve the C10K problem)[2]
- Lighttpd, which relies on an asynchronous architecture to handle requests[3]
- Cherokee, a lightweight web server[4]
- Tornado, a non-blocking web server and web application framework[5] written in Python
- Apache Deft, asynchronous, non-blocking web server running on the JVM
- JBoss Netty, a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients[6]
- Node.js, asynchronous, non-blocking web server running on Google's V8 JavaScript engine[7]
- EventMachine, an asynchronous, non-blocking web server running on Ruby EventMachine
- Yaws, a web server written in Erlang; profiting from Erlang's extremely lightweight processes.
- Medusa, a non-blocking web server library written in Python
As you'll see, Tornado is listed.
Beyond this your question is potentially more about horizontal scaling than it is about how to achieve server to client notifications.
Depending on which realtime server solution you choose this might never become an issues. For example, a single instance of Caplin System's Liberator can achieve a lot more than 10,000 persistent connections.
Upvotes: 2