Page 1 of 1

How fast can PHP process information?

Posted: Sat Mar 20, 2010 10:49 pm
by KrypticNinja
I'm working on a browser game and I need to update information in my database after a certain amount of time expires. I had an Idea to do this with php where each time the user loads specific pages it would run an update function checking various mysql tables, for tasks that have finished and update information in another table.

I know how to code it, that shouldn't be too dificult. I'm just not sure if it's gonna take a long time to load, and as much as it would need to run it can't take too long. Obviously the more users who play the more information that will need to be processed.

I'm more worried about the speed of MySQL to tell the truth, but I figured either way this would be a good place to ask.

Re: How fast can PHP process information?

Posted: Sun Mar 21, 2010 8:06 am
by mikosiko
you must consider also implement the processing using MySql Stored Procedure (and call them from your PHP file) and table's triggers

Re: How fast can PHP process information?

Posted: Sun Mar 21, 2010 8:17 am
by KrypticNinja
Hmm I didn't know you could store procedures in mysql. I'll have to look into that, my only concern with that is if mysql takes a while to process the information, would my DB be inaccessible during that time?

Re: How fast can PHP process information?

Posted: Mon Mar 22, 2010 6:54 am
by Jenk
premature optimisation. Cross this bridge when you get to it, not before you've even started.

Re: How fast can PHP process information?

Posted: Wed Mar 24, 2010 4:39 pm
by Zlobcho
Why not using gearman or beanstalkd? You can have few workers waiting to proceed delayed jobs/tasks in background, this way you will avoid the check on every request.

If you need more information, don't hesitate to ask. :)

p.s. If you are running on shared hosting then you can write your own implementation of queue-service and it still will be performing better then your current approach.

Re: How fast can PHP process information?

Posted: Wed Mar 24, 2010 9:12 pm
by KrypticNinja
That was all sort of greek to me ha ha. I just got started with PHP so I'm not familiar with any of that. But I'll look it up on google. Any good tutorials or the like would be greatly appreciated.

Re: How fast can PHP process information?

Posted: Thu Mar 25, 2010 4:26 am
by Zlobcho
Hi KrypticNinja,

http://gearman.org/ here you can read more on gearman or you can join #gearman in irc.freenode.org
http://kr.github.com/beanstalkd/

In very few words, with gearman you have a server, that accepts jobs from clients and dispatch these jobs to available workers.
Let's say you are playing your game (assume it's car racing) and you have purchase new car but you'll get it delivered in two days (2 minutes in the game), when you've pressed "purchase" button, your php code (the client) sends a background job (run separately and the client do not wait for a reply) to gearman/beanstalkd to run "purchase" job for user "x" buying car "y" after 2 minutes.

That's it pretty much, is not that hard, read some more on both solutions and do not hesitate to ask for help. :)