
|
View Full Version : PHP misteries
marco 12-26-2001, 05:24 AM Hi! I have a site at Venturesonline and yesterday the account has been stopped because they said that index.php (my home) took several gigs of RAM and caused high loads :(
I don't understand what it might have happened: the script has always been the same, I didn't touch it and visitors were even less than usual (so you can't say it was due to a spike in bandwidth usage and conseguent load of PHP modules handling additional requests)
Has any of you experienced anything similar? How did you solve it? The script uses gz_handler to compress output and uses persistent MySQL connections. Upon execution, it makes more or less 10 queries to the DBMS
Venturesonline told me that they haven't updated any software.
The sad part is that the (same) script has been running smoothly for the last 5 months
Any idea? I'm a bit confused... :confused:
Cheers,
MCHost-Marc 12-26-2001, 06:36 AM Originally posted by marco
took several gigs of RAM
:eek2:
marco 12-26-2001, 06:40 AM Yes, it sounds very strange (the server has 3.6 gigs of RAM, anyway, thus it can be possible)
Those were the exact words used :(
ho247 12-26-2001, 06:44 AM It could always be an excuse to get you off their server? They could think that you don't know that much about servers, just a thought anyway.
I can't see one PHP page can take 'several gigs' of RAM to load, LOL.
Alan
marco 12-26-2001, 06:48 AM I don't see the reason to send me out of their servers. I haven't done anything "bad" I think, and I use less than the alloted monthly bandwidth. I think VO are serious people, so I believe that there must be some problem with my script (ok: it may take less than one hundred of megs of RAM and not several gigs... but the problem I'm sure is there)
Post the script here for people see it :)
I do not know this site allowed to do that but just make a try ;)
----------------------------------------------------------------
I think VO are serious people, so I believe that there must be some problem with my script (ok: it may take less than one hundred of megs of RAM and not several gigs... but the problem I'm sure is there)
-----------------------------------------------------------------------
You never know what people try to do but I do not think that 1 page can not took several gig of RAM!
well, I confused now; you said it's a all pages in one software(such as e-card; forums...) or just 1 page?
:confused:
ho247 12-26-2001, 08:08 AM persistent MySQL connections
I hear persistent MySQL connections are not recommended, that's why I never use them, it could be that the MySQL queries are taking up a lot of RAM. There's no way that a page can use so much RAM, unless your script is repeating and repeating a command, but if that was the case, it should timeout after a while.
Are you opening any text files or something similar? Or log files come to think of it? The idea I've got is something that over 5 month's time has been built up, like a log file (if log rotation is not used), that way the log file could be say 2GIG and it would certainly take a lot of RAM and procesing power to open and read through the file.
Alan
HRBrendan 12-26-2001, 08:14 AM Check your logs around the time that they say it was causing problems and see if anything strange was happening. Maybe your site was getting hammered by a script, spider, etc. ?
Paul L. 12-26-2001, 08:32 AM We are not kicking him off our servers we dont operate like that unless the customer is unwilling to work with us on resolving the issue and thats not the case here this customer is willing to work with us to fix the issue. Yes there is a problem with his PHP and it takes down the server everytime we unsuspend the account. We will be working with the customer on this issue today so that we can open his site back up.
Asher S 12-26-2001, 08:49 AM OK I'm an experienced PHP programmer and have some knowledge about what might cause the PHP engine/server to freeze.
Do you have an infinite loop which persistently opens mySQL connections and does queries? This was a mistake that one of my programmers made on a certain project causing the server to freeze and eventually reboot.
Also do not use fopen/sockopen functions in infinite loops, causes a reboot or a freeze.
Just thought this might help. By the way if you need help patching up that script, do not hesitate to drop me a line, I'd be glad to help you out. ;)
Regards,
Asher.
Originally posted by Paul L.
We are not kicking him off our servers we dont operate like that unless the customer is unwilling to work with us on resolving the issue and thats not the case here this customer is willing to work with us to fix the issue. Yes there is a problem with his PHP and it takes down the server everytime we unsuspend the account. We will be working with the customer on this issue today so that we can open his site back up.
That's very nice:) :)
Originally posted by Paul L.
We are not kicking him off our servers we dont operate like that unless the customer is unwilling to work with us on resolving the issue and thats not the case here this customer is willing to work with us to fix the issue. Yes there is a problem with his PHP and it takes down the server everytime we unsuspend the account. We will be working with the customer on this issue today so that we can open his site back up.
That's very nice
I wish Unlimmited.com can do that for me but they not! my site hasn't been up for 3 days!
oh well; I am not going care much about it anyway!
People, becarefull with Unlimmited.com :)
;)
marco 12-26-2001, 09:43 AM Dear guys, thanks for replying to my post.
Here in attach you will find the code (only the one involved in index.php, which I was said caused the problem)
Anyway, the code as you can see is common with the rest of the site: therefore if there is a problem there it compromises the entire website :(
(I've cleaned a bit the code and I am excluding "stupid" classes - important files are index.php, pre.inc.php & post.inc.php, common/sql.inc.php, common/http_logger.inc.php)
Thanks again to everybody :)
ho247 12-26-2001, 10:32 AM I haven't had a chance to look at that file yet, but if anyone finds the problem can you post it here, as it'll be nice to know the solution to somethign like this for future reference?
Also, marco, if you get this solved, can you also tell us the solution to it? :)
Thanks,
Alan
revampnet 12-27-2001, 02:07 AM I remember reading somewhere recently that a php script can only take up 8 megs memory max.
Maybe its just in php4 or even php4.1.0 I don't remember were I read it exactly.
brently27 12-27-2001, 10:21 AM Does this sound like the game plan of CT or is it just me?
Joseph 12-27-2001, 06:17 PM Does your script load images, articles, files, or any other data into variables? Every variable that you declare will be stored in the RAM, so if you somehow attempted to store an entire database with thousands of images or articles into variables all at once, then that could take up an awfully large amount of RAM. This could also explain the sudden increase in memory usage; if you were to add a few new large images to the database recently then you could fill up your RAM very quickly. An infinite loop will not occupy you RAM as much as it will hog the CPU, unless of course it were to set new variables on every run. Also note that even if your script only loaded enough data/images into memory to occupy 20 mb, then you will have to multiply that 20 mb by the total number of visitors viewing your web site at one time, making it very easy to burn up 1 GIG of RAM.
I hope this helps,
marco 12-28-2001, 02:41 AM Like the dog that bites his tail, the problem was that a SQL routine called debugging routines if it failed. In that case, debugging routines called SQL code to alert sysadmins, and so on (if failure was "permanent", e.g. a connection to the DBMS failed)
Unluckily, this was very hidden in the behaviour (I've written that code!!!) and was obviously not intended.
Thanks to everybody for replying :)
|