Mongodb – Mongo takes too much memory when insert data

javamemorymongodb

I'm using mongo as a database log. I store on it all the logs of an application, so I have a high rate of inserts, for example 100 inserts per second. To accomplish that I developed a part of the application dedicated to store in mongo the data. this app only uses a mongo connector.

But the memory consuption is incredible high, I mean after start to use mongo the heap memory has increased in about 300MB and the CPU takes over 90%. Anyone knows how I can decrease this memory consuption or why it is happening?. I've tried to use Mysql and the heap memory keeps normal (only is increased in 20MB) and Cpu doesn't increment as mongo situation.

The data to store is very simple.
in fact I used the following json for separate test with the same results.

{testData:'something i'}

Is there any way to create a datasource with mongo?

Best Answer

see this link. https://groups.google.com/forum/#!topic/mongodb-user/w7G1xRy3TZQ

the bottom line is Mongo caches indexes and data in available RAM