Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 26 Sep 2009, 16:23
karel1985 karel1985 is offline
 
Join Date: Mar 2007
Real name: Karel B.
Too many connections problem...

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...l_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
__________________
Dutch Pc Helpforum - www.pc-helpforum.be
Reply With Quote
  #2  
Old 26 Sep 2009, 17:08
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Real name: Lynne
That is a server issue. See this - Common MySQL Error Messages
__________________
Former vBulletin.org Staff Member

Try a search before posting for help. Many users won't, and don't, help if the question has been answered several times before.
W3Schools -
Online vBulletin Manual
If I post some CSS and don't say where it goes, put it in the additional.css template.
I will NOT help via PM (you will be directed to post in the forums for help.)
Reply With Quote
  #3  
Old 26 Sep 2009, 18:04
snakes1100 snakes1100 is offline
 
Join Date: Dec 2001
Real name: Anthony
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
Reply With Quote
  #4  
Old 26 Sep 2009, 18:26
Angel-Wings's Avatar
Angel-Wings Angel-Wings is offline
 
Join Date: Sep 2007
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
Reply With Quote
  #5  
Old 27 Sep 2009, 12:53
karel1985 karel1985 is offline
 
Join Date: Mar 2007
Real name: Karel B.
Originally Posted by snakes1100 View Post
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 27 Sep 2009 at 12:54 ---------------

Originally Posted by Angel-Wings View Post
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...
__________________
Dutch Pc Helpforum - www.pc-helpforum.be

Last edited by karel1985; 27 Sep 2009 at 12:54. Reason: Auto-Merged DoublePost
Reply With Quote
  #6  
Old 27 Sep 2009, 20:32
imported_silkroad imported_silkroad is offline
 
Join Date: Dec 2003
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
Reply With Quote
  #7  
Old 04 Oct 2009, 17:10
karel1985 karel1985 is offline
 
Join Date: Mar 2007
Real name: Karel B.
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
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

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 <[email protected]>
>> Bug reports, feature requests, and downloads at MySQLTuner
>> 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)
__________________
Dutch Pc Helpforum - www.pc-helpforum.be
Reply With Quote
  #8  
Old 04 Oct 2009, 17:27
imported_silkroad imported_silkroad is offline
 
Join Date: Dec 2003
Originally Posted by karel1985 View Post
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.
Reply With Quote
  #9  
Old 06 Oct 2009, 15:09
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
As per announcement, 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

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 you will get suggestions by one of our Support Professionals.
__________________
Marco van Herwaarden
Ex vBulletin.org Coordinator
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 23:17.

Layout Options | Width: Wide Color: