Jens Carroll
2007-Mar-13 11:18 UTC
[Mongrel] Mongrel cluster with one app and many mysql databases
Hi All, I am new to the mongrel mailing list and I have a question (and I didn''t find any answer in the archives). I have successfully installed the apache2.2 proxy balancer with mongrel cluster and that works just fine. For a single rails app I have started 2 mongrels which consume about 100M (ps says 5.0% for each and I have 1G RAM). It seems a bit much but OK. However that would imply that I can have only another 6-8 apps before I need to upgrade RAM on my server. In fact I only have one appl (e.g. radiant) but I want to serve many of them with different mysql databases. So I am asking why not fire-up 10 mongrels and convince mongrel (or the app) to switch databases on request (maybe with the rails routing facilities) Any ideas or pointers? The mongrel cluster thingy is really great! I love it! Good job boyz. TIA Jens
Alexey Verkhovsky
2007-Mar-13 12:02 UTC
[Mongrel] Mongrel cluster with one app and many mysql databases
> convince mongrel (or the app) to switch databases on request (maybe withthe rails routing facilities) 10 databases with the same structure but different data? This is doable. You''d have to hack it yourself, probably by replacing ActiveRecord:: Base.connection with something that will internally hold 10 connections and switch dynamically. None of will have anything to do with Mongrel though. Mongrel is not a J2EE container, it has no notion of database connections. Alex -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070313/34d56452/attachment.html
Jens Carroll
2007-Mar-13 13:15 UTC
[Mongrel] Mongrel cluster with one app and many mysql databases
Thanks Alexey, I got also more and more to the point where it is clearly not a mongrel problem. Thanks for the answer, but if someone has done that before I would really appreciate any pointer. Jens Alexey Verkhovsky schrieb:>> convince mongrel (or the app) to switch databases on request (maybe > with the rails routing facilities) > > 10 databases with the same structure but different data? This is doable. > You''d have to hack it yourself, probably by replacing ActiveRecord:: > Base.connection with something that will internally hold 10 connections > and switch dynamically. > > None of will have anything to do with Mongrel though. Mongrel is not a > J2EE container, it has no notion of database connections. > > Alex > > > ------------------------------------------------------------------------ > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users
Steve Midgley
2007-Mar-13 17:00 UTC
[Mongrel] Mongrel cluster with one app and many mysql databases
Hi, This is getting a little OT but I think you can easily switch your database connections by playing with which environment you''re running in when the rails system starts up. This doesn''t get you all the way to your solution but should point out the line of code you''ll want to investigate. For example, if you were to start up 10 scratch Rails instances and had 10 entries in your database.yml file, one for each configuration, you could load 10 different db instances: for each one you would provide a different "RAILS_ENV" environment variable (corresponding to the appropriate entry in database.yml). Then you''d be running 10 different production instances with 10 dif. connections. What you want is a little trickier b/c you want to switch db instances on the fly with a single instance of Rails. But I still don''t think this is going to be too difficult. For example, it''s possible access an alternate database configuration entry with this line of code in the environment.rb file: config.database_configuration["development"]["database"] How and where to make the switch in an active running Rails server, I don''t know, but it looks very plausible. I hope this helps get you started, Steve At 09:46 AM 3/13/2007, mongrel-users-request at rubyforge.org wrote:>Message: 7 >Date: Tue, 13 Mar 2007 14:15:40 +0100 >From: Jens Carroll <jens.carroll at carroll.de> >Subject: Re: [Mongrel] Mongrel cluster with one app and many mysql > databases >To: mongrel-users at rubyforge.org >Message-ID: <45F6A3FC.4050605 at carroll.de> >Content-Type: text/plain; charset=ISO-8859-1 > >Thanks Alexey, > >I got also more and more to the point where it is clearly not a >mongrel >problem. > >Thanks for the answer, but if someone has done that before I would >really appreciate any pointer. > >Jens > >Alexey Verkhovsky schrieb: > >> convince mongrel (or the app) to switch databases on request > (maybe > > with the rails routing facilities) > > > > 10 databases with the same structure but different data? This is > doable. > > You''d have to hack it yourself, probably by replacing > ActiveRecord:: > > Base.connection with something that will internally hold 10 > connections > > and switch dynamically. > > > > None of will have anything to do with Mongrel though. Mongrel is > not a > > J2EE container, it has no notion of database connections. > > > > Alex-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070313/a4aebad3/attachment.html
Jim Hogue
2007-Mar-13 19:27 UTC
[Mongrel] Mongrel cluster with one app and many mysql databases
I just got a copy of "Rails Recipes" and I see in the index 15. Connecting to Multiple Databases I literally just got the book, so I can''t give you any details, but this might help get you to a solution. Note that the OT comment is probably correct as it is Rails, not Mongrel that deals with the database. You may want to try the Rails mailing list archives. - Jim ----- Original Message ----- From: "Steve Midgley" <public at misuse.org> To: <mongrel-users at rubyforge.org> Sent: Tuesday, March 13, 2007 1:00 PM Subject: Re: [Mongrel] Mongrel cluster with one app and many mysql databases> Hi, > > This is getting a little OT but I think you can easily switch your > database connections by playing with which environment you''re > running > in when the rails system starts up. This doesn''t get you all the way > to > your solution but should point out the line of code you''ll want to > investigate. > > For example, if you were to start up 10 scratch Rails instances and > had > 10 entries in your database.yml file, one for each configuration, > you > could load 10 different db instances: for each one you would provide > a > different "RAILS_ENV" environment variable (corresponding to the > appropriate entry in database.yml). Then you''d be running 10 > different > production instances with 10 dif. connections. > > What you want is a little trickier b/c you want to switch db > instances > on the fly with a single instance of Rails. But I still don''t think > this is going to be too difficult. For example, it''s possible access > an > alternate database configuration entry with this line of code in the > environment.rb file: > > config.database_configuration["development"]["database"] > > How and where to make the switch in an active running Rails server, > I > don''t know, but it looks very plausible. > > I hope this helps get you started, > > Steve > > > At 09:46 AM 3/13/2007, mongrel-users-request at rubyforge.org wrote: >>Message: 7 >>Date: Tue, 13 Mar 2007 14:15:40 +0100 >>From: Jens Carroll <jens.carroll at carroll.de> >>Subject: Re: [Mongrel] Mongrel cluster with one app and many mysql >> databases >>To: mongrel-users at rubyforge.org >>Message-ID: <45F6A3FC.4050605 at carroll.de> >>Content-Type: text/plain; charset=ISO-8859-1 >> >>Thanks Alexey, >> >>I got also more and more to the point where it is clearly not a >>mongrel >>problem. >> >>Thanks for the answer, but if someone has done that before I would >>really appreciate any pointer. >> >>Jens >> >>Alexey Verkhovsky schrieb: >> >> convince mongrel (or the app) to switch databases on request >> (maybe >> > with the rails routing facilities) >> > >> > 10 databases with the same structure but different data? This is >> doable. >> > You''d have to hack it yourself, probably by replacing >> ActiveRecord:: >> > Base.connection with something that will internally hold 10 >> connections >> > and switch dynamically. >> > >> > None of will have anything to do with Mongrel though. Mongrel is >> not a >> > J2EE container, it has no notion of database connections. >> > >> > Alex >--------------------------------------------------------------------------------> _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users
Jens Carroll
2007-Mar-14 14:51 UTC
[Mongrel] Mongrel cluster with one app and many mysql databases
Thanks guys! That should keep me busy. Have fun Jens Jim Hogue schrieb:> I just got a copy of "Rails Recipes" and I see in the index > > 15. Connecting to Multiple Databases > > I literally just got the book, so I can''t give you any details, but > this might help get you to a solution. > > Note that the OT comment is probably correct as it is Rails, not > Mongrel that deals with the database. You may want to try the Rails > mailing list archives. > > - Jim > > ----- Original Message ----- > From: "Steve Midgley" <public at misuse.org> > To: <mongrel-users at rubyforge.org> > Sent: Tuesday, March 13, 2007 1:00 PM > Subject: Re: [Mongrel] Mongrel cluster with one app and many mysql > databases > > >> Hi, >> >> This is getting a little OT but I think you can easily switch your >> database connections by playing with which environment you''re >> running >> in when the rails system starts up. This doesn''t get you all the way >> to >> your solution but should point out the line of code you''ll want to >> investigate. >> >> For example, if you were to start up 10 scratch Rails instances and >> had >> 10 entries in your database.yml file, one for each configuration, >> you >> could load 10 different db instances: for each one you would provide >> a >> different "RAILS_ENV" environment variable (corresponding to the >> appropriate entry in database.yml). Then you''d be running 10 >> different >> production instances with 10 dif. connections. >> >> What you want is a little trickier b/c you want to switch db >> instances >> on the fly with a single instance of Rails. But I still don''t think >> this is going to be too difficult. For example, it''s possible access >> an >> alternate database configuration entry with this line of code in the >> environment.rb file: >> >> config.database_configuration["development"]["database"] >> >> How and where to make the switch in an active running Rails server, >> I >> don''t know, but it looks very plausible. >> >> I hope this helps get you started, >> >> Steve >> >> >> At 09:46 AM 3/13/2007, mongrel-users-request at rubyforge.org wrote: >>> Message: 7 >>> Date: Tue, 13 Mar 2007 14:15:40 +0100 >>> From: Jens Carroll <jens.carroll at carroll.de> >>> Subject: Re: [Mongrel] Mongrel cluster with one app and many mysql >>> databases >>> To: mongrel-users at rubyforge.org >>> Message-ID: <45F6A3FC.4050605 at carroll.de> >>> Content-Type: text/plain; charset=ISO-8859-1 >>> >>> Thanks Alexey, >>> >>> I got also more and more to the point where it is clearly not a >>> mongrel >>> problem. >>> >>> Thanks for the answer, but if someone has done that before I would >>> really appreciate any pointer. >>> >>> Jens >>> >>> Alexey Verkhovsky schrieb: >>>>> convince mongrel (or the app) to switch databases on request >>> (maybe >>>> with the rails routing facilities) >>>> >>>> 10 databases with the same structure but different data? This is >>> doable. >>>> You''d have to hack it yourself, probably by replacing >>> ActiveRecord:: >>>> Base.connection with something that will internally hold 10 >>> connections >>>> and switch dynamically. >>>> >>>> None of will have anything to do with Mongrel though. Mongrel is >>> not a >>>> J2EE container, it has no notion of database connections. >>>> >>>> Alex > > > -------------------------------------------------------------------------------- > > >> _______________________________________________ >> Mongrel-users mailing list >> Mongrel-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/mongrel-users > > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users >-- Carroll Engineering Dipl.-Ing. Jens Carroll Neuk?llnerstr. 2 D-71229 Leonberg, Germany Phone: +49 (0)7152 929053 FAX: +49 (0)7152 929054