Lack of RAM will kill your blog host virtual machine
I know what you are thinking: “Well, duh Pedro, how come you didn’t know that?”.
I’ll explain: Recently i started having some service shortages on my blog. From times to times the CPU usage would just go rooftop and then nginx and apache both stopped serving requests. I am using Linode as my host, where i have a nice virtual machine (or node, as they call it) with some reasonable values in terms of CPU and bandwidth monthly usage. The weakest link was the RAM; it only had 386Mb.
A while back i developed Jumperr.com and i figured “hey, i already have the node, so i’ll just host it there”. Some time after deploying jumperr, i started noticing these shortages coming up maybe once a month, or every two weeks (i notice the pattern now, not then
). At some point i even considered switching hosts (to slicehost, for example), but i never thought that memory could be the problem (after all they are not that accessed anyways). Looking at the system logs i just could not figure out what made the machine stop working just like that.
About one month ago, i decided to develop a stupid website that allows you to bomb countries using a Google maps interface. And then, surprise, the shortages became more and more frequent (sometimes 4 per day!). In one of these fails i decided to try to login to the node using Linode’s ajax ssh interface on their dashboard. And that’s when i saw it: a bunch of “out of memory” errors right on the boot list. Since when you connect normally via SSH you don’t see the prompt on the remote end, i never saw these before.
So there you go, lesson learned. If it spikes, chances are you are out of memory
By the way, if you are a proper Linux/Unix admin, was there a log that might contain those errors that i missed?
Related:
- OSX: Change time machine auto backup interval The default time machine backup interval is every hour. Sometimes...
- Things i wanted in Apple’s iPad (tablet) Cool as it may be, i cannot but feel disappointed with Apple’s...
Categorised as: computers, findings, hardware, tips
A solução é basica, deixas de usar frameworks de hype tipo Ruby on Rails e Django que consomem mais recursos por request que o OpenOffice a correr, e vais ver a utilização da memoria a baixar.
Eu também andei a fazer um site em Django, e tipo, isso é tudo muito bonito e tal e fácil e isso tudo. O problema maior é quando vais meter em produção e vês que nem um cluster de bluegenes consegue aguentar com os recursos que isso consome.
Primeiro, não funciona bem no apache, portanto, se queres alguma merda que precise de php ou usas o php todo martelado no nginx com fastcgis e o crl a consumir também montes de memoria, ou usas o nginx pro django, e o apache pro php.
Abraço
Também não é preciso exagerar
O Django funciona bem e até agora nunca vi ninguém a queixar-se de problemas de memória quando é bem configurado. Tens montes de dicas (por exemplo aqui: http://blog.webfaction.com/tips-to-keep-your-django-mod-python-memory-usage-down) como remover o apache completamente, ou pelo menos mudar do mod_python para mod_wsgi.
Pesando velocidade de desenvolvimento e facilidade de manutenção contra estabilidade e super optimização continuo a preferir o django do que o php
By the way, enquanto escrevia isto, descobri um wsgi server que algum pessoal diz que é muito mais rápido e eficiente do que o apache com o mod_wsgi: http://pypi.python.org/pypi/Spawning/0.7