FreeBSD threads, Apache, and mod_wsgi

·—— ···· ·· — ····· ···—— ——···

I'm evaluating mod_wsgi, and my usual server environment is FreeBSD 6. Unfortunately, FreeBSD has gained a bad reputation for supporting Apache's thread-based worker MPM (more modern than the process-based prefork MPM). I wrestled with this last fall when I was evaluating mod_python. Now I'm wrestling with it again, because one needs a threaded Apache in order to take advantage of mod_wsgi's daemon mode.

The complications begin with FreeBSD's three threading implementations:

(Here's a much more detailed discussion.)

Now, I found two actual data points last fall to scare me off from a threaded Apache on FreeBSD:


The first is from September 2003, before libpthread had landed, and the claim that "FreeBSD threads suck. Bigtime" probably refers to the older libc_r library. The second instance is under Apache 2.0/FreeBSD 6.0, but it doesn't definitively address the case of mixed threading libraries: with an empty libmap.conf, one could end up with an httpd linked against libpthread loading modules linked against libraries that are linked against libc_r or libthr (right?). Given these question marks, I'm giving threaded Apache on FreeBSD another shot for the sake of a full-featured mod_wsgi.

After getting mod_wsgi to compile, I saw Apache die silently after loading mod_wsgi. However, it looks like the problem is that the envvars trick to force Apache to "acquire threadedness" is now coming back to haunt me. If you're using libpthread with Apache, then you don't want another threading library linked via envvars, or really at all: I'm not going to touch libmap.conf for now, but if I see more problems, the first thing I'll try is overriding any use of libc_r with libpthread in libmap.conf. After that, I'll probably take future problems to the freebsd-apache and freebsd-threads lists. For now, though, I have mod_wsgi working with a threaded Apache 2.0, and that's enough for today.

·—— ···· ·· — ····· ···—— ——···
Feed back to Chad Whitacre.