[Klone-users] threading
Stefano Barbato
barbato at koanlogic.com
Thu Nov 1 16:07:22 EDT 2007
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
More information about the klone-users
mailing list