Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2006
    Location
    Lancashire, UK
    Posts
    473

    Will an AJAX shoutbox with lots of users active in it kill the server?

    I am upgrading my online game, and i am going to use and AJAX shoutbox, to show shouts instantly, by refreshing the display area each second.

    I was wondering though, if the server is being called every second by possibly hundreds of people, and displaying 50 shouts, will it kill the server and get me removed from my hosting for taking up server resources?

    is there a better way i can make an AJAX shoutbox, which doesnt fetch the 50 shouts each second?

  2. #2
    Join Date
    Aug 2005
    Location
    UK
    Posts
    654
    Instead of checking with teh server every second (called polling) I prefer to have my AJAX connect, the CGI or PHP then stals for upto 30 seconds untill there is any text/chat to output, if there isn't it dies and the AJAX makes a new request.

    This makes the updates quicker, no up-to-one seond lag, and cuts load dramaticly.

  3. #3
    Youd probably do a lot better making a java applet to do something like that just to be on the safe side. Im not sure how that particular chat works but calling any page that much will put pressure on the server.

  4. #4
    Join Date
    Feb 2006
    Location
    Lancashire, UK
    Posts
    473
    hmm, i want to stick with javascript and php

    Xeentech, could you give me a quick example of a script i could use? I didnt really understand what you were saying

  5. #5
    Join Date
    Aug 2005
    Location
    UK
    Posts
    654
    Its hard to explain. Its almost exactly the same as what you are doing, but when the server gets your AJAX Request, instead of returning "theres nothing new". It will wait untill there is something to return.

    Read: http://ajaxpatterns.org/HTTP_Streaming

    BTW, thats the first result in google for "http streaming ajax", thats the best term I can think of to describe what I do.

  6. #6
    Join Date
    Jan 2006
    Location
    Ontario, Canada
    Posts
    958
    I've you'd like to see a working example, check out the bottom of www.kdoubt.net

    That should answer your question
    Kdoubt.net - Gameing discussion, arcade, all around good fun

  7. #7
    Join Date
    Feb 2006
    Location
    Lancashire, UK
    Posts
    473
    ok, so instead of making loads of ajax requests, you just make one, which is a loop (therefore keeping the conection to the server open) and constantly looping?

  8. #8
    Join Date
    Feb 2006
    Location
    Lancashire, UK
    Posts
    473
    is that what you mean????

  9. #9
    Join Date
    Jan 2006
    Location
    Ontario, Canada
    Posts
    958
    Yes, simply put
    Kdoubt.net - Gameing discussion, arcade, all around good fun

  10. #10
    Join Date
    Aug 2005
    Location
    UK
    Posts
    654
    You have to watch out though. I recommend you have the looping php/cgi exit after 30-60 seconds and have the javascript/ajax connnect again. Some crappy browsers (lets not name names) sometimes can't handle very long Keep-Alive sessions, and some proxys will also bork it up.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •