Recently i ran into RAM troubles on my vserver for some reasons, i encountered the evil:
Cannot allocate memory at ...
So first i suspected mongodb to use up loads of memory as top showed.
The true RAM monsters were some apache and php-fpm zombies, but thats another story.
While suspecting mongodb i thought about outsourcing the mongodb and i found a free and sufficient offer in mongolab.
My interests were on and i gave it a try.
The free version has a limit for up to 240MB storage and since my app is just a small counter it should last for some time.
The registration was easy, creation of the database aswell and the administration panel is also pretty cool and informative.
Then create a user and migrate:
First get my data from the vserver on the vserver:
mongodump --host 127.0.0.1
Then fetch it to my local machine:
scp -r firstname.lastname@example.org:/var/www/vhosts/verrueckte/dump/mongodumpdata .
Ups i didnt had no mongo client on my local machine, go get it:
sudo apt-get install mongodb-clients
Now connect to the mongolab via your console
mongo db123xyz.mongolab.com:12345/thedb -u <user> -p <pw>
Hey works, great!
Alright see you later.
Now import the dumps to continue the counter there were i stopped.
cd mongodumpdata mongorestore -h db123xyz.mongolab.com:12345 -d thedb -u -p .
Then teach the php app the new connection:
$this->host = 'mongodb://user:email@example.com:12345/thedb'; new mongo($this->host);
There you go! The counter is storing its stuff to the mongolab database.
And i can stop the mongod on my machine and free some memory.
ps aux | grep mongodb kill <PID>