• Whenever more than a few people are on my site I get the WP Database error page. My host has told me that its because a script isn’t closing the database calls properly. Now I’ve turned off everything in WP turning it back to the default install and I still get the issue. It leaves me thinking that WP is either not closing DB calls, or its badly coded, or my host can’t support more than 10 people looking at my site at once due to its limit of 10 concurrent connections at once.

    Any ideas?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    my host can’t support more than 10 people looking at my site at once due to its limit of 10 concurrent connections at once.

    Bingo.

    WordPress does close DB connections. In fact, when nobody’s hitting your page, WordPress isn’t even running, so it can’t possibly have a DB connection. But if your DB connection limit is 10, then 10 viewers is the most you can simultaneously have.

    You could use WP-Cache to cache pages. Viewers looking at cached pages never hit the database, in theory. Might improve your performance and eliminate the issue.

    But realistically, a simultaneous connection limit of 10 is horrifyingly low. Jump it up to 100 or so. GoDaddy’s cheap hosting has a limit of 100.

    Thread Starter petemc

    (@petemc)

    Its shared hosting so I have no control over that. They say there was a load of “sleeping connections”.

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    My mistake. WordPress does not explicitly close connections, it relies on PHP to automatically close them at the end of script execution.

    Still, 10 connections is way low. I would get a better host. Like I said, even GoDaddy’s shared hosting is 100 connections.

    Thread Starter petemc

    (@petemc)

    Oh. Is there anyway I can do something to fix this?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Like I said in another thread, this is not an error or a bug. The fact that it doesn’t explicitly close connections should not make any difference.

    Still, there’s some options I posted over here if you want to try them: http://wordpress.org/support/topic/108337?replies=3

    Note that these two different fixes I talk about over there *should not work*. They shouldn’t actually cause anything to change. PHP should not leave a connection open after script execution ends, unless you explicitly tell it to do so with pconnect (which wordpress does not do).

    Thread Starter petemc

    (@petemc)

    So my host has persistant connections turned off and PHP should close the connection automatically. Even with PHP4? It makes me wonder if theres another issue at hand, or whether my site is too popular for the current package I’m on. I’ve installed WP-Cache and I’ll see how that goes but I guess I need to plan for the future.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Closing db connections?’ is closed to new replies.