I have a mysql database with multiple tables "InnoDB" with millions of row in it. Let say, The majority of interactions with tables are simple select/insert statements. But i have to make some Inner joints for statistics purpose.
I have two servers with Master/Slave replication. Master is for write only and slave for read to separate the queries manually without using a loadbalancer like ProxySQL … And it works fine for the simple queries.
Servers specs :
CPU : Intel Xeon E5-1630v3 - 4c/8t - 3.7 GHz/3.8 GHz
RAM : 64 GB ECC 2133 MHz
Latency between the two servers is 1ms (measured)
The problem is when i run the statistic module, i got like 99% of CPU usages and queries take a lot of time. Ex : 1 INNER JOIN take 2 or 3 sec (With indexes) but when i launch a lot of them, it can take up to 90 sec.
Its clear to me that i have to add more servers and build an architecture around with a load balancer. but before i dive to this, can anyone suggest me a working solution for my situation please.
Thanks in advance.
2
Answers
Thank you for your reply @lemonina
I wonder why my question has a -1 ...
I run a Benchmark before a reinstall all with sysbench :
here is the result :
There was no specific configuration with this test.
So made some changes based on what you suggest :
innodb_buffer_pool_size = 48G | Suggest between 60 and 80 % of RAM based on here
innodb_log_file_size = 10G | From Percona
innodb_thread_concurrency = 0 | From Link
innodb_flush_log_at_trx_commit=1 | From Link
sync_binlog=1 | From Link
innodb_file_per_table (NO) | From Link
For the caching, i don't think it will work because there is new data every second
SET GLOBAL innodb_redo_log_capacity = 8589934592; for Replica
Scaling horizontally with ProxySQL will be a great idea. I already tested this, but I dropped down this solution because the dispatching of the queries was slow. I found after a solution for this, so i think i will test this in a near future.
I also read about dividing the database between servers, I didn’t test it, but i have to figure out which tables i can put in the same server for my INNER JOINTs.
Here is my new configuration :
And the result from the same test :
I'm not sure if the reinstall of the 100 Go database can impact the performance obtained or the configuration did.
What do you think ?
here are some suggestions to improve your performance:
JOIN
(my.cnf)
and adjust it for the hardware configuration and workload (parameters such as "innodb_buffer_pool_size", "innodb_log_file_size", "innodb_flush_log_at_trx_commit", "innodb_thread_concurrency", etc)as you have already identified, scaling horizontally with a load balancer may be the best long-term solution to handle increasing loads