Suggestion on "Sorry, SMF was unable to connect to the database ...." error - Page 1
Forum section: electronics / general

author: BravoV
author_rank: Super Contributor
timestamp: February 26, 2013, 02:44:29 pm
content: Got this forum's error message :QuoteUsually I ignored them and happened only once in a while, but I've been getting this lot more lately compared to few months ago.Bandwidth problem ? If it is, just a suggestion, not sure if SMF can do that, for non registered users or guest account, block the access to the post's attachment especially photos, we got tons here in this forum, hopefully this at least will decrease quite amount of bandwidth consumption.Also search function, its a cpu & disk intensive process, make it a timed limit between searches for regged users only, again, if this is doable in SMF, the search feature is well known to be abused alot by users or even by a search bot.

author: baljemmett
author_rank: Unknown
timestamp: February 26, 2013, 11:34:25 pm
content: Quote from: BravoV on February 26, 2013, 02:44:29 pmI believe this is already the case - although I don't often view the forum when I'm not logged in, I do remember before signing up that attachments simply didn't show up at all (which was slightly confusing when people would refer to 'as you see in the photo', etc.)I don't think the 'cannot connect to database' is a bandwidth issue though; it's likely to be either too many concurrent users exhausting the connection pool, or perhaps just high CPU usage causing timeouts?

author: BravoV
author_rank: Super Contributor
timestamp: February 27, 2013, 02:27:45 am
content: Quote from: baljemmett on February 26, 2013, 11:34:25 pmNope, just checked without logged in, still can see those attached pictures.

author: justanothercanuck
author_rank: Frequent Contributor
timestamp: February 27, 2013, 02:37:18 am
content: Quote from: baljemmett on February 26, 2013, 11:34:25 pmCould also be SQL running out of memory and restarting itself.

author: EEVblog
author_rank: Unknown
timestamp: February 27, 2013, 03:29:22 am
content: Pretty sure it's nothing to do with bandwidth. The forum (and blog) is hosted on it's own dedicated server, which is deliberately overkill in order to keep the forum as fast as possible. The bandwidth requirements are consistent and well within the capability of the server and it's backbone.Dave.

author: BravoV
author_rank: Super Contributor
timestamp: February 27, 2013, 03:31:54 am
content: How bout cpu & disk utilization chart ? Any abnormal activities or overloaded recently ?

author: EEVblog
author_rank: Unknown
timestamp: February 27, 2013, 03:40:47 am
content: And some MySQL server stats for those who know about such things.Dave.

author: BravoV
author_rank: Super Contributor
timestamp: February 27, 2013, 03:46:03 am
content: No idea on that sql thingy, Dave, hopefully experts will jump in if there are serious issues by looking that charts & logs.

author: kolonelkadat
author_rank: Regular Contributor
timestamp: February 27, 2013, 05:06:49 am
content: post your my.cnf (/etc/my.cnf), and your server stats (ram cpu) maybe there is some optimization that can be done.If im reading the graph right(green is used memory, orange is free memory), you have a fair amount of ram to throw at caching.a switch to InnoDB is almost definitely in order. I would wager that OP's error is due to MyISAM's table level lock. (only 1 insert/update can be done on a table at any given time). InnoDB does need more ram for caching and whatnot, but it looks like you've plenty to spare.

author: EEVblog
author_rank: Unknown
timestamp: February 27, 2013, 07:54:21 am
content: Quote from: kolonelkadat on February 27, 2013, 05:06:49 amI have no idea what InnoDB is, but if it's not already part of my standard WHM/cPanel config then I'm not going near itThere is nothing wrong with the forum, so nothing to fix really. If there were more database connection errors then more people would be complaining. I see a connection error maybe once a month, and I'm one of the heaviest forum users on the other side of the planet from the server.Dave.

author: grumpydoc
author_rank: Super Contributor
timestamp: February 27, 2013, 08:12:11 am
content: QuoteFWIW I see it anything from once or twice a day to once or twice a week, usually clears if I come back in 5 mins or so.

