Re: [Cppcms-users] DB connection pooling
Brought to you by:
artyom-beilis
From: Shiv S. D. <shi...@gm...> - 2012-10-23 18:14:44
|
Hi, Is it simple to do write a backend driver based on what is available for Hypertable? On Tue, Oct 23, 2012 at 10:19 PM, Artyom Beilis <art...@ya...> wrote: > Using cppdb you only need to add a small parameter to connection string > to enable connection pooling. > It would automatically use a pool withing a special singleton. > > Usually you don't need to use the pool class directly. > > Artyom Beilis > -------------- > CppCMS - C++ Web Framework: http://cppcms.com/ > CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ > > ------------------------------ > *From:* Lee Elenbaas <lee...@gm...> > *To:* cpp...@li... > *Sent:* Tuesday, October 23, 2012 5:33 PM > *Subject:* Re: [Cppcms-users] DB connection pooling > > I have not used cppDB yet - aside from some testing - but if you look at > its API, it comes with a pool class, > > just hold an instance of that pool in your app, and use it whenever you > need a connection > you can pass a shared_ptr around for it - or just store it in a single > place. > > but this is not part of the cppcms framework itself, and i have no idea > how the pool will handle multiple threads requesting a connection at the > same time - perhaps Artyom could answer that > > On Mon, Oct 22, 2012 at 3:47 PM, Shiv Shankar Dayal < > shi...@gm...> wrote: > > Agreed. So where do I put my DB connection pool? As mentioned in > documentation "The CppCMS service has a simple design of a single event > loop and a thread pool that handles actual user application responses." > this means on outer side there is an event-based design and internally > there is a thread pool. Therefore I draw a conclusion that I need a thread > based pool and once the application is mounted and a factory object is > created right where I hit first db query I should use one connection from > pool. > > > On Mon, Oct 22, 2012 at 6:30 PM, Lee Elenbaas <lee...@gm...>wrote: > > I fail to see the connection between the application being asynchronious > and the DB connections being pooled > > if you need to do several things with the same DB at the same time (or > simply in different threads) > you need several DB connections - you can choose to pool them - and this > way reuse them > > both synchronious and asynchronious applications can handle multiple > threads - so both need some way of using db connections - and a pool is one > good way to do that > > On Mon, Oct 22, 2012 at 2:22 PM, Shiv Shankar Dayal < > shi...@gm...> wrote: > > Hi, > Consider the following piece of documentation > If the application that handles it is a synchronous application, its > execution is passed to the *thread pool*. The user application prepares > the response and sends it synchronously to the client and the context is > destroyed, completing the "requst/response" cycle. > If the application is asynchronous, the HTTP Context remains inside the > event loop's thread and it is handled by the asynchronous application. This > application may decide to complete the response immediately or postpone it > by implementing, for example, long polling. > and following code > > 1. int main(int argc,char ** argv) > 2. { > 3. try { > 4. cppcms::service srv(argc,argv); > 5. srv.applications_pool().mount( > 6. cppcms::applications_factory<hello>() > 7. ); > > now as it is also written that applications are asynchronous what is the > need of more that one database connection. Is it the case that one > persistent connection will suffice? > -- > Best regards, > Shiv Shankar Dayal > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > -- > -- > lee > Lee Elenbaas > lee...@gm... > > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > -- > Best regards, > Shiv Shankar Dayal > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > -- > -- > lee > Lee Elenbaas > lee...@gm... > > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > > > ------------------------------------------------------------------------------ > Everyone hates slow websites. So do we. > Make your web apps faster with AppDynamics > Download AppDynamics Lite for free today: > http://p.sf.net/sfu/appdyn_sfd2d_oct > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > -- Best regards, Shiv Shankar Dayal |