Long polling with codeigniter and node.js Long polling with codeigniter and node.js codeigniter codeigniter

Long polling with codeigniter and node.js


Its not such that node will handle all the requests in one connection. Node can handle large number of concurrent connection at a time, where Apache in other hands can only handle very few concurrent connections as compared to node.js

Look into websockets http://socket.io/ .

Websockets allow full duplex connections between the client and the server. HTTP protocol opens up a connection for each request and the connection ends after the client receives the response. Websockets allows us to keep the connection open.

If you use nodejs and websockets in the server end, you can push the events using the sockets to the clients, as opposed to the clients polling the server in certain intervals.

So it will save you from long polling.

In your case:If you decide on using nodejs and websocket then you will need to find a way to trigger an incoming email event in the server and notify the existing sockets about the event.

So node will also need to poll POP to check mail, whats the difference

Imagine 1000 users logged in to the app using polling. Each user will poll the server every 30 seconds. So 2000 POP polls per second.

Using nodejs, 2 POP poll second, and if there is any mail, notify the sockets, and the clients will handle the event.

But you should really consider the overall requirements of your project.How to decide when to use Node.js?