2đź‘Ť
Setting WSGIApplicationGroup %{GLOBAL}
although advisable if using lxml, isn’t going to solve performance issues. It protects against deadlocks and crashes due to lxml not being incompatible with sub interpreters. Thus completely different issue.
As to performance, if you have many requests performing CPU intensive Python only code, then there will be some GIL contention, but that will only slow the throughput overall and not block concurrent requests which are also doing CPU intensive work. This is because the Python interpreter will cause control by a thread to be implicitly yielded every certain number of Python byte code instructions so that other threads can run.
The bigger problem is where you are using a module which has a C extension component and it is doing CPU intensive long running tasks and what it is doing means it has to operate on Python data structures and so cannot release the GIL to allow other threads to run. In other words, C code which takes a long time and doesn’t release the GIL locks out other threads.
If you are seeing this sort of problem, because Windows doesn’t allow multi process Apache, you would have to use some sort of backend task queuing system which can farm out the actual work to separate processes somehow. On UNIX systems you would use Celery, or Redis Queue for that. What your options on Windows are I have no idea.
0đź‘Ť
As why you get “massive slowdowns” when doing some CPU or memory intensive computations, it doesn’t necessarily has to do with the GIL, it might just be your system not being able to cope with the load. Scaling heavy processings is usually dealt with using a multiple servers setup (eventually with parallelisation).
- [Answered ]-Reduce queries to the same Django model when using Model.objects.all()
- [Answered ]-Django: Customizing ManyToManyField form options
- [Answered ]-'UserForm' object has no attribute 'Cleaned_data'
- [Answered ]-What is happening in this urlpatterns list of Python Django urls.py file?
- [Answered ]-List filter to be conditional (according to results)