addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramlinklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [php-49] sql too many connections

From: Dan M.
Sent on: Thursday, November 8, 2012 12:10 PM
I had that problem at my job with the previous database libs we were using (include a file, open a new connection -- these were really old libs from phpbb), we ended up ditching them and rolling our own and then open sourcing it. We've used our lib in production for over a year and it works well (including juggling connections):


hope that helps


On Thu, Nov 8, 2012 at 12:05 PM, Mark Steudel <[address removed]> wrote:
Hmmm that's a good thing to look at.


On Thu, Nov 8, 2012 at 12:04 PM, Dan Munro <[address removed]> wrote:
I think it depends on the type of include. include(), and require(), will open new connections each time afaik. include_once()/require_once() wouldn't.


On Thu, Nov 8, 2012 at 12:02 PM, Mark Steudel <[address removed]> wrote:
If PHP is just using the default mysql_connect in a single include file which is required throughout the site, doesn't it by default attempt to use the same open connection?


On Thu, Nov 8, 2012 at 11:57 AM, Dan Munro <[address removed]> wrote:
Do you know how connections are handled while the script/s run? One thing that I've seen before is that each area of code (as in each include, procedural script, or class) will open it's own new connection to the db, instead of reusing an existing connection, which should reduce the number of open connections.


On Thu, Nov 8, 2012 at 11:48 AM, Mark Steudel <[address removed]> wrote:
So I've inherited a site that has a lot of traffic and we're getting
too many sql connectionsin the error logs. Obviously one solution is
to up the # of max connections in the my.cnf (right now its at 150, I
upped it to 200). I wanted to explore the code and see if there were
some things from the php side I could do to eliminate some of the
problems. Any suggestions on things to try or look for? I can't decide
if using mysql_close explicitly on pages is a good idea or not. Any
guidelines?

--
-----------------------------------------
Mark Steudel
P: [masked]
F: [masked]
[address removed]

. : Work : .
http://www.mindfulinteractive.com

. : Play : .
http://www.steudel.org/blog

. : LinkedIn : .
http://www.linkedin.com/in/steudel



--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
http://www.meetup.com/php-49/
This message was sent by Mark Steudel ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Mark Steudel, visit his/her member profile: http://www.meetup.com/php-49/members/2764664/
Set my mailing list to email me

As they are sent
http://www.meetup.com/php-49/list_prefs/?pref=1

In one daily email
http://www.meetup.com/php-49/list_prefs/?pref=2

Don't send me mailing list messages
http://www.meetup.com/php-49/list_prefs/?pref=0
Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]




--
From the desk of Dan Munro




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Dan Munro ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Dan Munro, visit his/her member profile



--
-----------------------------------------
Mark Steudel
P: [masked]
F: [masked]
[address removed]

. : Work : .
http://www.mindfulinteractive.com
 
. : Play : .
http://www.steudel.org/blog

. : LinkedIn : .
http://www.linkedin.com/in/steudel





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Mark Steudel ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Mark Steudel, visit his/her member profile



--
From the desk of Dan Munro




--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Dan Munro ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Dan Munro, visit his/her member profile



--
-----------------------------------------
Mark Steudel
P: [masked]
F: [masked]
[address removed]

. : Work : .
http://www.mindfulinteractive.com
 
. : Play : .
http://www.steudel.org/blog

. : LinkedIn : .
http://www.linkedin.com/in/steudel





--
Please Note: If you hit "REPLY", your message will be sent to everyone on this mailing list ([address removed])
This message was sent by Mark Steudel ([address removed]) from The Seattle PHP Meetup Group.
To learn more about Mark Steudel, visit his/her member profile
Set my mailing list to email me As they are sent | In one daily email | Don't send me mailing list messages

Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]



--
From the desk of Dan Munro

Our Sponsors

  • PluralSight

    PluralSight subscriptions for developer training

  • O'Reilly

    Disc Code: PCBW is good for 40% off print and 50% off ebooks and videos

  • JetBrains PhpStorm

    Occasional free licenses to raffle off at meetups

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy