Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
#1040 - Too Many Connections
Old 07-20-2009, 09:35 AM #1040 - Too Many Connections
animeez's Avatar
Experienced Talker

Posts: 45
Location: watch anime @ animeez.com
Trades: 0
#1040 - Too Many Connections

What causes this error and how to prevent it in the future?
animeez is offline
Reply With Quote
View Public Profile Visit animeez's homepage!
 
 
Register now for full access!
Old 07-20-2009, 09:57 AM Re: #1040 - Too Many Connections
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Well, obviously, you have too many simultaneous connections to your site.

2 ways to solve this:
1) reduce the number of simultaneous clients. Implement a caching mechanism that will lighten the server load
2) modify the server settings to allow more connections.

And maybe...
If you use PHP, and your db is mysql, try to switch from temporary connections to permanent connections.
It might help, but other problems might arise.
See http://www.php.net/function.mysql-pconnect and http://www.php.net/manual/en/feature...onnections.php
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 07-20-2009 at 09:59 AM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 07-24-2009, 02:23 PM Re: #1040 - Too Many Connections
Lashtal's Avatar
wherenomanhasgonebefore

Posts: 679
Name: Lashtal
Trades: 0
I would find it interesting to know...

are you on a shared server, or dedicated?

and

how many visitors are you getting on your site daily (average)?
__________________
Currently Reading:
Please login or register to view this content. Registration is FREE
Lashtal is offline
Reply With Quote
View Public Profile
 
Old 07-25-2009, 10:02 AM Re: #1040 - Too Many Connections
Super Talker

Posts: 130
Trades: 0
That is actually a much deeper question than it seems. On the surface, the cause is that the amount of connection requests exceeds the max connections in the my.cnf file. However, the real reason that it happened is what you need to figure out. Usually when I run into this, it's because some other query is locking a table or multiple tables that other queries are requesting.

This could be caused by a run away query, a big job running on the server, there is a problem with the disks i/o, an issue with memory. I've watched this happen as it's happening and it's amazing how fast the server can go from answering all requests quickly to bringing down the server.

Lets say that your average connections are around 20 and a max of 100 and every request is resolved in a few milliseconds. Then something chokes the memory on the server and now every request takes a second. Then what happens is requests are coming in faster than they are resolved and you go from a nice calm average of 20 connections over the last few hours to TOO MANY CONNECTIONS in a matter of 30 seconds.
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
Old 07-27-2009, 08:37 PM Re: #1040 - Too Many Connections
Super Talker

Posts: 130
Trades: 0
I had a perfect example of this same issue happening on my production DB. So I loaded up MonYog and watched the processlist refresh every second until I noticed a pattern. I started seeing an update query that would take about a second or two to run. When multiple people were trying to update the same table, those queries would start to get backed up and take longer to run and more and more connections would build up. I looked at what was wrong with the query and discovered that there was a composite primary key on two fields. I'll call these two fields f1 and f2. They were in the order of (f1, f2) and this is important because when you have a composite key, the order is important. The where condition was only looking at f2 which means that an index wasn't being used at all. If it would have been on f1, than the index would be used or if the where condition looked at both the index would be used. For my issue, the query needed to look at both so we simply changed it to do so and it picked up the index, which took the query down to milliseconds. Another option would have been to also add single index on f2.
__________________
flann

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
flann is offline
Reply With Quote
View Public Profile
 
Old 07-30-2009, 05:44 AM Re: #1040 - Too Many Connections
Extreme Talker

Posts: 167
Name: Jilesh
Trades: 0
Hi,

You need to close all unwanted connection into your coding part..as it may remain open and forget to close it..Also you can increase the connection limit by contacting your hosting service provider from the server end.
__________________

Please login or register to view this content. Registration is FREE

ASP.NET 3.5 | SQL 2005 Database | US Based Hosting Company | 24 X 7 Support | Daily Backups
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
thewebhostingdi is offline
Reply With Quote
View Public Profile
 
Old 07-30-2009, 02:34 PM Re: #1040 - Too Many Connections
Novice Talker

Posts: 9
Name: Kris
Trades: 0
to many ppl connect to sql databse
dellz is offline
Reply With Quote
View Public Profile
 
Old 07-30-2009, 02:34 PM Re: #1040 - Too Many Connections
Novice Talker

Posts: 9
Name: Kris
Trades: 0
or i may think im wrong
dellz is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to #1040 - Too Many Connections
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26695 seconds with 12 queries