I need to increment a counter each time a web page is rendered.
When I use mongodb to do that, I can do about 16000 writes per second on a 4 cores/8 threads CPU on a regular disk.
When I use Mysql InnoDB table, I can do only... 30 writes per second on regular disk or 200 writes on SSD !!
Because I have only one write per transaction (basically I have no other write to do after incrementing my counter for a same http request) Using autocommit to False and manually commit will not help.
The différence is that Mongodb flushes writes lazyly.
I tried to have Mysql buffering writes before flushing them to disk by setting these parameters into my.cf, but it did not helped :
innodb_buffer_pool_size = 1G
innodb_flush_method=O_DIRECT
innodb_log_file_size=100M
innodb_change_buffering=all
innodb_thread_concurrency=8
Is there a way to have faster mysql writes ?
innodb_flush_log_at_trx_commit = 2– Rick James Jun 19 '15 at 00:14