I just palying around with Rails,it is co cool! but I found there is only one database connection to my MySQL server during the whole application life, Is single one connection enough? in PHP,every request opens a connection or a PConnect for a session of requests, and in JAVA,there will be a "connection pool" holding some connections, what is the solution in Rails? i am new,so pls... _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
> I just palying around with Rails,it is co cool! > but I found there is only one database connection to my MySQL server > during the whole application life, > Is single one connection enough?There''s one connection per process. When you''re getting ready to scale, you''ll jump to FastCGI that holds persistent connections to the database. That''ll likely lead you to have 10-15 processes on a single machine and hence also 10-15 connections to the database. -- David Heinemeier Hansson, http://www.basecamphq.com/ -- Web-based Project Management http://www.rubyonrails.org/ -- Web-application framework for Ruby http://www.loudthinking.com/ -- Broadcasting Brain
thank you,David. i am now using FastCGI, where to setup the connections? On 4/13/05, David Heinemeier Hansson <david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org> wrote:> > I just palying around with Rails,it is co cool! > > but I found there is only one database connection to my MySQL server > > during the whole application life, > > Is single one connection enough? > > There''s one connection per process. When you''re getting ready to scale, > you''ll jump to FastCGI that holds persistent connections to the > database. That''ll likely lead you to have 10-15 processes on a single > machine and hence also 10-15 connections to the database. > -- > David Heinemeier Hansson, > http://www.basecamphq.com/ -- Web-based Project Management > http://www.rubyonrails.org/ -- Web-application framework for Ruby > http://www.loudthinking.com/ -- Broadcasting Brain > >
develop-U23jnKMpDSxBDgjK7y7TUQ@public.gmane.org
2005-Apr-13 13:35 UTC
Re: only one database connection?!
Hui, You don''t setup the connections. FastCGI will just grow with you as they are needed. As long as you only have a single concurrent connection running at a time - then a single connection is all you need. If you start having multiple simultaneous connections - the additional connections will automatically get setup as the system deems them necessary. It''s a win-win - no more connections used then needed but grown as required. John W Higgins develop-U23jnKMpDSxBDgjK7y7TUQ@public.gmane.org Quoting hui <fortez-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> thank you,David. > > i am now using FastCGI, > where to setup the connections? > > On 4/13/05, David Heinemeier Hansson <david-OiTZALl8rpK0mm7Ywyx6yg@public.gmane.org> wrote: > > > I just palying around with Rails,it is co cool! > > > but I found there is only one database connection to my MySQL server > > > during the whole application life, > > > Is single one connection enough? > > > > There''s one connection per process. When you''re getting ready to scale, > > you''ll jump to FastCGI that holds persistent connections to the > > database. That''ll likely lead you to have 10-15 processes on a single > > machine and hence also 10-15 connections to the database. > > -- > > David Heinemeier Hansson, > > http://www.basecamphq.com/ -- Web-based Project Management > > http://www.rubyonrails.org/ -- Web-application framework for Ruby > > http://www.loudthinking.com/ -- Broadcasting Brain > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program.
> > You don''t setup the connections. FastCGI will just grow with you > as they are > needed. As long as you only have a single concurrent connection > running at a > time - then a single connection is all you need. If you start > having multiple > simultaneous connections - the additional connections will > automatically get > setup as the system deems them necessary. > > It''s a win-win - no more connections used then needed but grown > as required.Is there a max number of connections FastCGI will grow it''s pool to? Is it configurable or hardcoded? Steve
configurable. See FastCgiServer in the fastcgi docs On 4/13/05, Steve V <ruby-ChEX1j9zMF7JbC0vcoRRxNBPR1lH4CV8@public.gmane.org> wrote:> > > > You don''t setup the connections. FastCGI will just grow with you > > as they are > > needed. As long as you only have a single concurrent connection > > running at a > > time - then a single connection is all you need. If you start > > having multiple > > simultaneous connections - the additional connections will > > automatically get > > setup as the system deems them necessary. > > > > It''s a win-win - no more connections used then needed but grown > > as required. > > Is there a max number of connections FastCGI will grow it''s pool to? Is it > configurable or hardcoded? > > Steve > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog
On 13.4.2005, at 20:15, Steve V wrote:> > Is there a max number of connections FastCGI will grow it''s pool to? > Is it > configurable or hardcoded?Here''s an example from a lighttpd config file: fastcgi.server = ( ".fcgi" => ( "localhost" => ( "min-procs" => 5, "max-procs" => 5, "socket" => "/tmp/aaltonen.fcgi.socket", "bin-path" => "/Users/jarkko/Sites/aaltonen/public/dispatch.fcgi", "bin-environment" => ( "RAILS_ENV" => "development" ) ) ) ) AFAIK, min-procs and max-procs are the minimum and maximum number of fcgi processes that will be kept running simultaneously. Each of them then holds a db connection of its own. //jarkko> > Steve > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails