MySQL/ProxySQL

ProxySQL 옵션 이야기

lejpower 2021. 9. 1. 22:30
mysql> show variables like "%ping%";
+---------------------------------+--------+
| Variable_name                   | Value  |
+---------------------------------+--------+
| mysql-monitor_ping_max_failures | 3      |
| mysql-monitor_ping_timeout      | 1000   |
| mysql-monitor_ping_interval     | 10000  |
| mysql-ping_interval_server_msec | 120000 |
| mysql-ping_timeout_server       | 500    |
+---------------------------------+--------+
5 rows in set (0.00 sec)

Admin> show variables like "%shun%";
+------------------------------+-------+
| Variable_name                | Value |
+------------------------------+-------+
| mysql-shun_on_failures       | 5     |
| mysql-shun_recovery_time_sec | 10    |
+------------------------------+-------+
2 rows in set (0.00 sec)

mysql-monitor_ping_interval (10초)

The interval at which the Monitor module should ping the backend servers by using the mysql_ping API.

 

mysql-monitor_ping_max_failures (3번)

The maximum number of ping failures the Monitor module should tolerate before sending a signal to MySQL_Hostgroups_Manager to kill all connections to the backend server.

mysql-monitor_ping_timeout (1초)

How long the Monitor module will wait for a ping reply.

 

 

즉, MySQL을 멈춘 뒤에 30초 후에 서버 상태가 "SHUNNED"가 되었다. 

 

mysql-shun_on_failures

The number of connection errors tolerated to the same server within an interval of 1 second until it is automatically shunned temporarily. For now, this cannot be disabled by setting it to a special value, so if you want to do that, you can increase it to a very large value.

 

즉, 1초 안에 5번 이상 커넥션에 문제가 생길경우에는 임시적으로 "shunned"상태로 변경한다.

mysql-shun_recovery_time_sec

A backend server that has been automatically shunned will be recovered after at least this amount of time.
Note that if ProxySQL isn’t handling client traffic, there is no actual hard guarantee of the exact timing, but in practice it shouldn’t exceed this value by more than a couple of seconds.

Self tuning:

  • mysql-shun_recovery_time_sec should always be less than mysql-connect_timeout_server_max/1000 , in order to prevent that a server is taken out for so long that an error is returned to the client. If mysql-shun_recovery_time_sec > mysql-connect_timeout_server_max/1000 , the smaller of the two is used. (see #530)
  • if only one server is present in a hostgroup and mysql-shun_recovery_time_sec > 1 , the server is automatically brought back online after 1 second

즉, 최소 10초이상 경과후에 백앤드 서버는 자동적으로 온라인 상태로 리커버리 된다.