14
I’m afraid I haven’t got any definite answers. Graham Dumpleton’s tips were most helpfull, but unfortunately he didn’t make an answer (just comments), so there is no way to accept his response.
Although I still haven’t fully resolved the issue, here are some basic tips for other people having similar problems:
- Read Webfaction’s documentation:
- Make sure the
DEBUG
setting is set toFalse
- Don’t use
mod_python
, usemod_wsgi
- Make sure you use the most recent version od
mod_wsgi
(Webfaction tends to install older versions) - Don’t use Django to serve static content
- Try running
mod_wsgi
in a daemon mode (Webfaction installs it in embedded mode by default) [thanks Graham Dumpleton for the tip] - If you run in embeded mode, you can specify “inactivity-timeout=[seconds]” option. It will restart the process after [seconds] of inactivity, helping with increased memory usage. Read this forum post for detailed instructions.
- This script will help you monitor your memory usage easier, and more precisely [thanks ClaudioA for the tip]
2
We had a similar issue on Webfaction, but it turned out it wasn’t because of them at all. There’s a bug in Django about high memory usage when using the sitemap with lots of elements: http://code.djangoproject.com/ticket/11572
When we removed the sitemap it doesn’t shoot up 90 Mb at the time any longer. Just thought I should mention it since it took a long time for use to troubleshoot.
- [Django]-Django: display time it took to load a page on every page
- [Django]-Django: accessing the model instance from within ModelAdmin?
- [Django]-Can "list_display" in a Django ModelAdmin display attributes of ForeignKey fields?
1
I have the same problems with webfaction.
The method I use, and which webfaction told me I should keep using, is run a cron job that checks the memory every 5 minutes or so, and restarts any apps that are getting out of control.
Out of 4 python apps on webfaction, I average 4 restarts per day.
- [Django]-Django Rest-Framework nested serializer order
- [Django]-Laravel's dd() equivalent in django
- [Django]-Scoped_session(sessionmaker()) or plain sessionmaker() in sqlalchemy?
1
-
Did you check these tips? ->
http://blog.webfaction.com/tips-to-keep-your-django-mod-python-memory-usage-down -
We have deploy an app in WebFaction
and we are not having those issues. -
Are you serving your static files as
they recommend? -
BTW this could be useful too:
http://fightingrabbits.com/archives/198
- [Django]-Error: [ngModel:datefmt] Expected `2015-05-29T19:06:16.693209Z` to be a date – Angular
- [Django]-How do I run tests for all my Django apps only?
- [Django]-Remove default apps from Django-admin
1
I’d suggest not to guess.
Take a look at http://code.google.com/p/django-dowser/, it is a very useful app for detecting memory leaks and figuring out what parts of your code are responsible for memory consumption.
- [Django]-How to use less css with django?
- [Django]-Inline in ModelForm
- [Django]-Readonly for existing items only in Django admin inline
1
Check if the in-process memory cache backend is enabled, if yes, that could be the problem (new cache entries at each request).
- [Django]-"No 'Access-Control-Allow-Origin' header is present on the requested resource" in django
- [Django]-Django model fields getter / setter
- [Django]-DatabaseError: value too long for type character varying(100)
0
I’ve had issues with memory on Webfaction too – they didn’t really crop up until I added my fifth application though. I tried a few tweaks to my apache configs, but what finally worked for me was just switching over to mod_wsgi.
- [Django]-Remove Labels in a Django Crispy Forms
- [Django]-How to add a new field to a model with new Django migrations?
- [Django]-Convert Django Model object to dict with all of the fields intact
0
Are both mod_python and mod_wsgi modules loaded into apache?
I know mod_wsgi doesn’t like having mod_python in its building. Check its not loaded.
- [Django]-How to set the default of a JSONField to empty list in Django and django-jsonfield?
- [Django]-Update multiple objects at once in Django?
- [Django]-Fastest way to get the first object from a queryset in django?