Elxis CMS Forum

Support => Database => Topic started by: yiannisK on October 10, 2010, 17:21:25

Title: Mysql too many connections
Post by: yiannisK on October 10, 2010, 17:21:25
Hello friends after longgg time!

Last days, there are too many connections on mysql service. Till now, always working with:
Code: [Select]
[mysqld]
set-variable=max_connections=150
set-variable=max_user_connections=0
(settings my.cnf file)

I run the "processlist" command in mysqladmin section (SSH mode) to see what is going on.
I  noticed that some elxis based sites, has, without any particular reason (low number of guests), too many active sql connections!

My question is: how can i drop (switch off) older, past sql connections that are remaining active. Elxis, has a mechanism after a guest leaves the website, to drop the sql connection or this is a server-side setting?

Details:
The site has defender, floodblocker enabled.
mysql 5.0.77 (Version: 5.0.77)
PHP Version:     5.1.6
Web Server:    Apache/2.2.3 (CentOS)
Version    Elxis 2009.0 Stable rev2437 [ Pandora ] 22-May-2009 10:31 GMT+2
Title: Re: Mysql too many connections
Post by: CREATIVE Options on October 10, 2010, 17:23:31
1st you have to check, 3rd parties components, modules, bot.
2nd check the log's
Title: Re: Mysql too many connections
Post by: datahell on October 10, 2010, 22:19:15
Open includes/Core/database.php file and change this:
....$this->_resource->PConnect(....)
to this:
....$this->_resource->Connect(....)

You will find this in 2 places at the top of the file inside function __construct.

Note: you dont need to do that if you use Elxis 2009.2.
Older Elxis versions used persistent database connections. This means that the db connection does not closes after the load of the page in order to have fast response on the next request. This is better for sites with high traffic but not for low-mid traffic. We stopped persistent connections on newer releases. Do this change to stop persistent connections.

To remove past connections restart mysql: /etc/init.d/mysql restart   (or wherever your mysql daemon is located to)
Title: Re: Mysql too many connections
Post by: yiannisK on October 10, 2010, 23:05:06
Thanks Datahell! That's exactly i was looking for...