author: justanothercanuck
author_rank: Frequent Contributor
timestamp: February 27, 2013, 11:23:21 am
content: I wouldn't worry about the SQL performance error messages, most of those are caused by how web forums are designed.I am worried about the CPU and memory usage though. Ideally you want as close to 0% as possible (even if that sounds like a waste). If we're running at 97% cpu with 2 gigs of memory swapped out, then the server is totally underpowered.

author: Thor-Arne
author_rank: Unknown
timestamp: February 27, 2013, 07:36:55 pm
content: Quote from: justanothercanuck on February 27, 2013, 11:23:21 amI agree.Another thing to watch out for is time spent reading/writing from/to disk.Optimizing the database might help a little on disk access.That said, I haven't noticed any database issues.

author: ModemHead
author_rank: Frequent Contributor
timestamp: February 27, 2013, 08:30:30 pm
content: I get those errors very often during east-coast US morning hours. Sometimes it's bad enough I have to just move on and come back later. Most other times it's OK.

author: robrenz
author_rank: Super Contributor
timestamp: February 27, 2013, 08:46:52 pm
content: Same here and It does seem to be more frequent lately.

author: EEVblog
author_rank: Unknown
timestamp: February 27, 2013, 09:38:40 pm
content: Quote from: justanothercanuck on February 27, 2013, 11:23:21 amYes, but if it was really maxed out like that I'd expect poor performance all the time. But this is probably one of the fastest forums that I use.For those curious. I'm on the basic plan here:http://www.hostgator.com/dedicatedIntel Xeon E3-1220LV2 2.3GHz10 mbps Uplink4 GB DDR3 Memory500 GB RAID-1 Drives10 TB BandwidthUp to 5 Dedicated IPsI can go up to a bigger plan that gets me a faster processor and more bandwidth, but like I showed, I don't need that bandwidth.They don't have any fancy hybrid server mix-n-match plans optimised for things like database access etc.(and no, unless something is drastically wrong, I'm not changing host providers)Dave.

author: manicdoc
author_rank: Unknown
timestamp: February 28, 2013, 01:05:00 am
content: As I just said in my email; you need to look at the whole 'chain' i.e. Apache <> Php <> MySQL - if any one of these is not correctly 'scaled' it will impact the other and create a backlog that will result in either dropping connections at Apache or MySQL level when your traffic peaks - either way the pages break or it goes slowmo..Probably need to sit down with you next Thursday and have a look around, can probably sort you in 5 minutes.

author: EEVblog
author_rank: Unknown
timestamp: February 28, 2013, 02:57:11 am
content: Server status attached.All seems ok.Dave.

author: TerminalJack505
author_rank: Super Contributor
timestamp: February 28, 2013, 05:11:30 am
content: I've been getting this message lately. The only time it's a problem is when you try to post something. If you get it when you are posting then you will lose the text of your (profound and life-changing) post. I've been copying the text of my posts to the clipboard before hitting 'Post' or 'Preview' because of this.So far as the error goes, it sounds like the maximum database connections may be getting exceeded. I'd check the SQL logs and also peek at what the maximum is currently set to.

author: BravoV
author_rank: Super Contributor
timestamp: February 28, 2013, 05:34:19 am
content: Looks like I'm not alone experiencing this.

author: justanothercanuck
author_rank: Frequent Contributor
timestamp: February 28, 2013, 10:37:13 am
content: Quote from: EEVblog on February 28, 2013, 02:57:11 amThat one seems okay. A load average of 0.5 for a 8 core system is more than fine. I'm not sure why the other ones said you were deep in swap. Still doesn't explain the slowness and errors.

author: EEVblog
author_rank: Unknown
timestamp: February 28, 2013, 10:14:14 pm
content: I asked HostGator about the issue and they responded with:QuoteSo we'll increase the number of connections and see if that makes a difference.Dave.

author: EEVblog
author_rank: Unknown
timestamp: February 28, 2013, 10:17:52 pm
content: Another stats shot.Dave.

