cooldude
cooldude

Reputation: 985

using Redis AOF fsync per write vs MYSQL myism db performance

I m having a game which requires rounds being clicked by players . It is compulsory to save per round data in the file. Currently , we are using a mysql database to do save the data. I m thinking to optimize it by using redis. Is the redis AOF fsync per write such reliability and better performance over mysql.

Upvotes: 1

Views: 1195

Answers (1)

Didier Spezia
Didier Spezia

Reputation: 73236

You may want to read the Redis persistency page and the high latency troubleshooting page.

The MyISAM engine does not offer any redo logging mechanism. So it is quite fast, but not reliable. Any system crash will lead to potential corruptions in the data files, that have to be repaired before the service can be restored.

Redis with AOF + fsync per write will offer better reliability, but at the price of performance and scalability. Fsync operations are very expensive with HDD. Redis tries to optimize them by using a form of group commit (i.e. several write operations are batched during the event loop iteration), but still, when the fsync is done, the whole Redis event loop is frozen.

You can relax this behavior by using other options (appendonly everysec for instance). In this mode, you can loose the last second of write traffic in case of system crash, but there is no need to repair anything before restarting Redis. Performance in this mode is far better because the fsync are mostly done in background.

IMO, if you need absolute durability (but for a game I doubt it), you will be better served with a real OLTP engine with maximum safety options (for instance: InnoDB with innodb_flush_log_at_trx_commit set to 1).

Upvotes: 1

Related Questions