DB connection handling - i get "too many connection" - what's the solution?

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

    DB connection handling - i get "too many connection" - what's the solution?

    I have a php-webpage that needs the database in the beginning and in
    the end of the script. In the middle there is a lot of processing that
    takes several seconds - during that time I don't use the database
    connection.

    What is the best approach? Should I close the connection after I'm
    done with it OR should I reuse the connection thru my whole script?

    Where can I read more about this? Any pointers?

    Today I'm using the same connection thru my script. And sometimes I
    get an error from the database "too many connections". What does that
    mean? My webserver provider says that I have at least 100 connections
    to play with. How come I get this error????

    Thank you for all your help!!!!

    Leif
  • Amir Khawaja

    #2
    Re: DB connection handling - i get "too many connection&quot ; - what'sthe solution?

    Leif Wessman wrote:
    [color=blue]
    > I have a php-webpage that needs the database in the beginning and in
    > the end of the script. In the middle there is a lot of processing that
    > takes several seconds - during that time I don't use the database
    > connection.
    >
    > What is the best approach? Should I close the connection after I'm
    > done with it OR should I reuse the connection thru my whole script?
    >
    > Where can I read more about this? Any pointers?
    >
    > Today I'm using the same connection thru my script. And sometimes I
    > get an error from the database "too many connections". What does that
    > mean? My webserver provider says that I have at least 100 connections
    > to play with. How come I get this error????
    >
    > Thank you for all your help!!!!
    >
    > Leif[/color]

    Are you using persistant connections to your database?

    --
    Amir Khawaja.

    ----------------------------------
    Rules are written for those who lack the ability to truly reason, But
    for those who can, the rules become nothing more than guidelines, And
    live their lives governed not by rules but by reason.
    - James McGuigan

    Comment

    • Leif Wessman

      #3
      Re: DB connection handling - i get "too many connection&quot ; - what's the solution?

      No, should I? I have lots of traffic to my website.

      Leif

      Amir Khawaja <amir@gorebels. net> wrote in message news:<fDbUb.247 97$QJ3.13194@fe d1read04>...[color=blue]
      > Leif Wessman wrote:
      >[color=green]
      > > I have a php-webpage that needs the database in the beginning and in
      > > the end of the script. In the middle there is a lot of processing that
      > > takes several seconds - during that time I don't use the database
      > > connection.
      > >
      > > What is the best approach? Should I close the connection after I'm
      > > done with it OR should I reuse the connection thru my whole script?
      > >
      > > Where can I read more about this? Any pointers?
      > >
      > > Today I'm using the same connection thru my script. And sometimes I
      > > get an error from the database "too many connections". What does that
      > > mean? My webserver provider says that I have at least 100 connections
      > > to play with. How come I get this error????
      > >
      > > Thank you for all your help!!!!
      > >
      > > Leif[/color]
      >
      > Are you using persistant connections to your database?[/color]

      Comment

      • Amir Khawaja

        #4
        Re: DB connection handling - i get &quot;too many connection&quot ; - what'sthe solution?

        Leif Wessman wrote:[color=blue]
        > No, should I? I have lots of traffic to my website.
        >[/color]

        Try persistant connections and see what sort of results you end up
        getting. However, I doubt that will solve your problem but it does not
        hurt to try. I'm assuming here that you are using MySQL (since it is the
        popular DB server for PHP). One thing to note about MySQL is that if
        your script runs for a long time, you may want to explicitly close the
        connection prior to executing the code that takes a long time. This way,
        you are not holding up the connection for other potential users of your
        system. 100 is a default value set by MySQL. It means that 100
        simultaneous connections may remain open at any given time.

        --
        Amir Khawaja.

        ----------------------------------
        Rules are written for those who lack the ability to truly reason, But
        for those who can, the rules become nothing more than guidelines, And
        live their lives governed not by rules but by reason.
        - James McGuigan

        Comment

        Working...