> 1. Sequel provides thread safety, connection pooling.. > How can I test and verify that connection pooling is working?
svn co http://assistance.rubyforge.org/svn/trunk assistance cd assistance spec spec/connection_pool_spec.rb > 2. When and where should I open a connection to the db? You should only open a single database instance for each actual database you're using. Once you start accessing that database instance from multiple threads, the connection pooling is done automatically without any intervention on your part. > What is the impact if I have several model files and each file begins > with a database connection? Though you can associate a model class with a specific table in any open database, models are by default associated with the first database that was opened. It's better that you open a database instance only once upon initialization. > Is it advisable for me to place this db connection in start.rb (for > ramaze)? yes. > Is this connection to the db persistent, in the sense that it exists > for as long as start.rb is running > and that this single connection will handle all user requests (with > connection pooling)? yes. some adapters like postgresql or mysql also automatically renew the connection if it is lost. > If so, the connection would be left idle when no query is made to the > db? yes. you can also manually close all active connections by calling Database#close. The connection will be automatically reestablished once you start doing database work again. > Or is this connection duplicated when another user accesses the web > app? that depends on how your web app is made. the connection pool guarantees ownership of a connection for each thread that needs it, so if you have multi-threaded web app that treats each incoming request using a separate thread, each thread will use its own connection from the connection pool. the connection pool has a maximum size defined (which you can control), so if more requests are made than there are connections avaliable, the requests will be blocked until a connection becomes available. sharon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to sequel-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---