Answer the question
In order to leave comments, you need to log in
Slow queries on remote MySQL?
I'm migrating a project to git and I'm faced with the fact that I need to connect to a remote database in order to work with up-to-date information. I set up a bunch of nginx + php7, but when I try to open a page with queries made through mysqli, I get an error like mysqli::__construct(): (HY000/2002), or the page opens very slowly (from 30 seconds or more). The server itself is located in the data center of Moscow, and I'm in the Trans-Baikal Territory, the ping is about 60ms. There is no difference how to connect to the database using a tunnel or a direct connection.
I tried to set up replication from server to server located in the same data center, but there were also delays
[client]
port = 3306
socket = /var/lib/mysql/mysql.sock
[mysqld_safe]
nice = 0
socket = /var/lib/mysql/mysql.sock
pid_file = /var/lib/mysql/mysql.pid
log_error = /var/log/mysql/error.log
[mysqld]
performance_schema
user = mysql
port = 3306
datadir = /var/lib/mysql
socket = /var/lib/mysql/mysql.sock
pid_file = /var/lib/mysql/mysql.pid
log_error = /var/log/mysql/error.log
skip_external_locking = 1
skip_name_resolve = 1
event_scheduler = 1
max_join_size = 1000000
max_sort_length = 1024
max_connections = 900
max_allowed_packet = 256M
max_connect_errors = 1000
wait_timeout = 30
interactive_timeout = 30
net_read_timeout = 30
net_write_timeout = 30
key_buffer_size = 32M
read_buffer_size = 4M
sort_buffer_size = 4M
read_rnd_buffer_size = 4M
table_cache = 2G
table_open_cache = 5000
max_heap_table_size = 512M
tmp_table_size = 512M
tmpdir = /temp
query_cache_type = 0
query_cache_size = 0
query_cache_limit = 0
innodb_open_files = 35000
open_files_limit = 35000
join_buffer_size = 16777216
thread_cache_size = 8
slow_query_log = 1
long_query_time = 7.000000
log_queries_not_using_indexes = 0
slow_query_log_file = /var/log/mysql/long.log
innodb_read_io_threads = 64
innodb_write_io_threads = 64
innodb_buffer_pool_size = 8G
innodb_buffer_pool_instances = 8
innodb_lock_wait_timeout = 60
innodb_log_file_size = 256M
innodb_log_files_in_group = 8
innodb_log_buffer_size = 16M
innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
transaction-isolation = READ-COMMITTED
wsrep_on = OFF
Answer the question
In order to leave comments, you need to log in
Most likely this is due to the fact that the site and the database are on different servers. I remember doing something like this. Separated the database and the site on different servers for better performance. There was no effect, on the contrary, it became even slower. Although maybe I'm a curmudgeon myself)
If there is a lot of data in the sample, then they simply may not reach due to restrictions, see the config
Solution is so-so
Do replication
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question