Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I practically never see any web application where server pushes messages to the client. While pushing messages from server to client is hugely used in multiplayer games, why this model is so underused in web apps?

Is it wrong? Does it destroy the client-server model?

share|improve this question
1  
Can you give more detail about what you want to use this for? –  Daenyth Jul 24 '12 at 18:58
6  
If pushing data is wrong, I dont want to be right. –  GrandmasterB Jul 24 '12 at 19:10
    
Agree with @GrandmasterB. Pushing is not wrong. Sometimes it's difficult. Sometimes it's the best thing you can do. Sometimes it's not needed. –  joshp Jul 24 '12 at 19:45
    
You see plenty - this is what AJAX is all about. –  user1249 Jul 25 '12 at 9:51

2 Answers 2

up vote 9 down vote accepted

Request-response vs. message pushing

Some architectures and protocols were designed for request-response type of communication. In HTTP, the client asks the server to GET, POST, DELETE, HEAD etc. something, and the server responds (or fails to respond). In POP3, the server role is limited to answer the requests, nothing more.

Some others are designed in a way that the client and the server are communicating together, which enables scenarios which are hardly possible in a request-response model. IMAP, for example, has an advantage over POP3 to allow the new messages to be delivered immediately to the client. To achieve the same nearly-immediate behavior with POP3, the only thing you can do is to query the server for new emails once per second, which obviously raises performance and bandwidth usage issues.

Message pushing in practice

In general, pushing information from server to client may be totally acceptable in some cases. You quoted yourself an example of a type of products where this is a common practice: multiplayer games.

In a web applications, it is unusual to see the information to be sent by the server to the client for several reasons:

  • In many cases, you don't need such feature in a web application. For example, why would MSDN or Google Images start to push something to my browser? Or why would TheDailyWTF change its content on the fly while you're browsing it?

  • For a while, it was impossible to do it without using Java applets or similar non-HTML components, making it very complicate to implement in a website. If you were creating a chat application, using a Java applet wasn't probably too difficult, but for any other web app, it was an overkill. For example, I hardly imagine eBay creating a Silverlight app which would establish a two-way communication with the server in order to update the bids in real time.

Some people came with alternative solutions, but they had their own drawbacks (performance and bandwidth usage). For example, it was not unusual to see some bulletin boards making regular AJAX requests (every ten seconds for example) to see if something changed.

Today, things start to change with HTML 5 and WebSockets. Stack Exchange is an excellent example of a proper use of them: actually, when you see the notifications about new comments or answers or when you see the up and down votes in real time, it's done with WebSockets.

With WebSockets, you may imagine other valid uses of two-ways communication in browsers:

  • Real time information. Example: for large cities, Google Maps has Traffic feature. What about updating this information in real time, or notifying the drivers immediately when an road accident causes traffic jam?

  • Social interactions. Example: when posing a comment on a blog, what about the ability to see the comments of other people immediately after they are posted? Another example: what if, in a bug tracking system, I can see immediately the newly created bug reports?

  • Cases where immediate response is required. Example: a monitoring panel used by a system administrator may be written in HTML and with WebSockets, it may inform the sysadmin immediately if a server is down.

  • etc.

share|improve this answer

I dont think it's wrong. E.g. The company I am with offers a client-server version control system, which pushes a message of in-advance notice when scheduled maintenance is up.

share|improve this answer

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.