There already is a WSGIRestrictEmbedded directive in mod_wsgi 2.X
which allows one to disable the ability to have a WSGI application run
in embedded mode. That is, you must have
WSGIDaemonProcess/WSGIProcessGroup correctly setup. If you do not, you
will get a 500 error and message in the Apache error logs of:
Embedded mode of mod_wsgi disabled by runtime configuration
I was already intending to have mod_wsgi 4.0 disable embedded mode by
default, but now thinking of doing this earlier in mod_wsgi 3.0.
The overall intent of this is to discourage people using embedded
mode, especially when they have no clue about setting up Apache, and
encourage them to use the safer option of daemon mode.
I accept that I may have to make that error message which appears in
the logs more descriptive/prescriptive, but still think doing this
would be the best.
BTW, this doesn't apply to Windows or Apache 1.3 where embedded mode
is the only option.
Comments?
Graham
I would prefer embedded mode to be disabled by default. It seems like
a very useful option for people who know what they're doing and have a
very specific environment thats well suited for using embedded mode.
My guess is the vast majority of modwsgi users only ever want daemon
mode, and those who want embedded mode will know how to configure it.
But thats just IMHO and a wild guess at that. :-)
I'll admit that that is an interesting idea, but in itself dangerous.
If someone has an existing site running under embedded mode and they
decide to add a new application running in a daemon process, there
main site will stop working and they will not know why.
As for the newbies, this is why the error message in the Apache error
logs has to be better. Ie., something like:
"""Embedded mode of mod_wsgi disabled by runtime configuration.
Configure use of a daemon process using
WSGIDaemonProcess/WSGIProcessGroup directives, or enable embedded mode
using the WSGIRestrictEmbedded directive."""
Graham
Returning a custom 500 HTML page is not unreasonable and could be considered.
In general have avoided doing that. I was setting Apache error-notes
with details of error, but that only shows up in standard error page
if multingual error documents enabled in Apache. Plus no longer set
error-notes in mod_wsgi 3.0 due to risk of information about system
setup being exposed.
Graham
+1 for same reasons.
Defaults should be best practice for the common case. Advanced users
with special cases can learn how to enable embedded mode and tune
Apache as required.
Bring it forward to mod_wsgi 3.0. Hell, Debian still won't supply 3.0
for a few more years, given their current form...
Cheers,
Chris Miles
The problem lies in the default settings for these directives:
For prefork:
StartServers
MinSpareServers
MaxSpareServers
MaxClients
MaxRequestsPerChild
For worker:
StartServers
MaxClients
MinSpareThreads
MaxSpareThreads
ThreadsPerChild
MaxRequestsPerChild
As stated elsewhere in this group, the defaults from an out of the box
Apache configuration are good for static and CGI-generated content.
Maybe you just disable embedded mode if the values for the above
directives make for less than optimal performance.
Better if you leave embedded mode alone but put minimum recommended
values for the above directives in the Quick Configuration
documentation. Maybe even add a distinct section on Performance
Tuning. Don't get me wrong, documentation is excellent for mod_wsgi
but in most cases people would just like to get it up and running as
quickly as possible without wading through several pages of docs.
--
Best Regards,
Nimrod A. Abing
W http://arsenic.ph/
W http://preownedcar.com/
W http://preownedbike.com/
W http://abing.gotdns.com/
speaking from the newbies perspective (which is different than the 90%
IMO), if it *just works* the first time you load it it should be the
best software in the planet.
> Suggestion is simple the WSGIDaemonProcess it self disables embedded
> mode, and you can re enable it if your 'really' know what you are
> doing.
so yes I kind of agree, if you are having conflicting directives in
your config file, mod_wsgi should fail to load, it's the only way to
make people (with broken configuration realize it's their fault and
not apache/mod_wsgi) that their site is slow. Sadly the average joe
won't read the log file, until pointed at it.
While we are having this discussion, I have made some changes and we
will see who screams first. That of course presumes one is using
mod_wsgi from trunk. I am pretty sure I know who it will be. :-)
Anyway, obviously, disabling embedded mode by default means that
without specifically setting up WSGIDaemonProcess/WSGIProcessGroup,
which many will not do, they are going to get an error on the first
try. This isn't going to be very welcoming. At the same time though,
nothing works with fastcgi without configuration either.
One option is that when embedded mode is disabled and no
WSGIDaemonProcess has been defined, that a default daemon process is
automatically created, with everything routed through to that. That
way everything would work and they wouldn't be the wiser that it
wasn't running in embedded mode. Only issue would be that to make is
perform reasonably, would have to be a multithreaded process which may
cause some code to not work if not multithread safe.
Doing that may be a bit too magic though as it hides what is
happening. Thus, best compromise may be the descriptive HTML error
page, although in general I don't like doing that as it exposes
details about what the server is running, which some people may not
want. But then it is only going to happen in a case where not
configured properly.
Graham
The other option is I do defer this to mod_wsgi 4.0 again like had
originally intended. Any solution then can tie in with the plan to add
support for transient daemon processes.
http://code.google.com/p/modwsgi/issues/detail?id=22
There could be a default rule setup where by if nothing explicitly
done, then an on demand daemon process created for each
virtualhost:port combination. If multiple WSGI applications mounted
for host, then they just run in separate sub interpreters as like they
do in embedded mode anyway.
Still have the issue of probably wanting only a single multithread
process. Possibly also want to have a default inactivity timeout set
so process is shutdown when not in use for a while.
Actually, I am started to like this idea and so can see some sense in
not disabling embedded mode in mod_wsgi 3.0 since the fallback if
transient daemon processes available much better.
Graham
Or finally, I just take a bit longer with mod_wsgi 3.0 and implement
transient daemon processes now.
I would just need to make sure I give some added priority to get
mod_wsgi 2.4 bug fix version out.
Graham
"Fastest" != "Optimal" For many people ease of administration and
number of features is far more important than a small increase in
requests per second. If you really think "faster is better" I'm not
sure why you're using Python to begin with. :) There are definitely
"faster" platforms out there.
Agreed. For better or worse, most people just copy & paste the
modwsgi setup instructions for their application and only return to
the docs when something doesn't work as they expect.
So instead of changing code, you could just change the docs.
Michael Schurter
That is because I reverted the change. Everything should be how it was before.
Graham
Wiki documentation still need a major overhaul, but perhaps marginally
better now that there is the quick configuration guide.
The problem with making the first example use daemon mode is that it
will not work on Windows or Apache 1.3 Thus had avoided it and just
gone with what would at least work on all platforms.
Graham
If you mean changing the number of processes and/or threads in a
process group dynamically, much the same way that Apache does for
processes in worker/prefork MPM, the answer is no. Part of the reason
why daemon mode works well is that things are fixed. The dynamic
nature of things in embedded mode is the cause of unexpected memory
usage and load spikes as I recently blogged about.
The only measure of scaling back would have is that with on demand
created processes, inactivity timeout would shutdown the process but
not start it up again automatically, only being started when
subsequent request arrives.
Dynamically creating external threads may also cause problems with
accumulation of thread local data in Python. I'll have to actually
check what happens on winnt MPM as it already dynamically creates
threads from memory and so may already have this problem. :-(
Anyway, perhaps explain better what you are talking about.
Graham
No, I am safe. Number of threads per generation is fixed even on winnt MPM.
Graham
Had already been thinking about how to overload on same directive.
Graham