Tuning proxysql

1,089 views
Skip to first unread message

Bootleg Eighty Six

unread,
Sep 4, 2017, 9:01:14 PM9/4/17
to proxysql
It seems like the latency introduced by Proxysql is about 10 times slower than without?
Running a series of test with direct access to DB take 12 minutes but with Proxysql installed on the same server, it's taking 148 minutes.

Is there something wrong with my config?

Here's and output from global variables.

mysql> select * from global_variables order by variable_name;
+-----------------------------------------------------+------------------------------------------------------+
| variable_name                                       | variable_value                                       |
+-----------------------------------------------------+------------------------------------------------------+
| admin-admin_credentials                             | admin:admin                                          |
| admin-cluster_check_interval_ms                     | 1000                                                 |
| admin-cluster_password                              |                                                      |
| admin-cluster_username                              |                                                      |
| admin-hash_passwords                                | true                                                 |
| admin-mysql_ifaces                                  | 127.0.0.1:6032;/var/run/proxysql/proxysql_admin.sock |
| admin-read_only                                     | false                                                |
| admin-refresh_interval                              | 2000                                                 |
| admin-stats_credentials                             | stats:stats                                          |
| admin-telnet_admin_ifaces                           | (null)                                               |
| admin-telnet_stats_ifaces                           | (null)                                               |
| admin-version                                       | 1.4.1-45-gab4e6ee                                    |
| mysql-client_found_rows                             | true                                                 |
| mysql-commands_stats                                | true                                                 |
| mysql-connect_retries_delay                         | 1                                                    |
| mysql-connect_retries_on_failure                    | 10                                                   |
| mysql-connect_timeout_server                        | 1000                                                 |
| mysql-connect_timeout_server_max                    | 10000                                                |
| mysql-connection_delay_multiplex_ms                 | 0                                                    |
| mysql-connection_max_age_ms                         | 0                                                    |
| mysql-default_charset                               | utf8                                                 |
| mysql-default_max_latency_ms                        | 1000                                                 |
| mysql-default_query_delay                           | 0                                                    |
| mysql-default_query_timeout                         | 86400000                                             |
| mysql-default_reconnect                             | true                                                 |
| mysql-default_schema                                | information_schema                                   |
| mysql-default_sql_mode                              |                                                      |
| mysql-default_time_zone                             | SYSTEM                                               |
| mysql-enforce_autocommit_on_reads                   | false                                                |
| mysql-eventslog_filename                            |                                                      |
| mysql-eventslog_filesize                            | 104857600                                            |
| mysql-forward_autocommit                            | false                                                |
| mysql-free_connections_pct                          | 10                                                   |
| mysql-have_compress                                 | true                                                 |
| mysql-hostgroup_manager_verbose                     | 1                                                    |
| mysql-init_connect                                  | (null)                                               |
| mysql-interfaces                                    | 0.0.0.0:3306;/var/run/proxysql/proxysql.sock         |
| mysql-long_query_time                               | 1000                                                 |
| mysql-max_allowed_packet                            | 4194304                                              |
| mysql-max_connections                               | 10000                                                |
| mysql-max_stmts_cache                               | 10000                                                |
| mysql-max_stmts_per_connection                      | 20                                                   |
| mysql-max_transaction_time                          | 14400000                                             |
| mysql-mirror_max_concurrency                        | 16                                                   |
| mysql-mirror_max_queue_length                       | 32000                                                |
| mysql-monitor_connect_interval                      | 120000                                               |
| mysql-monitor_connect_timeout                       | 600                                                  |
| mysql-monitor_enabled                               | true                                                 |
| mysql-monitor_groupreplication_healthcheck_interval | 5000                                                 |
| mysql-monitor_groupreplication_healthcheck_timeout  | 800                                                  |
| mysql-monitor_history                               | 600000                                               |
| mysql-monitor_password                              | admin                                                |
| mysql-monitor_ping_interval                         | 60000                                                |
| mysql-monitor_ping_max_failures                     | 3                                                    |
| mysql-monitor_ping_timeout                          | 1000                                                 |
| mysql-monitor_query_interval                        | 60000                                                |
| mysql-monitor_query_timeout                         | 100                                                  |
| mysql-monitor_read_only_interval                    | 1000                                                 |
| mysql-monitor_read_only_timeout                     | 800                                                  |
| mysql-monitor_replication_lag_interval              | 10000                                                |
| mysql-monitor_replication_lag_timeout               | 1000                                                 |
| mysql-monitor_slave_lag_when_null                   | 60                                                   |
| mysql-monitor_username                              | admin                                                |
| mysql-monitor_wait_timeout                          | true                                                 |
| mysql-monitor_writer_is_also_reader                 | true                                                 |
| mysql-multiplexing                                  | true                                                 |
| mysql-ping_interval_server_msec                     | 10000                                                |
| mysql-ping_timeout_server                           | 200                                                  |
| mysql-poll_timeout                                  | 2000                                                 |
| mysql-poll_timeout_on_failure                       | 100                                                  |
| mysql-query_cache_size_MB                           | 256                                                  |
| mysql-query_digests                                 | true                                                 |
| mysql-query_digests_lowercase                       | false                                                |
| mysql-query_digests_max_digest_length               | 2048                                                 |
| mysql-query_digests_max_query_length                | 65000                                                |
| mysql-query_processor_iterations                    | 0                                                    |
| mysql-query_processor_regex                         | 1                                                    |
| mysql-query_retries_on_failure                      | 1                                                    |
| mysql-server_capabilities                           | 45578                                                |
| mysql-server_version                                | 5.5.30                                               |
| mysql-servers_stats                                 | true                                                 |
| mysql-session_idle_ms                               | 1000                                                 |
| mysql-session_idle_show_processlist                 | true                                                 |
| mysql-sessions_sort                                 | true                                                 |
| mysql-shun_on_failures                              | 5                                                    |
| mysql-shun_recovery_time_sec                        | 10                                                   |
| mysql-ssl_p2s_ca                                    | (null)                                               |
| mysql-ssl_p2s_cert                                  | (null)                                               |
| mysql-ssl_p2s_cipher                                | (null)                                               |
| mysql-ssl_p2s_key                                   | (null)                                               |
| mysql-stacksize                                     | 1048576                                              |
| mysql-threads                                       | 4                                                    |
| mysql-threshold_query_length                        | 524288                                               |
| mysql-threshold_resultset_size                      | 4194304                                              |
| mysql-wait_timeout                                  | 28800000                                             |
+-----------------------------------------------------+------------------------------------------------------+

mysql> select * from mysql_servers;
+--------------+-----------------------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| hostgroup_id | hostname                    | port | status | weight | compression | max_connections | max_replication_lag | use_ssl | max_latency_ms | comment |
+--------------+-----------------------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+
| 1            | /var/run/mysqld/mysqld.sock | 0    | ONLINE | 1      | 0           | 3000            | 10                  | 0       | 0              |
    |
+--------------+-----------------------------+------+--------+--------+-------------+-----------------+---------------------+---------+----------------+---------+

René Cannaò

unread,
Sep 4, 2017, 9:08:01 PM9/4/17
to Bootleg Eighty Six, proxysql
Hi.

Can you please share any further details to understand what your tests do, and what is the environment?
What hardware are you using?
Are you running client/proxy/server all in the same box?
What is the level of parallelism? (how many connections?)
More questions may follow, but the more you describe your setup and your tests, the easier will be to find an answer.

Thanks.

--
You received this message because you are subscribed to the Google Groups "proxysql" group.
To unsubscribe from this group and stop receiving emails from it, send an email to proxysql+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bootleg Eighty Six

unread,
Sep 4, 2017, 9:28:54 PM9/4/17
to proxysql
The test are doing select statements for each database.
For example
use db1;
select price from table1 where expiry > date1 and expiry < date2;

We have about 5000 tests doing these same things for each DB and each table and we expect a certain number of results from each query.

These are using c++ library for mysql https://dev.mysql.com/doc/refman/5.7/en/mysql-real-connect.html

I am running the the proxy and slave on the same box

/etc/mysql/my.cnf
port 3307

/etc/proxysql.cnf
        interfaces = "0.0.0.0:3306;/var/run/proxysql/proxysql.sock"

mysql_servers  = (
    {
        address="/var/run/mysqld/mysqld.sock"
        port=0
        hostgroup=1, max_connections=3000
        max_replication_lag=10
    }
)

The tests are running from cluster of 20 host so I guess we have max parallelism of 20 with each test making 1 connection.

Hope that's enough.

René Cannaò

unread,
Sep 4, 2017, 9:36:58 PM9/4/17
to Bootleg Eighty Six, proxysql
The first issue I see here is that without ProxySQL, mysqld can use all CPU resources, while with proxysql running on the same box there is CPU contention.
How many physical cores has this server?

How many databases/shards do you have in a single mysql server?

Bootleg Eighty Six

unread,
Sep 4, 2017, 10:18:17 PM9/4/17
to proxysql, boot...@gmail.com
Thanks for the prompt responses René . Much appreciated.
I don't think resource is an issue. htop shows low CPU usage and memory

Model name:            Intel(R) Xeon(R) CPU           X5675  @ 3.07GHz
CPU MHz:               3066.501
NUMA node0 CPU(s):     0-5
NUMA node1 CPU(s):     6-11

# free -h
             total       used       free     shared    buffers     cached
Mem:           47G        34G        12G       432M       354M        27G

I am not running a sharded DB. Everything is running on a single readonly slave.

Total size of DB is about 50G with about 80% of that data is in the top 50 databases out of a total of 150 databases.

One thing though, in order to test this, I changed /etc/hosts on test cluster to point to proxysql/mysql server.
So it might be a DNS resolution issue that slows things down. but I can't imagine that it will slow down this much.

This is what my stats look like.

hostgroup_id    hostname        port    status  weight  compression     max_connections max_replication_lag     use_ssl max_latency_ms  comment
1       /var/run/mysqld/mysqld.sock     0       ONLINE  1       0       3000    10      0       0
hostgroup       srv_host        srv_port        status  ConnUsed        ConnFree        ConnOK  ConnERR Queries Bytes_data_sent Bytes_data_recv Latency_us
1       /var/run/mysqld/mysqld.sock     0       ONLINE  0       9       9       0       1776372 785147591       1509177464      192

Thanks.
To unsubscribe from this group and stop receiving emails from it, send an email to proxysql+u...@googlegroups.com.

Bootleg Eighty Six

unread,
Sep 5, 2017, 1:27:00 AM9/5/17
to proxysql, boot...@gmail.com
Checking with strace

socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 22
connect(22, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("10.1.0.10")}, 16) = 0
.....
setsockopt(22, SOL_IP, IP_TOS, [8], 4)  = 0
setsockopt(22, SOL_TCP, TCP_NODELAY, [1], 4) = 0
setsockopt(22, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0

.....
read(22, "Z\0\0\2\377\25\4#28000ProxySQL Error: Acc"..., 16384) = 94


Seems like Proxysql can keep it's connections to mysql server?

Bootleg Eighty Six

unread,
Sep 5, 2017, 4:05:55 AM9/5/17
to proxysql, boot...@gmail.com
OK. False alarm here.
Seems like I have an outdated user list and tests is using new user, hence, they were connecting and failing and then trying again.

I failed to catch this in the logs.

Thanks everyone.
Reply all
Reply to author
Forward
0 new messages