My document looks like this-
{ "_id" : ObjectId("4f0565b8440b4b19d407ea29"), "type" : "web",
"when" : ISODate("2012-01-05T08:56:24.134Z"), "user" : "IIUEBSTJ",
"res" : false
}
As you can see, it is fairly simple and small document. _id is automatically being indexed by MongoDB. I am generating these documents via C# MongoDB driver. MongoDB instance version 2 is running on Ubuntu box with 512 MB RAM and 2 core CPU. Since I am using SDD, I don’t see any noticeable change in insert speed when faults occur. Here is the code for generating these documents-
MongoDatabase db = server.GetDatabase("logs");
MongoCollection coll = db.GetCollection("logs");
long ctr = 0;
for (; ; )
{
Console.WriteLine("Doc# {0}", ctr++);
BsonDocument log = new BsonDocument();
log["type"] = "auth";
BsonDateTime time = new BsonDateTime(DateTime.Now);
log["when"] = time;
log["user"] = RandomString(8);
BsonBoolean bol = BsonBoolean.False;
log["res"] = bol;
coll.Insert(log);
}
Currently I am getting about 5k inserts per second. Is this good enough? By “good”, I want to know if this is the kind of speed you insert speed you’ve seen?
As an attempt to answer this constructively, I’d suggest considering first (as the commenters have suggested) what is the right number of inserts/sec for you. That is entirely dependent on your use case, and one would hope that you can answer it better than anyone here.
If you think that you ought to be getting more performance than you are (and a quick Google search suggests that the answer is yes), try to figure out where your current bottlenecks are and focus your attention there. For instance:
Are all the CPUs pinned at 100% on either your client machine or your server? For the client, use Windows Task Manager or the excellent Process Explorer from sysinternals. For the server, use the top command. This may mean that you simply need more CPU muscle on that machine.
Is one CPU on the client or server pinned at 100%, while others are idle? If that is the case, you are probably looking at a single-threaded process that could benefit from multithreading. If it’s on the server, then spreading your write workload out among several clients may help.
Are either of your machines using all of their memory? The same tools may help to diagnose this.
Are either of your machines saturating their network bandwidth? Same tools to diagnose for windows, or something like vnStat for Linux. If so, you may need to switch to faster network hardware (network cards, switches, routers, better cable, etc).
This isn’t intended to be a snarky answer- just trying to point you in the right direction for diagnosing this kind of thing.