Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2003
    USA, FL

    ajax push script

    I have written a really simple push script using php and jquery ajax. However, the way I had to write the php was a while script which loops continually until an update it sent and then it turns false, send out the message, and starts again.

    Problem is the php while script is eating up the server. I put in a usleep of 100,000 which is .1 sec but still eating it up and the more people who use this the more of these scripts run. So, any ideas?

    1. Find a way to make the while less cpu intensive.
    2. Setup a socket server and have the ajax connect to it.
    3. ?????

  2. #2
    Join Date
    Apr 2009
    Pittsburgh, Pennsylvania
    Use flash, controlled by javascript as a bridge to connect to a socket, and write the socket server in a language that actually supports threading, php supports forking, which isn't effective imo.


    I recommend using python for the server. Lots of free resources out there for it.

  3. #3
    Join Date
    Jan 2003
    USA, FL
    I was trying to just use jquery (ajax) on the front end and php on the back end. I got it working with out any problems; just the php script while doing the "while" loop is maxing out the cpu and if several are initiated it just keeps it max but does not really overload it per say.

  4. #4
    Join Date
    Aug 2005
    I'm working on the same sort of thing currently. We're using XMPP over Ajax/HTTP.. so It's a little more complicated that what you're doing, bt essentially the same thing.

    We're using ProxyPass in Apache to pass requests for /bosh onto a custom socket server that uses select() to multiplex sockets.

    ProxyPass is really only for our development environment. We're expecting to move to something more scalable, like HAProxy, once we deploy.

Similar Threads

  1. Replies: 0
    Last Post: 06-26-2009, 08:26 PM
  2. Looking for a simple AJAX script!
    By jherbison in forum Web Design and Content
    Replies: 9
    Last Post: 10-15-2007, 10:56 AM
  3. Problem with my ajax script
    By latheesan in forum Programming Discussion
    Replies: 2
    Last Post: 09-25-2007, 08:28 PM
  4. installing relay ajax script
    By Calibaba in forum Hosting Security and Technology
    Replies: 0
    Last Post: 03-12-2007, 10:30 PM
  5. Which script push the SQL more?
    By 19leo19 in forum Hosting Security and Technology
    Replies: 3
    Last Post: 08-05-2006, 09:11 AM

Posting Permissions

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