views:

1861

answers:

3

Hi there,

I'm building a system that tracks and verifies ad impressions and clicks. This means that there are a lot of insert commands (about 90/second average, peaking at 250) and some read operations, but the focus is on performance and making it blazing-fast.

The system is currently on MongoDB, but I've been introduced to Cassandra and Redis since then. Would it be a good idea to go to one of these two solutions, rather than stay on MongoDB? Why or why not?

Thank you

+3  A: 

I currently work for a very large ad network and we write to flat files :)

I'm personally a Mongo fan, but frankly, Redis and Cassandra are unlikely to perform either better or worse. I mean, all you're doing is throwing stuff into memory and then flushing to disk in the background (both Mongo and Redis do this).

If you're looking for blazing fast speed, the other option is to keep several impressions in local memory and then flush them disk every minute or so. Of course, this is basically what Mongo and Redis do for you. Not a real compelling reason to move.

Gates VP
Heh, nice! Do you guys also do the impression validation route as well? Yeah - I was just concerned because while Mongo can handle lots of data, its might be inferior to Redis, and every millisecond counts.
Mark Bao
Depends what you mean by "validation". You can't reliably validate impressions / clicks real-time, you have to do that afterwards in larger batches.
Gates VP
+2  A: 

If you have the choice (and need to move away from flat fies) I would go with Redis. Its blazingly fast, will comfortably handle the load you're talking about, but more importantly you won't have to manage the flushing/IO code. I understand its pretty straight forward but less code to manage is better than more.

You will also get horizontal scaling options with Redis that you may not get with file based caching.

Ben Hughes
Mongodb has horizontal scaling too.
TTT
Thank you. Yeah, Redis is blazing fast, and so is Mongo, but we need to find what is the best solution given our volume. Thank you.
Mark Bao
A: 

Just found this: http://blog.axant.it/archives/236

Quoting the most interesting part:

This second graph is about Redis RPUSH vs Mongo $PUSH vs Mongo insert, and I find this graph to be really interesting. Up to 5000 entries mongodb $push is faster even when compared to Redis RPUSH, then it becames incredibly slow, probably the mongodb array type has linear insertion time and so it becomes slower and slower. mongodb might gain a bit of performances by exposing a constant time insertion list type, but even with the linear time array type (which can guarantee constant time look-up) it has its applications for small sets of data.

I guess everything depends at least on data type and volume. Best advice probably would be to benchmark on your typical dataset and see yourself.

drdaeman