View Full Version : Server overload?
shachi
04-11-2007, 03:58 PM
Hello all!!
I have a php script which executes a command on the server(which is pdf2ps), I just wanted to know if it will overload the server if there are many users requesting on the server. If this will overload the server, how can I prevent it or is there any other way to do the same thing?
Thank you all.
pcbrainbuster
04-11-2007, 04:02 PM
http://www.google.co.uk/search?sourceid=navclient&aq=t&ie=UTF-8&rlz=1T4GGLJ_enGB213GB213&q=PHP+bandwidth+detection -
Look around there...
thetestingsite
04-11-2007, 04:19 PM
Being that you are going to be executing a shell script, of course it will use the server resources (in this case, the processor). If quite a few users execute the same script at the same time, then their would be some server load to it (not sure if it will overload it, that just depends on the server hardware itself).
If this will overload the server, how can I prevent it or is there any other way to do the same thing?
If you run your own server, test it out by getting multiple users to access the script at the same time (let's make the limit at 10, then go up from there). If it overloads the server, then depending on how many users you used to test it will help you to decide whether or not to upgrade your server hardware. Otherwise, you could probably prevent this server load by making a limit to how many simultaneous connections the script could have.
Anyways, hope this helps.
shachi
04-11-2007, 04:39 PM
thetestingsite: the time the script I am using(that is: pdf2ps) takes depends on how big the user-uploaded file. So, for e.g. we have two users A and B, will A uploading a huge file make user B to wait until the request from user A is complete(as far as I know, yes)? Is there any way to prevent it?
shachi
04-11-2007, 04:43 PM
Oops, forgot to tell that I am also using ps2png at the same time.
thetestingsite
04-11-2007, 04:46 PM
will A uploading a huge file make user B to wait until the request from user A is complete(as far as I know, yes)?
Yes it will make the user wait, unless the script runs multiple processes. In any case, it will slow the reaction time for user B.
Is there any way to prevent it?
There probably are ways around this, but just not sure of them.
Hope this helps.
shachi
04-11-2007, 04:58 PM
Thanks for the quick reply thetestingsite. May be I can use ampersand(&) for multi tasking?
Yes it will make the user wait, unless the script runs multiple processes.No it won't... the server handles each script in a different thread, otherwise everybody who wanted to view a page would have to wait until everybody else had done downloading it before s/he was allowed a look.
Those two scripts deal with graphics processing, and will probably take up quite a lot of resources. You can set limits to the maximum amount of memory and CPU time per user (/etc/security/limits.conf on my distro). Create a new user, give it some sane limits, and have the shell commands run under that user instead of the one you usually use for PHP scripts. That way you can check if the program fails and return a "sorry, the server is too busy at the moment" error message, without preventing other PHP scripts from working in the mean time.
pcbrainbuster
04-11-2007, 07:56 PM
Yeah, just look at rapidshare.com, if there's to many users downloading it makes you wait two minutes...
thetestingsite
04-12-2007, 03:18 AM
Yeah, just look at rapidshare.com, if there's to many users downloading it makes you wait two minutes...
That is something completely different. They have a user management type system to where if the user is not logged in, it makes them wait. Otherwise, if the user is logged in; and there are more users than the amount they have defined that are accessing the script then they make that user wait.
djr33
04-12-2007, 05:13 AM
Sounds like a fairly specific thing. How many users do you forsee simultaneously uploading? I doubt it'll overlap more than two at a time very frequently.
Let's say your site is really popular... let's say.... 720 uploads per day. That's 21,600 in a month... 259,200 in a year! Congrats ;)
That's an average of 30 per hour. Let's say that they all take 1 minute. Then, there's an average of 1 every two minutes in the hour, with half of that time used for processing, the rest resting.
In other words, the serving is working half the time.
And, sure, it would overlap, but I doubt you'd get more than 3-4 at a time very often. 2 at a time? Sure. 3? sometimes. 4? rarely. 10? hardly ever. more? maaaaybe once in a while.
And, really, many servers have a 30 second limit on the PHP script processing, so that would be even less time busy, assuming all of the processing were under 30 seconds (or you have something bigger to deal with).
In the end, this means that, sure, once in a while, you'll come across a time when multiple people are uploading. They'll get a slight delay. ...so?
I've had slight delays on many pro sites (my connection? Theirs? both?), but it's to be expected. Once in a while something loads slowly. The end. And it would be back up full speed soon enough.
shachi
04-12-2007, 09:08 AM
No it won't... the server handles each script in a different thread, otherwise everybody who wanted to view a page would have to wait until everybody else had done downloading it before s/he was allowed a look.
Oh yes, I completely forgot that shell_exec opens a new shell each time it's called.
Those two scripts deal with graphics processing, and will probably take up quite a lot of resources.
Will using GhostScript take up a lot of resources as well?
You can set limits to the maximum amount of memory and CPU time per user (/etc/security/limits.conf on my distro). Create a new user, give it some sane limits, and have the shell commands run under that user instead of the one you usually use for PHP scripts.
I guess I should do that.
[QUOTE=drj33]Sounds like a fairly specific thing. How many users do you forsee simultaneously uploading? I doubt it'll overlap more than two at a time very frequently.
No clue, this application I am building is just in it's developmental state.
In the end, this means that, sure, once in a while, you'll come across a time when multiple people are uploading. They'll get a slight delay. ...so?
I've had slight delays on many pro sites (my connection? Theirs? both?), but it's to be expected. Once in a while something loads slowly. The end. And it would be back up full speed soon enough.
So, I shouldn't worry about overloading the server or wasting unwanted bandwidth?
Thank you all for your kind replies. :D
djr33
04-12-2007, 09:16 AM
If you want perfection, sure, worry about it.
In a real life situation? Likely could be ok.
I'm not sure on specifics, but I'd say fix it if it becomes a problem.
Do what you can now; doesn't hurt, but don't over stress.
shachi
04-12-2007, 10:06 AM
Ok, Thanks everyone!!
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.