Monday, January 6, 2014

Django Apache Server - Processes be Killed

Few days ago, while we are trying to give out a live demo to our customers. The Django-apache server was not working accidentally. I found that I couldn't even SSH into the server. Now, I am writing down the problem I met and how I solved it in this post.

Django-Apache Server has No Response

My Django-apache has no response. The requests from the apps timeout and failed to receive the response.

Can't SSH into the Server

Same, I got timeout and failed while trying to SSH into the server. So, I try to login using the SSH interface from Linode. That works, but I see the following messages:
Out of memory: Kill process xxxxx (safesquid) score xx or sacrifice child Killed process xxx, UID xxx, (python) total-vm:xxxxKB, anon-rssxxxxkB, file-rss:xxxkB
*xxx is some number
The messages repeat a lot, and keep popping up. After doing Google Search, I think that there are some problems to do with the memory. It seems that someone use too much memory, and OS started to kill processes in order to get memories. I think OS killed the running apache server.


Turn Off Debug Mode

First, I scan through the processes running on my machine. The only two suspected service is django and celery. Then, I started to think if I am following the right deploying steps in their official document. And I found in Django Deployment Document, it says that if django is under debug mode, "All database queries will be saved in memory as the object django.db.connection.queries. As you can imagine, this eats up memory!"

So, I did the following modifications in settings.py
DEBUG = False
ALLOWED_HOSTS = ['api.plate.tw']


Result

I haven't met the same problem after switching off the debug mode, but still not sure if the problem is totally be solved.

No comments:

Post a Comment