author: EEVblog
author_rank: Unknown
timestamp: February 28, 2013, 10:22:17 pm
content: I have enabled "compressed output" on the forum which is supposed to lower the bandwidth requirement.I have enabled the "persistent connection" option which "Keeps the connection active to increase performance. If you aren't on a dedicated server, this may cause you problems with your host."I have also enabled it to email me every time there is a database connection error.Will see how it goes.Dave.

author: EEVblog
author_rank: Unknown
timestamp: February 28, 2013, 10:26:36 pm
content: Also, the current SMF forum "load average" is 1.34This figure is very low, and the default recommended values are 2.5 to disable the search feature, and 40 to disable the forum completely.So all pointers seem to show that the forum is not being overloaded in any way.Dave.

author: TerminalJack505
author_rank: Super Contributor
timestamp: February 28, 2013, 10:31:57 pm
content: The maximum allowed connections per database user would concern me. I don't know how the Simple Machines software works but I'm willing to bet it does pretty much all database access as just a handful of database users.I'm sure it wouldn't hurt anything to boost both of those parameters.

author: Monkeh
author_rank: Super Contributor
timestamp: February 28, 2013, 10:59:49 pm
content: Quote from: EEVblog on February 27, 2013, 07:54:21 amYou should be scared to be using cPanel.

author: justanothercanuck
author_rank: Frequent Contributor
timestamp: February 28, 2013, 11:36:47 pm
content: Quote from: EEVblog on February 28, 2013, 10:26:36 pmEnabling gzip would actually make the CPU consumption worse. I'm also surprised that hostgator limits you to 150 (or even 25) connections. That's also not helping.As for SMF and it's 40-load upper limit, that's just silly. I don't think a single-core system would even run with a load of 40. Scale that same machine up to 8 cores, and it's still running 5 processes per-core at-once. A system can only multitask so much, even moreso if it's fighting with gzip for CPU resources.But hey, I just call it like I see it. It's not like I haven't been doing this for the past 10 years.I'm sure we all appreciate you trying though.

author: mariush
author_rank: Super Contributor
timestamp: February 28, 2013, 11:39:59 pm
content: Dave, it's unlikely to be a hardware issue, the configuration you have is fine and powerful enough.The issue is most likely related to the number of simultaneous connections allowed to MySQL, coupled with some settings you have in Apache and PHP.PHP likes to reuse connections but Apache also works with processes or threads (depending how it's configured) and depending on how many users you have connecting at the same time or within a short amount of time, apache creates processes or threads to handle the connections better and faster, and each of these threads/processes load their own php, and these copies will create separate mysql connections.. and you might reach a mysql connection limit.You can check how many connections mysql has at a particular time with phpMyAdmin - you should have that in CPanel.. log in using the root mysql password or forum's password then right from the main screen you can click on "Variables" button in the menu and scroll down until you find:max connect errors 10max connections 100I have only 3-4 low traffic sites and as you can see I had 10 connect errors in a months - I should increase the max connections as well. If you login into Mysql using phpMyAdmin with the root account, you may be able to edit the setting right there in the Variables window (if you hover the mouse over the area with the number, a small edit link should appear somewhere near it - it depends on what skin phpmyadmin uses)Also on that main page of phpMyAdmin, you have a button called Status, that shows the current status of MySQL. Click on All Status Variables, then filter by using the word "connect" and you should have there "Max used connections" - if that is a high value, it may be a hint you need to increase the limits.PS. If you have a dedicated server, even if it's managed by Hostgator, they should do what you say, within reason. I don't understand how they limit you to 25 connections per database user... is the database on another server that's shared by several people?If so I could understand why they'd put limits on each user accessing the mysql server but you could very well ask them to setup mysql on your own dedicated server and allow that mysql installation to use as much ram and processor as you want. There's no law/rule saying your dedicated server has to be only a "web server".gzip compression isn't so beneficial, most of the traffic is pictures which are already compressed. Save cpu power and leave that disabled.