Re: [Cppcms-users] How can I limit the total maximum number of synchronous application object in th
Brought to you by:
artyom-beilis
|
From: Artyom B. <art...@ya...> - 2014-03-05 07:19:22
|
No there is no such method. It works this way. When the request comes to the cppcms service event loop it does all its handling (i.e. preparing get/post data, parsing). When it is ready, it requests a relevant application from the pool and sends it to the thread pool for handling. So if there are many connections than many applications would be created and of course if there is a peak many more would be created and than released after a peak passes Now about DB connection... What SQL connector are you using? If you are using cppdb I'd recommend to use its internal connection pooling instead of keeping the connection withing the application itself. Now each time you need an sql connection you just create a cppdb::session with connection string and the connection would be fetched from a pool. What is more important it would close a connections that are out of use for a long time. One of the problems of keeping an open SQL connection withing a application is that an application can be idle for a long time. One of such cases is for example not using a connection at all because data is fetched from a cache (some real problem I used to had when I used connection-per-application approach) Another problem that in case of errors you need to be able to close connection and not use it any more (i.e. reopen). CppDB does this for you. Connection that received errors on it wouldn't go back to pool. I hope this helps. Also having better application pool implementation with more fine grained tuning is something that would be nice to have + some generic "object" pooling for any type of objects would be good thing as well. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ -------------------------------------------- On Thu, 2/13/14, Jean-Frédéric Gaudreault <jfg...@gm...> wrote: Subject: [Cppcms-users] How can I limit the total maximum number of synchronous application object in the pool at any given time... To: cpp...@li... Date: Thursday, February 13, 2014, 6:27 PM Thanks a lot for creating CppCms, it is a wonderful framework. I made a simple project, with a synchronous application pool (like hello_world), and I was hoping I could create a DB connection inside each application object and keep it cached for reusing. Now, I am using the configuration service.applications_pool_size to set my pool size, but it seems this configuration is only for the number the maximum number of app object to cache, it does not limit the maximum number of objects created at any time. For instance, I have set the service.applications_pool_size to 24, and if I run a load test and increase the number of concurrent requests, I am able to go over 24 app objects. In fact I don't really see a limit easily, it would go over 200 app objects living at any time (in my case this translates to 200 DB connections), as long as I am hitting the service with over 200 concurrent requests. Even if I play with the worker_thread config it does not seem to limit in any way the max number of app objects. Once I stop my load test, I will see the number of app objects/db connections go back to the service.applications_pool_size I have configured. Is there any way to really limit the app pool size so that it will only go up to a maximum setting configured? Under heavy load, once this limit is reached, it should queue the requests and dispatch them at the next available application object. Also, I am using nginx with my cppcms app configured as fastcgi. I tried to see if I could limit the concurrent requests in nginx to queue them but could not find how or if this is possible. Overall, I find that being able to control the maximum number of app objects is important, in order to properly manage the memory and CPU resources used under heavy load. Also, please let me know if I'm missing something, I am just starting with cppcms but I find great potential. Thanks, Jeff -----Inline Attachment Follows----- ------------------------------------------------------------------------------ Android apps run on BlackBerry 10 Introducing the new BlackBerry 10.2.1 Runtime for Android apps. Now with support for Jelly Bean, Bluetooth, Mapview and more. Get your Android app in front of a whole new audience. Start now. http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk -----Inline Attachment Follows----- _______________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |