Forum Moderators: coopster

Message Too Old, No Replies

Polling phps from client at high rates

Server load is just too damn high

         

gawd

8:57 am on Aug 24, 2006 (gmt 0)

10+ Year Member



Hey all,

I'm working on this new website of mine. Making it really short: my clients poll the server every 2 seconds to see if anything changed. It's crystal clear that 2 seconds refresh rate can kill my server rather quickly. So, I thought of changing my code to use Keep-Alive requests with value of 300 seconds. That way, I will save lots of php code execution, mysql socket connections and such. The problem is, that now I will have lots of execution threads on server.

Question is, how is it done with php? I guess I will have to check my database and go sleep for a while. But what about the number of executed php scripts? How many do you think I can run? I'm looking for something with experience in this.

Currently I'm running on shared hosting, but I will probably move to a managed server at some point.

Thanks!

whoisgregg

1:56 pm on Aug 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this just one computer that is refreshing just one page every 2 seconds? Any server should be able to handle that load. I would look first towards optimizing your scripts and database calls.

If those are optimized, this may be one of those situations where an AJAX-type setup would actually *save* bandwidth and CPU cycles. Instead of them refreshing the entire page every 2 seconds, you could have a javascript on the page "refresh" a lean PHP script that returns a "true or false" that something has changed. Then use javascript to automagically refresh the page only when something has changed.

gawd

4:14 pm on Aug 24, 2006 (gmt 0)

10+ Year Member



That's the problem. Currently each client refreshes every 2 seconds. But I want to support as many clients as possible.

If I have 1,000 clients, then I need 1,000 sockets, and 1,000 phps running at the same time :S