Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I have built a jQuery based text chat in ASP.net where the workflow is as such:

  1. User A logs in.
  2. On the bottom of my page I have an iframe on which the jQuery code is embedded.
  3. jQuery will send a request to the server in 5 second intervals to check wether there are any messages for user A (checks in database).
  4. Any messages found for user A are returned to the client in JSON format and will be displayed in a div tag.


My question regarding this is wether it's a good idea to send these frequent requests to the server as there would be thousands of users polling the server every 5 seconds.

Any suggestions or ideas are welcome.

Thanks in advance!
Posted
Updated 20-Apr-11 1:55am
v2

1 solution

See this discussion on stackoverflow that is about using Comet and jQuery[^] in unison. Comet is based on the Bayeux protocol[^] and is the reverse of Ajax[^]. Whilst Ajax polls the server Comet relies on a standing connection between client and server and the messages are pushed from the server to the client.
This does reduce the traffic a whole lot when there are a large number of clients. Each of them polling the server in intervals of a couple of seconds will put some load onto your machine.

If you still have some questions leave a comment by clicking on "Add comment".

Best Regards,

-MRB
 
Share this answer
 
v2
Comments
Sandeep Mewara 20-Apr-11 10:24am    
My 5 MRB!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900