Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am prototyping an application using nodejs. But this question refers to hypothetical large scale roll out. What is more demanding on a server and/or bandwidth: WebSocket stay alive connections or repeated client HTTP GET requests?

For example (maybe an extreme example), is it more efficent for Twitter to allow its clients to send GET requests to its API every 20 secs, or have each client connected on an HTTP1.1 websocket? What about every 1min or greater, or less?

Thanks Ross

btw: maybe it does not matter, but presuming GET requests will be handled by nginx as supposed to node, would this make a difference?

share|improve this question
    
What are you rolling out? Are the GETs keep-alive's themselves or are they checking for updated info? –  Rob Olmos Nov 30 '10 at 1:30
    
Just checking for updated info. In the prototype it returns a json response. –  Ross Nov 30 '10 at 9:35
add comment

2 Answers

up vote 1 down vote accepted

WebSockets are better because you keep connection open and don't send extra protocol headers and other stuff after each request and response. Look at this article:

During making connection with WebSocket, client and server exchange data per frame which is 2 bytes each, compared to 8 kilo bytes of http header when you do continuous polling.

share|improve this answer
    
great, thanks for the info. –  Ross Dec 3 '10 at 10:09
add comment

websockets is a better option but it isn't in all browsers yet. If you go that route you'll want to use SocketIO on the client and node.js side. That will provide a failover to flash sockets if the browser does not support websockets yet.

You gain on websockets since the data that gets sent back to the server isn't as big as a get request.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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