mysql_pconnect Too many connections ERROR

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Angelos

    mysql_pconnect Too many connections ERROR

    I get this error mysql_pconnect Too many connections ... every now and
    then.
    Does anyone knows where it comes from ?
    There are a lot of sites running on the server and all of them use the
    Database frequently.
    Is there any configuration that I will have to do to my server in order to
    handle the load ?

    Thank you...
    I would appreciate answers from someone that already experienced that
    problem.


  • Alvaro G Vicario

    #2
    Re: mysql_pconnect Too many connections ERROR

    *** Angelos wrote/escribió (Mon, 1 Aug 2005 12:01:20 +0000 (UTC)):[color=blue]
    > I get this error mysql_pconnect Too many connections ... every now and
    > then.
    > Does anyone knows where it comes from ?[/color]

    It comes from persistent connections: they remain open even when scripts
    ends so your server can display this message even with low load.

    If scripts are out of your control, I'd suggest disabling persistent
    connections in php.ini: scripts that use mysql_pconnect( ) won't stop
    working, they'll just use regular connections.

    [MySQL]
    ; Allow or prevent persistent links.
    ;mysql.allow_pe rsistent = On
    mysql.allow_per sistent=Off



    --
    -- Álvaro G. Vicario - Burgos, Spain
    -- http://bits.demogracia.com - Mi sitio sobre programación web
    -- Don't e-mail me your questions, post them to the group
    --

    Comment

    • Angelos

      #3
      Re: mysql_pconnect Too many connections ERROR


      "Alvaro G Vicario" <alvaro_QUITAR_ REMOVE@telecomp uteronline.com> wrote in
      message news:15tkqr4f5q 6uw$.9wa20n32kn aa$.dlg@40tude. net...[color=blue]
      > *** Angelos wrote/escribió (Mon, 1 Aug 2005 12:01:20 +0000 (UTC)):[color=green]
      >> I get this error mysql_pconnect Too many connections ... every now and
      >> then.
      >> Does anyone knows where it comes from ?[/color]
      >
      > It comes from persistent connections: they remain open even when scripts
      > ends so your server can display this message even with low load.
      >
      > If scripts are out of your control, I'd suggest disabling persistent
      > connections in php.ini: scripts that use mysql_pconnect( ) won't stop
      > working, they'll just use regular connections.
      >
      > [MySQL]
      > ; Allow or prevent persistent links.
      > ;mysql.allow_pe rsistent = On
      > mysql.allow_per sistent=Off
      >[/color]
      Cheers For that ... at the moment I have just used mysql_connect instead of
      mysql_pconnect

      But i Don't really understand when to use the pconnect...


      Comment

      • Andy Hassall

        #4
        Re: mysql_pconnect Too many connections ERROR

        On Mon, 01 Aug 2005 17:21:10 GMT, "Angelos" <adevletoglou@r edcatmedia.net>
        wrote:
        [color=blue]
        >But i Don't really understand when to use the pconnect...[/color]



        For non-persistent connections, the number of open connections is the number
        of concurrent requests, so at maximum:

        = Number of child processes/threads your webserver uses

        The number of connections open to a database when using persistent connections
        is related to:

        Number of child processes/threads your webserver uses
        *multiplied by*
        Number of usernames used in scripts accessing the database server

        If the number of usernames used is large, i.e. there's lots of different
        scripts which each access different MySQL databases, then the number of
        connections opened to the server and held open by the persistent connections
        can get very high. This is usually the case in shared hosting; persistent
        connections are often not a good idea on shared hosting.

        Whereas if there's only a small number of databases accessed on the same
        server, the number of connections may stay manageable, and so you can take
        advantage of not having to open a new connection each time.

        --
        Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
        <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

        Comment

        • evanescent.lurker@gmail.com

          #5
          Re: mysql_pconnect Too many connections ERROR

          Angelos wrote:[color=blue]
          > I get this error mysql_pconnect Too many connections ... every now and
          > then.
          > Does anyone knows where it comes from ?
          > There are a lot of sites running on the server and all of them use the
          > Database frequently.
          > Is there any configuration that I will have to do to my server in order to
          > handle the load ?[/color]

          One possible suggestion, rewriting mysql_pconnect to mysql_connect has
          already been mentioned, but it your load on the mysql server is not to
          high, why don't you just allow more connections? You just need to set
          the max_connection variable in the [mysqld] section of your my.cnf.

          The problem was apparent in some default linux installations, where the
          number of allowed connections to the Apache was higher than the number
          of allowed connections to the mysqld (ie 150 apache connections and
          only 100 allowed mysqld connections).

          But that said, you need to weight between this two choices. Either
          rewrite php to use mysql_connect and have little slower pages, or
          update the mysqld to accept more connections. It's a simple speed vs.
          load, but if your server is mostly sitting idle, I'd go for the
          max_connection solution in my.cnf...

          -- Evanescent Lurker --

          P.S. ooh, a URI:


          Comment

          Working...