After 2 days of debugging, I kept my whistle to a minimum: the Python garbage collector.
My application stores many objects in memory. And it works well. GC performs regular rounds (I did not play with thresholds by default (700, 10, 10)).
From time to time, in the middle of an important transaction, passing the 2nd generation starts and checks my objects ~ 1.5M generation 2.
It will take 2 seconds! A nominal transaction takes less than 0.1 seconds.
My question is: what should I do?
I can turn off 2nd generation sweeps (setting a very high threshold is the right way?), And the GC is obedient. When should I turn them on?
We implemented a web service using Django, and each user request takes about 0.1 seconds.
Optimally, I will run these GC gen 2 loops between user API requests. But how to do that?
My view ends with return HttpResponse(), AFTER I would like to run the Gen 2 GC generator.
How should I do it? Does this approach make sense?
Is it possible to mark an object that NEVER needs to collect garbage so that the GC does not test them every cycle of the 2nd generation?
How to configure GC to run full deployments when the Django server is relatively inactive?
Python 2.6.6 on multiple platforms (Windows / Linux).
source
share