Discussion:
multi core machines using lighttpd
n***@gmail.com
2010-07-16 22:51:11 UTC
Permalink
Hi all,

I am using web.py with cgi and lighttpd.

Is this configuration by default limited to 1 core?

Is there a way to allow multiple user connections to be handled in
parallel?

I have currently set the lighttpd config value as such: "max-procs" =>
1

Not sure if increasing the value will allow concurrency.

Cheers,
Ivan Novick
Anand Chitipothu
2010-07-18 16:59:40 UTC
Permalink
Post by n***@gmail.com
Hi all,
I am using web.py with cgi and lighttpd.
Is this configuration by default limited to 1 core?
Is there a way to allow multiple user connections to be handled in
parallel?
I have currently set the lighttpd config value as such: "max-procs" =>
1
Not sure if increasing the value will allow concurrency.
Are you using lighttpd+cgi or lighttpd+fastcgi?
n***@gmail.com
2010-07-27 20:05:37 UTC
Permalink
Post by Anand Chitipothu
Post by n***@gmail.com
Hi all,
I am using web.py with cgi and lighttpd.
Is this configuration by default limited to 1 core?
Is there a way to allow multiple user connections to be handled in
parallel?
I have currently set the lighttpd config value as such: "max-procs" =>
1
Not sure if increasing the value will allow concurrency.
Are you using lighttpd+cgi or lighttpd+fastcgi?
fastcgi
--
You received this message because you are subscribed to the Google Groups "web.py" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to webpy+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
n***@gmail.com
2010-07-27 20:54:54 UTC
Permalink
The other related questions is:

If using fastgi with lighttpd and "max-procs" = 1

Is a different python thread created for each concurrent session?

Cheers,
Ivan
Justin Davis
2010-07-27 22:33:41 UTC
Permalink
If you increase the max-procs, you will spawn (at most) that many
python processes. Note that these aren't threads, but separate
processes, so you need to be sure that any state within a given
application isn't necessary. For instance, if you maintain a global
dict of logged in users, this will break in the multiprocess
deployment.

webpy applications are multithreaded however, so multiple connections
will be processed simultaneously. However, due to the way python
implements threading (specifically, the GIL), it's uncommon for python
threads to really take advantage of multicore architectures. If you
have several cores and have written the program correctly, upping the
max-procs variable will help you get more throughput.

Good luck,
Justin
If using fastgi with lighttpd and  "max-procs" = 1
Is a different python thread created for each concurrent session?
Cheers,
Ivan
--
You received this message because you are subscribed to the Google Groups "web.py" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to webpy+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
n***@gmail.com
2010-07-27 22:47:03 UTC
Permalink
Post by Justin Davis
If you increase the max-procs, you will spawn (at most) that many
python processes. Note that these aren't threads, but separate
processes, so you need to be sure that any state within a given
application isn't necessary. For instance, if you maintain a global
dict of logged in users, this will break in the multiprocess
deployment.
webpy applications are multithreaded however, so multiple connections
will be processed simultaneously. However, due to the way python
implements threading (specifically, the GIL), it's uncommon for python
threads to really take advantage of multicore architectures. If you
have several cores and have written the program correctly, upping the
max-procs variable will help you get more throughput.
Good luck,
Justin
Thanks Justin!

Having read your reply and digging deeper it seems the Session object
is a ThreadedDict and HttpServer uses ThreadingMixIn

I am assuming (hoping) what this means is that each web request is
handled on a new python thread and that the incoming request will have
the session data of its matching session associated with the new
thread.

Also that any variables defined globally (outside of the session) can
be shared by all threads. Like in your example: a global dictionary
of logged in users. (assuming max-procs is 1).

I am reading this correctly ... or is the behavior different than I am
describing?

Thanks and Regards,
Ivan Novick
--
You received this message because you are subscribed to the Google Groups "web.py" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to webpy+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
Justin Davis
2010-07-28 00:02:20 UTC
Permalink
Yes, that sounds correct. If you only have 1 process, the ThreadedDict
makes certain dictionaries threadsafe -- specifically web.ctx and any
session objects.

Mutliprocess might expose some race conditions within "class Store" in
session.py -- combine multiprocess and sessions carefully!

-Justin
Post by n***@gmail.com
Post by Justin Davis
If you increase the max-procs, you will spawn (at most) that many
python processes. Note that these aren't threads, but separate
processes, so you need to be sure that any state within a given
application isn't necessary. For instance, if you maintain a global
dict of logged in users, this will break in the multiprocess
deployment.
webpy applications are multithreaded however, so multiple connections
will be processed simultaneously. However, due to the way python
implements threading (specifically, the GIL), it's uncommon for python
threads to really take advantage of multicore architectures. If you
have several cores and have written the program correctly, upping the
max-procs variable will help you get more throughput.
Good luck,
Justin
Thanks Justin!
Having read your reply and digging deeper it seems the Session object
is a ThreadedDict and HttpServer uses ThreadingMixIn
I am assuming (hoping) what this means is that each web request is
handled on a new python thread and that the incoming request will have
the session data of its matching session associated with the new
thread.
Also that any variables defined globally (outside of the session) can
be shared by all threads.  Like in your example: a global dictionary
of logged in users.  (assuming max-procs is 1).
I am reading this correctly ... or is the behavior different than I am
describing?
Thanks and Regards,
Ivan Novick
--
You received this message because you are subscribed to the Google Groups "web.py" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to webpy+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webpy?hl=en.
Loading...