Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
May 21, 2012, 03:56:36 AM

Pages: [1]   Go Down
  Print  
Author Topic: Server woes...  (Read 1129 times)
Peak
Spacescooter Operator
*****
Offline Offline

Posts: 44


« on: August 22, 2006, 01:58:34 PM »

I've been talking about this with support, and never got any solution, so I think it's time to ask here...

I have a dedicated server (the smallest one). Sometimes (about once a month or so), the server dies due to "too many connections". If I check the connections I see a lot of mysql-threads that should have died a long time ago using up all connections. And the load is up to about 60-100.

Mostly, the problem goes away if I stop mysql, and restart it after the load goes down. In severe cases I have to reboot the server. I've checked everything I can. There's not a lot of users using the connections when this happens. It's mostly happens at night here in Sweden...

Anyone that have any idea what I can do to keep this from happening. The server is enough for the three small websites that are on the server. Except for the times when this "too many connections" happens, the load is safely above 1.00, and uses few resources.

Logged

//Peak
Peak
Spacescooter Operator
*****
Offline Offline

Posts: 44


« Reply #1 on: August 24, 2006, 01:25:51 PM »

Now it happened again. LP restarted the server (I did it last time), but this shouldn't be happening. The small websites we have on the server doesn't take up many resources.

 Confused
Logged

//Peak
GMTurner
Berserker Poster
*****
Offline Offline

Posts: 7539



WWW
« Reply #2 on: August 24, 2006, 05:09:30 PM »

I think it will depend in part on what scripts you have running on the server. If any of them are set to use persistent connections they might not be closed correctly by the script and so start adding up. Without knowing more about everything that is accessing mysql on your server it is hard to say for sure what the cause might be. Is there a way for you to view where the connections are coming from? If so, are there attempts to connect from hosts that shouldn't be connecting?

just tossing out some ideas...
Logged

The above post was made at a time when I gave a dang and doesn't necessarily reflect my current views or opinions.

For those no longer with us ... Grr..!!

Turner's Lounge
Adelante
Chief Systems Administrator
Pong! (the videogame) Master
*****
Offline Offline

Posts: 23


i see a kitty!!!!


WWW
« Reply #3 on: August 28, 2006, 04:48:24 AM »

This actually very simple to solve.

in your /etc/my.cnf or /etc/mysql/my.cnf

set these values in your [mysqld] section at the bottom:

Quote
set-variable   = wait_timeout=300
set-variable   = interactive_timeout=300
set-variable   = max_connections=500


Also check your php scripts on your server, and I bet you will find that the one which handles your mysql connection is using the mysql_pconnect() option.

mysql_pconnect() will create a persistant connection to your mysql server. The idea behind it is that you can check to see if a connection exists, if it does, then use it. But what is happening is your script is creating a persistant connection to your mysql server, and then the next time the script is called, its nothing checking if one exists, its going and recreating a new connection.

So once 100 people have viewed the page within a certain time period, you end up with 100 persistant connections to your mysql server, and hence the "too many connections" error you are getting.


The settings above will allow for 500 connections and set the timeout of those connections to 300 seconds (I think the default is 28800 seconds).

Dave
Logged
Peak
Spacescooter Operator
*****
Offline Offline

Posts: 44


« Reply #4 on: September 07, 2006, 09:17:27 PM »

No, no persisitent connections. When it runs normally, there's usually only one or two threads to the mysql--databse.

We did some repairing on the database (there was some corruption, apparently), and so far nothing bad have happened again. It usually happens once a month, though, so I'm not out of the woods yet.

The most puzzling thing is that this mostly happens at night.. :p Very few people accessing the forums/websites.

We'll see how it goes.. Smile
Logged

//Peak
Peak
Spacescooter Operator
*****
Offline Offline

Posts: 44


« Reply #5 on: September 10, 2006, 03:25:25 PM »

It seems to continue daily now:

top - 15:22:08 up 10:10,  2 users,  load average: 43.31, 45.04, 43.10
Tasks: 279 total,   1 running, 278 sleeping,   0 stopped,   0 zombie
Cpu(s):  5.9% us,  3.3% sy,  0.0% ni,  0.0% id, 89.5% wa,  1.3% hi,  0.0% si
Mem:    514980k total,   513300k used,     1680k free,      788k buffers
Swap:  1048568k total,  1047256k used,     1312k free,    34016k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
21599 mysql     15   0  227m  35m 2228 S  3.6  7.2  23:04.11 mysqld
 5509 apache    16   0 23256 6448 2464 S  2.0  1.3   0:00.65 httpd
 5684 apache    16   0 23088 6176 2452 S  1.6  1.2   0:00.39 httpd

[root@server ~]# mysqladmin processlist
mysqladmin: connect to server at 'localhost' failed
error: 'Too many connections'

And this is at (lokal time) 00:23. In the middle of the night. Hardly anyone on the sites.

This is really annoying. My guess is that the Mysql LP installed is acting up. Big time. I want this fixed!
Logged

//Peak
perestrelka
Administrator
Master Jedi
*****
Offline Offline

Posts: 1395



« Reply #6 on: September 12, 2006, 04:23:55 AM »

Hi,

Upon looking at the output of top, it appears to me that this problem might be caused by too many processes lingering around on the database server. Then you may reach a limit and no new ones will be allowed to be started. Only this can cause MySQL server to eat so many memory resources.

I noticed that you are running MySQL 4.1.12. MySQL 4.1 undergone a few bug fix releases since then. You would consider upgrading to MySQL 4.1.21 to ensure that it is not a bug in the program.
Logged

Kind Regards,
Vlad Artamonov
Peak
Spacescooter Operator
*****
Offline Offline

Posts: 44


« Reply #7 on: September 12, 2006, 04:05:51 PM »

Yeah. Me and LP have checked up on this several times, and I've now been working on adjust the mysql-database a bit (the forum is beginning to be a bit big, and i suspect that mysql locks when doing something large. Like search, perhaps. Noticed that I hadn't activated full text search for some reason, so I did that plus a few other things I found on Invisionboards forum to optimize the database-interaction with the script.

So far so good, it's running fine at the moment. If there's any more problems, I guess I try to upgrade the memory.

About the mysql-upgrade. Is this included in the managed, or is that considered an extra thing if I don't want to upgrade myself (it's not good for the heart to make upgrades remotely while not an expert on these things).. :p
« Last Edit: September 12, 2006, 04:16:43 PM by Peak » Logged

//Peak
perestrelka
Administrator
Master Jedi
*****
Offline Offline

Posts: 1395



« Reply #8 on: September 12, 2006, 09:41:55 PM »


If you want us to upgrade MySQL for you, there will be an upgrade fee of $75 per hour as you have used the free script install included in the managed addon.
Logged

Kind Regards,
Vlad Artamonov
Pages: [1]   Go Up
  Print  
 
Jump to: