View Full Version : Too many connections problem...
karel1985
09-26-2009, 02:23 PM
Dear staff,
Recently (6 months) ago i moved from a shared host to a owned VPS (30gb, 1gb ram, dual xeon). http://www.pc-helpforum.be
Now each 2 weeks we are goiing down due to this error:
Database error in vBulletin :
mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Too many connections
/home/pchelp/domains/pc-helpforum.be/public_html/includes/class_core.php on line 311
MySQL Error :
Error Number :
Request Date : Thursday, September 24th 2009 @ 03:37:50 PM
Error Date : Thursday, September 24th 2009 @ 03:37:50 PM
Script : http://www.pc-helpforum.be/showthread.php?t=612
Referrer : http://www.google.be/url?sa=t&source=web&ct=res&cd=1&url=http%3A%2F%2Fwww.pc-helpforum.be%2Ff159%2Fhoe-een-thuis-netwerk-instellen-mappen-612%2F&ei=LHa7SsPzItPd-Qak75jRCw&rct=j&q=netwerk+instellen&usg=AFQjCNFfY7GGin4oofgwl_iWJaugdycx2Q
IP Address : 78.22.169.108
Username :
Classname : vB_Database
MySQL Version :
We received hundreds of these emails. Now we did check the serverload and i went from 0.6 to 2,5 serverload, although we had 700mb of free ram.
what is the suggestion you have or what can we check or change?
Thanks,
Best Regards,
Karel Beuckelaere
http://www.pc-helpforum.be
Lynne
09-26-2009, 03:08 PM
That is a server issue. See this - Common MySQL Error Messages (http://www.vbulletin.com/forum/../docs/html/troubleshoot_mysql_errors)
snakes1100
09-26-2009, 04:04 PM
Edit my.cnf (Typically /etc/my.cnf or /etc/mysql/my.cnf or /etc/my.ini)
max_connections = xxx
Raise the current value by 100
Restart mysql
Angel-Wings
09-26-2009, 04:26 PM
Additionally to raising the max_connections, give mysqltuner / tuning-primer a try to see if there're some more bottlenecks in the DB config.
Just use the outputs of the 2 scripts as some kind of guideline - specially tuning-primer tends to report a way too low key_buffer_size and mysqltuner will nearly always report something about doing an OPTIMIZE run ;)
karel1985
09-27-2009, 10:53 AM
Edit my.cnf (Typically /etc/my.cnf or /etc/mysql/my.cnf or /etc/my.ini)
max_connections = xxx
Raise the current value by 100
Restart mysql
Ok thanks, i raised it to 300. Lets wait and see :-) Thanks for the help.
--------------- Added 1254052474 at 1254052474 ---------------
Additionally to raising the max_connections, give mysqltuner / tuning-primer a try to see if there're some more bottlenecks in the DB config.
Just use the outputs of the 2 scripts as some kind of guideline - specially tuning-primer tends to report a way too low key_buffer_size and mysqltuner will nearly always report something about doing an OPTIMIZE run ;)
Will check this out...
imported_silkroad
09-27-2009, 06:32 PM
I agree. Don't update max_connections until you have run mysqltuner.pl and tuning-primer.sh
Reference:
MySQL Tuning Tools with mysqltuner.pl and tuning-primer.sh (http://www.unix.com/web-programming-web-2-0-mashups/75618-mysql-tuning-tools-mysqltuner-pl-tuning-primer-sh.html)
karel1985
10-04-2009, 03:10 PM
Thanks,
I'm quiet new to this but i found it how to run it.
I'm now reading everything and trying to analise it...
My vps has 30gb space and 1gb of Ram
Here are the results of Tuning Primer
-- MYSQL PERFORMANCE TUNING PRIMER --
- By: Matthew Montgomery -
MySQL Version 5.0.67-community i686
Uptime = 7 days 23 hrs 46 min 54 sec
Avg. qps = 18
Total Questions = 12726470
Threads Connected = 1
Server has been running for over 48hrs.
It should be safe to follow these recommendations
To find out more information on how each of these
runtime variables effects performance visit:
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html
Visit MySQL :: MySQL Enterprise Advisors (http://www.pc-helpforum.be/redirect-to/?redirect=http%3A%2F%2Fwww.mysql.com%2Fproducts%2F enterprise%2Fadvisors.html)
for info about MySQL's Enterprise Monitoring and Advisory Service
SLOW QUERIES
The slow query log is NOT enabled.
Current long_query_time = 10 sec.
You have 1 out of 12726509 that take longer than 10 sec. to complete
Your long_query_time may be too high, I typically set this under 5 sec.
BINARY UPDATE LOG
The binary update log is NOT enabled.
You will not be able to do point in time recovery
See MySQL :: MySQL 5.0 Reference Manual :: 6.3 Point-in-Time Recovery (http://www.pc-helpforum.be/redirect-to/?redirect=http%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefma n%2F5.0%2Fen%2Fpoint-in-time-recovery.html)
WORKER THREADS
Current thread_cache_size = 256
Current threads_cached = 14
Current threads_per_sec = 0
Historic threads_per_sec = 0
Your thread_cache_size is fine
MAX CONNECTIONS
Current max_connections = 300
Current threads_connected = 1
Historic max_used_connections = 15
The number of used connections is 5% of the configured maximum.
You are using less than 10% of your configured max_connections.
Lowering max_connections could help to avoid an over-allocation of memory
See "MEMORY USAGE" section to make sure you are not over-allocating
MEMORY USAGE
Max Memory Ever Allocated : 115 M
Configured Max Per-thread Buffers : 1.42 G
Configured Max Global Buffers : 42 M
Configured Max Memory Limit : 1.46 G
Physical Memory : 1.00 G
Max memory limit exceeds 90% of physical memory
KEY BUFFER
0 * 1024 / 16777216 * 100
Current MyISAM index space = 58 M
Current key_buffer_size = 16 M
Key cache miss rate is 1 : 1467
Key buffer free ratio = 0 %
You could increase key_buffer_size
It is safe to raise this up to 1/4 of total system memory;
assuming this is a dedicated database server.
QUERY CACHE
Query cache is enabled
Current query_cache_size = 16 M
Current query_cache_used = 14 M
Current query_cache_limit = 1 M
Current Query cache Memory fill ratio = 87.79 %
Current query_cache_min_res_unit = 4 K
However, 1232170 queries have been removed from the query cache due to lack of memory
Perhaps you should raise query_cache_size
MySQL won't cache query results that are larger than query_cache_limit in size
SORT OPERATIONS
Current sort_buffer_size = 2 M
Current read_rnd_buffer_size = 768 K
Sort buffer seems to be fine
JOINS
Current join_buffer_size = 1.00 M
You have had 298 queries where a join could not use an index properly
You should enable "log-queries-not-using-indexes"
Then look for non indexed joins in the slow query log.
If you are unable to optimize your queries you may want to increase your
join_buffer_size to accommodate larger joins in one pass.
Note! This script will still suggest raising the join_buffer_size when
ANY joins not using indexes are found.
OPEN FILES LIMIT
Current open_files_limit = 8310 files
The open_files_limit should typically be set to at least 2x-3x
that of table_cache if you have heavy MyISAM usage.
Your open_files_limit value seems to be fine
TABLE CACHE
Current table_cache value = 4000 tables
You have a total of 241 tables
You have 355 open tables.
The table_cache value seems to be fine
TEMP TABLES
Current max_heap_table_size = 32 M
Current tmp_table_size = 32 M
Of 75313 temp tables, 17% were created on disk
Created disk tmp tables ratio seems fine
TABLE SCANS
Current read_buffer_size = 1 M
Current table scan ratio = 96 : 1
read_buffer_size seems to be fine
TABLE LOCKING
Current Lock Wait ratio = 1 : 60194
Your table locking seems to be fine
Here are the results of MySQL Tuner
>> MySQLTuner 1.0.1 - Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at MySQLTuner (http://www.pc-helpforum.be/redirect-to/?redirect=http%3A%2F%2Fmysqltuner.com%2F)
>> Run with '--help' for additional options and output filtering
Please enter your MySQL administrative login: pchelp
Please enter your MySQL administrative password:
-------- General Statistics --------------------------------------------------
[--] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.0.67-community
[OK] Operating on 32-bit architecture with less than 2GB RAM
-------- Storage Engine Statistics -------------------------------------------
[--] Status: +Archive -BDB -Federated -InnoDB -ISAM -NDBCluster
[--] Data in MyISAM tables: 124M (Tables: 238)
[--] Data in MEMORY tables: 1M (Tables: 3)
[!!] Total fragmented tables: 15
-------- Performance Metrics -------------------------------------------------
[--] Up for: 7d 23h 32m 32s (12M q [18.417 qps], 783K conn, TX: 4B, RX: 406M)
[--] Reads / Writes: 75% / 25%
[--] Total buffers: 74.0M global + 4.9M per thread (300 max threads)
[!!] Maximum possible memory usage: 1.5G (149% of installed RAM)
[OK] Slow queries: 0% (1/12M)
[OK] Highest usage of available connections: 5% (15/300)
[OK] Key buffer size / total MyISAM indexes: 16.0M/58.1M
[OK] Key buffer hit rate: 99.9% (299M cached / 203K reads)
[OK] Query cache efficiency: 58.2% (5M cached / 9M selects)
[!!] Query cache prunes per day: 154293
[OK] Sorts requiring temporary tables: 0% (10 temp sorts / 2M sorts)
[OK] Temporary tables created on disk: 17% (15K on disk / 91K total)
[OK] Thread cache hit rate: 99% (15 created / 783K connections)
[!!] Table cache hit rate: 6% (353 open / 5K opened)
[OK] Open file limit used: 7% (651/8K)
[OK] Table locks acquired immediately: 99% (12M immediate / 12M locks)
-------- Recommendations -----------------------------------------------------
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Reduce your overall MySQL memory footprint for system stability
Enable the slow query log to troubleshoot bad queries
Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
*** MySQL's maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
query_cache_size (> 16M)
table_cache (> 4000)
imported_silkroad
10-04-2009, 03:27 PM
Thanks,
I'm quiet new to this but i found it how to run it.
I'm now reading everything and trying to analise it...
My vps has 30gb space and 1gb of Ram
Here are the results of Tuning Primer
Here are the results of MySQL Tuner
You should follow the recommendations of those scripts, reboot and run for a while, and then run them again.
You certainly need to reduce max_connections. I suggest you reduce your max_connections to 56, since you have never used more than 15 ! This should solve your problem with too much memory allocated (by MySQL) based on your physical memory.
Also, increase your query_cache_size to 32MB and also increase your key_buffer size by a similar amount.
Also, increase your join_buffer_size to around 2MB......
If you do this and run for a while, you can run the scripts again and see what is happening.
Marco van Herwaarden
10-06-2009, 01:09 PM
As per announcement (https://vborg.vbsupport.ru/announcement.php?f=232&a=38), use vBulletin.com for server advice:
Topics that do not fit this forum:
Hosting Discussions.
Please use vBulletin.com for discussion on hosting companies or server suggestions: vBulletin Hosting Options (http://www.vbulletin.com/forum/forumdisplay.php?f=11)
General PHP/MySQL/webserver configuration.
Please use vBulletin.com to get suggestions on your servers configuration on the topic of general PHP/MySQL optimisation. On the vBulletin.com Server Configuration (http://www.vbulletin.com/forum/forumdisplay.php?f=14) you will get suggestions by one of our Support Professionals.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.