Re: [Cppcms-users] Multiprocesses and cppcms_scale
Brought to you by:
artyom-beilis
From: Artyom B. <art...@ya...> - 2012-04-07 08:00:10
|
Absolutely right. Small additional notes: > I believe some situation, ppl use multiple > processes with only one thread, is because > implementation is not thread safe, yet multiple processes still fast. It is rather to make the application more crash resistant, such that if one process fails only several connections are gone. Also having multiple processes allows to have several event loops simultaneously and this may be helpful on multi-core systems in some load cases. > When run in multiple worker processes mode on single machine, > we need to use session.server.storage:"files", since "memory" > only works for single process and "network" will need to > use cppcms_scale. > The best way to scale sessions is to use client side storage, as it is 100% linearly scalable as does not involve central server (it has its own downsides) In any way, memory session storage is good mostly for development as if process shuts down all the sessions data is lost, so for server side storage files is generally better option and you can even use NFS to store session data across multiple cppcms instances. You can also use database for session storage (see contrib) section in the source code. In such case, if for example you use PostgreSQL or MySQL server for session storage you do not need to use cppcms_scale and it is already centralized. ---- Also I forget to add "external" session storage to configuration file description, such that you can use external session storage objects loaded from shared objects / dlls . I'll update the wiki later. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: william lee <we...@gm...> >To: Artyom Beilis <art...@ya...>; cpp...@li... >Sent: Saturday, April 7, 2012 6:29 AM >Subject: Re: [Cppcms-users] Multiprocesses and cppcms_scale > > >Hi Artyom, >Thank you for your kindly explanations. >It looks like I missed a lot of points from CppCMS Config wiki page. > > >Here are my conclusions, please correct me if I'm wrong. >1. cppcms_scale >After I start cppcms_scale by following cppcms_tcp_scale's doc, then config CppCMS instances to use cache.tcp.ips & session.server.ips, pointing to cppcms_scale machine, they should be able to scale up the distribution. >cppcms_scale is asynchronous application, so only one process is enough, with possible multi-threads to gain more performance on multiple core(cpu) machines. >If one cppcms_scale server is not enough, we can have several, but the cache.tcp.ips & session.server.ips should be identical to all CppCMS instances configuration, including the list order of cppcms_scale machine IPs, >I assume CppCMS instance will use this IP list with order, to hash the session bucket? > > >2. Multiple Processes >CppCMS support multiple processes with multiple threads, MS Windows only multiple threads. :) >When running on a single machine, multiple worker processes can use shared memory to store the cache, no need cppcms_scale to be involved. This can be done via cache.backend:"process_shared" configuration. This is also non-Windows. > > >I believe some situation, ppl use multiple processes with only one thread, is because implementation is not thread safe, yet multiple processes still fast. > > >When run in multiple worker processes mode on single machine, we need to use session.server.storage:"files", since "memory" only works for single process and "network" will need to use cppcms_scale. > > >And also, we can use "network" for multiple worker processes mode and running on several machines, so they will all point to cppcms_scale servers for consistent cache & session. > > >Thanks! >William L. > > > > >On Sat, Apr 7, 2012 at 5:34 AM, Artyom Beilis <art...@ya...> wrote: > > >> >> >>> >>>1. cppcms_scale >>> Here in this page, it mentioned "cppcms_scale" >>> http://cppcms.com/wikipp/en/page/cppcms_1x_high_performance >>> and I found the built binary cppcms_scale.exe as well. >>> It is supposed to provide triggered cache, and cross process session support? I can't any wiki page talking about its usage. >>> I found here is something about "cppcms_tcp_scale" >>> http://cppcms.com/wikipp/en/page/ref_utils >>> Are they the same thing? It would be great if can have a page/sample talking more about how to scale up. Thanks. >>> >> >>Yes, >> >>cppcms_scale allows to shared both cache and sessions over the network similarly to memcached. >> >>See: >> >>http://cppcms.com/wikipp/en/page/cppcms_1x_config#cache.tcp >>http://cppcms.com/wikipp/en/page/cppcms_1x_config#session.server.storage >> >> >>This way multiple cppcms services can share the cache and sessions over the network. >> >> >> >>> >>>2. Multi-Processes >>>Here in this page, http://cppcms.com/wikipp/en/page/tut_concept it mentioned CppCMS can have a pool of threads or processes. >>>But here when configure with web servers, http://cppcms.com/wikipp/en/page/cppcms_1x_tut_web_server_config#Configuring.Other.Web.Servers >>>document mentioned "be sure it starts only a single process". Otherwise the cache & session will be messed up, due to not cross process. >>>Is this the problem cppcms_scale targeted to solve ? >> >>Yes and no. Generally running CppCMS as a single service instance is good as it allows >>to handle cache withing the same process. Sometimes web server is not >> >>aware of the fact that the FastCGI server is multi-threaded and would start >>multiple instances and this is wrong. >> >> >>And yes cppcms_scale can solve it but generally it is better not to use cppcms_scale >>as long as you running the application on a single server. >> >> >> >>> If true, how can we configure CppCMS >> >>> with modern web servers, to run as multiple >>> processes and multiple threads, in fastcgi env? >>> >>> >> >>CppCMS handles both thread and process pool >> >> >>http://cppcms.com/wikipp/en/page/cppcms_1x_config#service.worker_threads >> >>This allows the process to share for example the cache using shared >>memory and not IPC. However if you scale to multiple network >>nodes you do need cppcms_scale for cache. >> >> >>Small note: under Windows CppCMS supports only multiple threads pool and can't >>fork multiple processes (as Windows does not have fork() system call) >> >>So if you do want to run multiple CppCMS processes under Windows >>you need to start them independently and use cppcms_scale to >>solve cache consistency issues >> >> >> >>>Thanks for the great work! I'd like to use CppCMS in my production environment soon. >>> >>> >>>Cheers, >>>William L. >> >>Regards, >> >>I'd be glad to hear about it. >>Artyom >> >>------------------------------------------------------------------------------ >>For Developers, A Lot Can Happen In A Second. >>Boundary is the first to Know...and Tell You. >>Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! >>http://p.sf.net/sfu/Boundary-d2dvs2 >>_______________________________________________ >>Cppcms-users mailing list >>Cpp...@li... >>https://lists.sourceforge.net/lists/listinfo/cppcms-users >> > >------------------------------------------------------------------------------ >For Developers, A Lot Can Happen In A Second. >Boundary is the first to Know...and Tell You. >Monitor Your Applications in Ultra-Fine Resolution. Try it FREE! >http://p.sf.net/sfu/Boundary-d2dvs2 >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |