3

i have an use case in my application where i need real time communication between users based on their position. Basically one user will create an "event" and it will be sent to near users. On the server side i'm planning use redis or mysql to manage events and participants. Based on questions like this one i could configure mysql with:

innodb_flush_log_at_trx_commit = 2

and it increases write performance. Do you think that properly configured MySQL could compete with Redis?, what i like of MySQL is that i can use an ORM in front of it. Or maybe i'm missing something about the difference between Redis and MySQL.

Thanks in advance.

2

There are too many differences to enumerate. The choice between them is heavily based on your application, which you have not described.

That setting affects writes, not reads.

If you are not exceeding 100 queries per second on slow spinning drives, MySQL will do just fine. Or, if it does not, then we should look at your indexes and queries.

2

See Looking at Redis from Percona (they are primary MySQL experts). They describe differences between Redis and MySQL. The blog posting is a little bit dated (2009).

Redis and MySQL have different use case.

I call Redis semi-persistent because it does not store the data on disk immediately but rather dumps its all database every so often – you have a choice of configuring time and number of updates between database dumps. Because dump is basically serial write Redis does not an expensive IO subsystem. Also because this dump is background it does not affect read/write performance to the database which is in memory. In the tests I’ve done I’ve seen Redis doing writes some 4MB/sec for probably 50% of test duration where Innodb had to write 50MB/sec for about third of throughput and doing a lot of random IO as it was doing it. This is among other things because Innodb has to flush full 16K pages while doing flush.

the test result summary

With Redis I got about 3 times more updates/sec – close to 100.000 updates/sec with about 1.5 core being used. I have not tried running multiple instances and I’m not sure the network and TCP stack would scale linearly in this case but anyway we’re speaking about hundreds of thousands of updates/sec.

I think Redis can be great piece of architecture for number of applications. You can use it as the database or as cache (it supports data expiration too)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.