21👍
I’ve done both, and Apache/mod_python tended to be easier to work with and more stable. But these days I’ve jumped over to Apache/mod_wsgi, which is everything I’ve ever wanted and more:
- Easy management of daemon processes.
- As a result, much better process isolation (running multiple sites in the same Apache config with mod_python almost always ends in trouble — environment variables and C extensions leak across sites when you do that).
- Easy code reloads (set it up right and you can just touch the
.wsgi
file to reload instead of restarting Apache). - More predictable resource usage. With mod_python, a given Apache child process’ memory use can jump around a lot. With mod_wsgi it’s pretty stable: once everything’s loaded, you know that’s how much memory it’ll use.
6👍
lighttpd with FastCGI will be nominally faster, but really the time it takes to run your python code and any database hits it does is going to absolutely dwarf any performance benefit you get between web servers.
mod_python and apache will give you a bit more flexibility feature-wise if you want to write code outside of django that does stuff like digest auth, or any fancy HTTP header getting/setting. Perhaps you want to use other builtin features of apache such as mod_rewrite.
If memory is a concern, staying away form apache/mod_python will help a lot. Apache tends to use a lot of RAM, and the mod_python code that glues into all of the apache functionality occupies a lot of memory-space as well. Not to mention the multiprocess nature of apache tends to eat up more RAM, as each process grows to the size of it’s most intensive request.
- [Django]-How can I chain Django's "in" and "iexact" queryset field lookups?
- [Django]-VueJS + Django Channels
- [Django]-Factory-boy create a list of SubFactory for a Factory
- [Django]-AccessDenied when calling the CreateMultipartUpload operation in Django using django-storages and boto3
- [Django]-What is the difference render() and redirect() in Django?
- [Django]-Django REST framework post array of objects
2👍
Personally I’ve had it working with FastCGI for some time now (6 months or so) and the response times ‘seem’ quicker when loading a page that way vs mod___python. The critical reason for me though is that I couldn’t see an obvious way to do multiple sites from the same apache / mod_python install whereas FastCGI was a relative no-brainer.
I’ve not conducted any particularly thorough experiments though 🙂
[Edit] Speaking from experience though, setting up FastCGI can be a bit of a pain the first time around. I keep meaning to write a guide..!
- [Django]-Django storages: Import Error – no module named storages
- [Django]-Django datefield filter by weekday/weekend
- [Django]-In django, how do I sort a model on a field and then get the last item?
2👍
I’m using it with nginx. not sure if it’s really faster, but certainly less RAM/CPU load. Also it’s easier to run several Django processes and have nginx map each URL prefix to a different socket. still not taking full advantage of nginx’s memcached module, but first tests show huge speed advantage.
- [Django]-Django 2, python 3.4 cannot decode urlsafe_base64_decode(uidb64)
- [Django]-Is there a way to filter a queryset in the django admin?
- [Django]-How about having a SingletonModel in Django?
2👍
There’s also mod_wsgi, it seems to be faster than mod_python and the daemon mode operates similar to FastCGI
- [Django]-How to run celery as a daemon in production?
- [Django]-How to run a celery worker with Django app scalable by AWS Elastic Beanstalk?
- [Django]-Paginating the results of a Django forms POST request
2👍
I’d recommend WSGI configurations; I keep meaning to ditch apache, but there is always some legacy app on the server that seems to require it. Additionally, the WSGI app ecology is very diverse, and it allows neat tricks such as daisy-chaining WSGI “middleware” between the server and the app.
However, there are currently known issues with some apps and apache mod_wsgi, particularly some ctypes apps, so be wary if you are trying to run, say, geodjango which uses ctypes extensively. I’m currently working around those issues by going back to fastcgi myself.
- [Django]-Why is __init__ module in django project loaded twice
- [Django]-AccessDenied when calling the CreateMultipartUpload operation in Django using django-storages and boto3
- [Django]-Django – Clean permission table