[Klone-users] threading

Robert Finking finking at ntlworld.com
Fri Nov 2 09:57:42 EDT 2007


Hi Stefano,

Brilliant - this is ideal. The tip about MinGW to avoid the need for 
shipping 3rd party libraries with the app is very useful.

You guys really have something great here. I was going to start cooking 
up the web interface from scratch till I found Klone!

Thanks again for the support

Robert Finking

Stefano Barbato wrote:

> Hi Robert,
>
> On Nov 1, 2007, at 8:19 PM, Robert Finking wrote:
>
>> Hi,
>>
>> Is it possible to configure the server to be single threaded? I wrote 
>> a simple page with a static int in it and incremented it on each 
>> view. In the browser the value displayed went 0, 1, 2, 3, 4, 0 ,5, 1, 
>> 6, 2, 7 etc. which I guess means separate threads are running.
>>
>> My plan is to use the server as the front end to an event driven 
>> application, so spawning separate threads each time will mean having 
>> to have the entire app run in another separate thread and then 
>> communicate with the webserver over sockets or something, which I'd 
>> like to avoid if poss.
>>
>> So, is it possible to run the server single threaded? Alternatively 
>> do you have other ways around this?
>>
>> Thanks again for your rapid response to my previous question.
>>
>> Regards
>>
>> Robert Finking
>
>
> Yes, it's possible.
>
> KLone supports three server models: prefork (default), fork and 
> iterative.
>
> In "prefork" mode a few processes (not threads, klone never use 
> multi-threading) are spawn at startup to serve client requests; each 
> process continuosly pops a request (if any) from the list of pending 
> HTTP connections and fulfills it. If you care about performance 
> prefork model is what you should choose.
>
> When using "fork" model KLone spawns a new process for each new client 
> request.  Choosing fork model makes sense just if you want to save 
> resources for very low traffic web applications and when performance 
> is not an issue.
>
> There's a third model called "iterative" that uses a single process 
> (single thread) to serve all connections. This is what you could use 
> for your project.
> Note that in iterative mode just one request at a time is served and 
> multiple concurrent connections are not possible.
>
> To switch to iterative model set the "model" key in the config file 
> (webapp/etc/kloned.conf) and restart kloned:
>
> -------------------------
> server_list    app_http
>
>   [...]
>
> app_http
> {
>     type            http
>     model           iterative   ##### <--- here
>
>     addr.type       IPv4
>     addr.port       8080
>     dir_root        /www
> }
> --------------------------
>
> A side note:
>
> if you don't need the prefork server model MinGW is a better choice 
> because it produces a smaller executable that doesn't depend on any 
> external library while with Cygwin you must distribute the cygwin1 DLL 
> or install the whole framework on any machine that runs the kloned.exe 
> daemon.
>
> bye,
> stefano
>
>
>
> _______________________________________________
> Klone-users mailing list
> Klone-users at koanlogic.com
> http://koanlogic.com/cgi-bin/mailman/listinfo/klone-users
>



More information about the klone-users mailing list