Your question is not about web2py but about the rocket web server. Things
work differently for different web servers.
With rocket, it creates a fixed number of threads and when a request
arrives it is assigned to one of the available threads or a new thread is
created t the request is queued. The number of thread has a minimum (to
avoid the overhead of creating new threads when a new request arrives) and
a maximum (to prevent DoS attacks).
These parameters can be specified with'
$ python web2py.py -h
....
--minthreads=MINTHREADS
minimum number of server threads
--maxthreads=MAXTHREADS
maximum number of server threads
...
minthreads defaults to 10
maxthreads defaults to 0 (which means no maximum, they will be created as
necessary and deleted when not necessary).
On Tuesday, 18 December 2012 05:54:11 UTC-6, Daniel Gonzalez wrote:
>
> Hi,
>
> How are threads managed in web2py? I am stress testing with a
> multithreaded programm, and I see that web2py spawns 14 "worker threads".
> These threads are not created/destroyed, but seem to run forever.
>
> python,8698 web2py.py -a aaaa
> |-{python},9005
> |-{python},9023
> |-{python},9042
> |-{python},9043
> |-{python},9044
> |-{python},9050
> |-{python},9051
> |-{python},9053
> |-{python},9054
> |-{python},9055
> |-{python},9057
> |-{python},9058
> |-{python},9059
> `-{python},9060
>
> I have several questions:
>
> - How do these threads map to the requests? Does each thread serve a
> request?
> - That means web2py can maximally cope with 14 parallel requests?
> - Is this number (14) configurable?
> - Are the objects defined in the models initialized at thread
> creation, and then reused for all requests?
>
> Thanks,
>
> Daniel
>
--