Loading ...
Sorry, an error occurred while loading the content.

Apache::DBI and NameVirtualHost

Expand Messages
  • gb
    Hi all! A have some problems with using apache::dbi and name virtual hosts. I have four sites, each having its own login into database. All of them listen to
    Message 1 of 6 , Oct 26, 2005
    View Source
    • 0 Attachment
      Hi all!

      A have some problems with using apache::dbi and name virtual hosts.
      I have four sites, each having its own login into database.
      All of them listen to one ip using NameVirtualHost directive
      Each site has a startup script with
      Apache::DBI->connect_on_init

      It seems to me that apache::dbi is not working properly, though in logs
      I can see that some database handlers are reused as it should be.
      2228 Apache::DBI need ping: yes
      2228 Apache::DBI already connected to '...'
      2178 Apache::DBI disconnect (overloaded)
      2299 Apache::DBI disconnect (overloaded)

      I've also noticed that database connections number is not equal to httpd
      process count and not even equal to 4xhttpd process count (4 sites)

      Am I doing something wrong? Can Apache::DBI hold several handlers for
      one httpd process? I suspect that user connects to different processes
      and the handler (dbname/username/pass) do not always match.
    • Geoffrey Young
      ... Apache::DBI will cache connections on a per-connection-string basis, once in each child process. so, if each connection to a database is made using a
      Message 2 of 6 , Oct 26, 2005
      View Source
      • 0 Attachment
        > Am I doing something wrong? Can Apache::DBI hold several handlers for
        > one httpd process? I suspect that user connects to different processes
        > and the handler (dbname/username/pass) do not always match.

        Apache::DBI will cache connections on a per-connection-string basis, once in
        each child process. so, if each connection to a database is made using a
        different username each will be cached and you'll end up with
        users*processes number of cached connections in total.

        HTH

        --Geoff
      • Randal L. Schwartz
        ... gb Each site has a startup script with gb Apache::DBI- connect_on_init This may be your problem. If the connection string is identical, Apache::DBI
        Message 3 of 6 , Oct 26, 2005
        View Source
        • 0 Attachment
          >>>>> "gb" == gb <gb@...> writes:

          gb> Each site has a startup script with
          gb> Apache::DBI->connect_on_init

          This may be your problem. If the connection string is identical,
          Apache::DBI caches it as "the same connection". But if you then
          do something unique per virthost in your connect_on_init, you're
          working against the system there, and you get broken results.

          One solution is to ensure that you use a different username/password
          per virthost, so that the connection string varies.

          --
          Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
          <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
          Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
          See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
        • gb
          ... The problem is that connection number is greater than users*processes! I have 5 db users(one for each of five sites) and MaxClients = 90 but the connection
          Message 4 of 6 , Oct 27, 2005
          View Source
          • 0 Attachment
            Geoffrey Young wrote:

            >>Am I doing something wrong? Can Apache::DBI hold several handlers for
            >>one httpd process? I suspect that user connects to different processes
            >>and the handler (dbname/username/pass) do not always match.
            >>
            >>
            >
            >Apache::DBI will cache connections on a per-connection-string basis, once in
            >each child process. so, if each connection to a database is made using a
            >different username each will be cached and you'll end up with
            >users*processes number of cached connections in total.
            >
            >HTH
            >
            >--Geoff
            >
            >
            >
            The problem is that connection number is greater than users*processes! I
            have 5 db users(one for each of five sites) and MaxClients = 90 but the
            connection count can reach 500 limit easily on workload peaks and is
            willing to grow further! This sites are very heavyloaded indeed.
            I use Apache 2, mp2.0.1 and Apache::DBI -0.9901
          • Geoffrey Young
            ... are you using the worker or prefork mpm? are you certain that your connect string is identical in each case (and that means identical - same AutoCommit
            Message 5 of 6 , Oct 27, 2005
            View Source
            • 0 Attachment
              >> Apache::DBI will cache connections on a per-connection-string basis,
              >> once in
              >> each child process. so, if each connection to a database is made using a
              >> different username each will be cached and you'll end up with
              >> users*processes number of cached connections in total.

              >>
              > The problem is that connection number is greater than users*processes! I
              > have 5 db users(one for each of five sites) and MaxClients = 90 but the
              > connection count can reach 500 limit easily on workload peaks and is
              > willing to grow further! This sites are very heavyloaded indeed.
              > I use Apache 2, mp2.0.1 and Apache::DBI -0.9901

              are you using the worker or prefork mpm? are you certain that your connect
              string is identical in each case (and that means identical - same AutoCommit
              settings, same user/pass, same _everything_)?

              --Geoff
            • gb
              I use prefork mpm The connection string in a startup script of each site is Apache::DBI- connect_on_init( dbi:Oracle:SID , login1 , pass1 ,{ PrintError =
              Message 6 of 6 , Oct 27, 2005
              View Source
              • 0 Attachment
                I use prefork mpm
                The connection string in a startup script of each site is
                Apache::DBI->connect_on_init("dbi:Oracle:SID", "login1", "pass1",{
                PrintError => 0,AutoCommit => 0 });
                I change only login and password for different sites. So 5 different
                connection strings

                Interesting thing - raising the MaxClients value make the site work
                better, it doesn't hang, and I don't see errors on web pages, though it
                seems that amount of mistakes doesn't become smaller.

                Geoffrey Young wrote:

                >>>Apache::DBI will cache connections on a per-connection-string basis,
                >>>once in
                >>>each child process. so, if each connection to a database is made using a
                >>>different username each will be cached and you'll end up with
                >>>users*processes number of cached connections in total.
                >>>
                >>>
                >
                >
                >
                >>The problem is that connection number is greater than users*processes! I
                >>have 5 db users(one for each of five sites) and MaxClients = 90 but the
                >>connection count can reach 500 limit easily on workload peaks and is
                >>willing to grow further! This sites are very heavyloaded indeed.
                >>I use Apache 2, mp2.0.1 and Apache::DBI -0.9901
                >>
                >>
                >
                >are you using the worker or prefork mpm? are you certain that your connect
                >string is identical in each case (and that means identical - same AutoCommit
                >settings, same user/pass, same _everything_)?
                >
                >--Geoff
                >
                >
                >
              Your message has been successfully submitted and would be delivered to recipients shortly.