Boat Drinks  

Go Back   Boat Drinks > General > Computer and Consoles

Reply
 
Thread Tools Display Modes
Old 14-02-2007, 21:58   #1
petemc
Moonshine
 
Join Date: Jul 2006
Location: Nr Liverpewl
Posts: 4,371
Default Any MySQL experts in the house?

For the past few weeks I've been having random outages on my photoblog. Visitors get the "Database connection error" message instead of my site. Annoyingly due to the way Wordpress works I can't even access the admin page when this happens. I've been speaking with my host and they say its because some script isn't closing the connection. They say they allow 10 MySQL connections at the same time. My site isn't *that* popular, surely. Larger forums work well enough. This forum does. My site gets 2,000 unique visitors a day. Thats a lot for me, but surely not a lot for MySQL or a large Wordpress site. I'm currently debating whether to spend £200 and jump ship, but £200 at the moment is a lot just to fix a number. Is 10 a small limit? I've been told their a reseller posing as a proper company.
petemc is offline   Reply With Quote
Old 14-02-2007, 22:05   #2
Mark
Screaming Orgasm
 
Join Date: Jul 2006
Location: Newbury
Posts: 15,194
Default

Have a look in the configuration for anything about persistant connections (pconnect). Turn them off.

On shared hosting, persistant MySQL connections are the evil spawn of satan.
Mark is offline   Reply With Quote
Old 14-02-2007, 22:07   #3
petemc
Moonshine
 
Join Date: Jul 2006
Location: Nr Liverpewl
Posts: 4,371
Default

mysql.allow_persistent is turned off. So far my host has told me a few things including deleting and recreating the user. I've just got this feeling that they don't know jack.
petemc is offline   Reply With Quote
Old 14-02-2007, 22:09   #4
Mark
Screaming Orgasm
 
Join Date: Jul 2006
Location: Newbury
Posts: 15,194
Default

10 connections isn't *that* much for a busy site, but it is a lot for an 'average' non-professional site, so it's all down to how busy your site really is.
Mark is offline   Reply With Quote
Old 14-02-2007, 22:21   #5
Garp
Preparing more tumbleweed
 
Garp's Avatar
 
Join Date: Jun 2006
Location: Hawaii
Posts: 6,038
Default

The only other thing, I guess, could be that the website code could be written badly and it keeps mysql connections open longer than it really needs to?

Have you got MySQL doing any caching?
http://www.databasejournal.com/featu...le.php/3110171
__________________
Mal: Define "interesting"?
Wash: "Oh, God, oh, God, we're all gonna die"?
Garp is offline   Reply With Quote
Old 14-02-2007, 22:27   #6
petemc
Moonshine
 
Join Date: Jul 2006
Location: Nr Liverpewl
Posts: 4,371
Default

Quote:
Originally Posted by Mark View Post
10 connections isn't *that* much for a busy site, but it is a lot for an 'average' non-professional site, so it's all down to how busy your site really is.
Nearly 60,000 visitors a month and 250,000 pageviews a month. Maybe it is a big site, maybe not. While I've been a web designer, I've never worked on technically large sites so I don't know what's "large". I know I never used to have this issue till my site became "popular".

Quote:
Originally Posted by Garp View Post
The only other thing, I guess, could be that the website code could be written badly and it keeps mysql connections open longer than it really needs to?

Have you got MySQL doing any caching?
http://www.databasejournal.com/featu...le.php/3110171
I always thought Wordpress was nicely written. Its probably the most popular blog package after Moveable Type. I don't have any access to what MySQL does, shared hosting.
petemc is offline   Reply With Quote
Old 05-03-2007, 16:21   #7
petemc
Moonshine
 
Join Date: Jul 2006
Location: Nr Liverpewl
Posts: 4,371
Default

Right. I've looked into this a lot more now. Here's the deal. Wordpress doesn't forceably close MySQL connections because non-persistant connections are automatically closed at the end of a scripts execution. So I told my host that and they said;

Quote:
Yes, but it’s not the MySQL process causig the problem, but the webserver process. So, since the connections don’t get closed properly and a connection stalls, then it remains active until the webserver process times out, which is longer than the MySQL timeout resulting in your experienced issues.
But the PHP max_execution_timeout is set to 30 seconds. So surely PHP should die after 30 and MySQL should after 60. I've seen some processes in the database sitting there with like 700 seconds on them just called "sleep". Any ideas why this is happening? Is it really a script issue or is my host just a bit iffy?
petemc is offline   Reply With Quote
Old 05-03-2007, 23:45   #8
Garp
Preparing more tumbleweed
 
Garp's Avatar
 
Join Date: Jun 2006
Location: Hawaii
Posts: 6,038
Default

Quote:
Originally Posted by petemc View Post
Right. I've looked into this a lot more now. Here's the deal. Wordpress doesn't forceably close MySQL connections because non-persistant connections are automatically closed at the end of a scripts execution.
In other words, lazy programming. All it takes is a single command to close the connection, and they could have used it.
__________________
Mal: Define "interesting"?
Wash: "Oh, God, oh, God, we're all gonna die"?
Garp is offline   Reply With Quote
Old 06-03-2007, 12:01   #9
petemc
Moonshine
 
Join Date: Jul 2006
Location: Nr Liverpewl
Posts: 4,371
Default

Quote:
Originally Posted by Garp View Post
In other words, lazy programming. All it takes is a single command to close the connection, and they could have used it.
Maybe, but the documentation does say;

Quote:
Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution. See also freeing resources.
The comments on the page also say;

Quote:
RonS is mostly incorrect about mysql_close. It's not necessarily good programming practice to always explicitly close your database connect as it might be in other languages. Your connection will be closed as soon as your script is finished, so there is almost never a need to call mysql_close at the end of a script.
Not defending them, just trying to get a better understanding
petemc is offline   Reply With Quote
Old 05-03-2007, 22:35   #10
Mark
Screaming Orgasm
 
Join Date: Jul 2006
Location: Newbury
Posts: 15,194
Default

Quote:
Note: The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running.
Mark is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:09.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.