【发布时间】:2018-11-23 21:10:22
【问题描述】:
关于
对于任何单个查询,MariaDB 服务器在大约 1 毫秒内完成每个请求。当并发增加时,每个请求的查询时间也会增加,直到超时。到目前为止,似乎只能为每个 mysql 服务器实例每秒进行大约 2k 的最大连接数,配置 tweeking 的数量似乎没有任何效果。有什么办法可以将每个客户端的查询时间减少不到 0.1ms?
这是查询
select ID from table where id=1;
如果有帮助,这里是mysql配置文件
[client]
port = 3306
socket = /home/user/mysql.sock
[mysqld]
port = 3306
bind-address=127.0.0.1
datadir=/home/user/database
log-error=/home/user/error.log
pid-file=/home/user/mysqld.pid
innodb_file_per_table=1
back_log = 2000
max_connections = 1000000
max_connect_errors = 10
table_open_cache = 2048
max_allowed_packet = 16M
binlog_cache_size = 1M
max_heap_table_size = 64M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
join_buffer_size = 8M
thread_cache_size = 8
thread_concurrency = 200
query_cache_size = 64M
query_cache_type = 1 #My settings
innodb_io_capacity = 100000
query_cache_limit = 2M
ft_min_word_len = 4
default-storage-engine = innodb
thread_stack = 240K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 64M
log-bin=mysql-bin
binlog_format=mixed
slow_query_log
long_query_time = 2
server-id = 1
key_buffer_size = 32M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
myisam_recover
innodb_buffer_pool_size = 2G
innodb_data_file_path = ibdata1:10M:autoextend
innodb_doublewrite = 0
sync_binlog=0
skip_name_resolve
innodb_write_io_threads = 500
innodb_read_io_threads = 500
innodb_thread_concurrency = 1000
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 8M
innodb_log_file_size = 256M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 81920
硬件
2x Intel Xeon 2670 32 Gb RAM 500Gb ssd ssd samsung evo 850
绕道
虽然 MySql 每秒可以执行超过 100 万次查询,但测试 here 只执行了 250 个连接的客户端。
【问题讨论】:
-
这仅限于您的硬件和配置。使用 1 个实例要跑得最快并不容易。如果您想每秒执行(接受)更多查询,则必须设置一个集群。简单的查询不会是最快的,但您可以一次接受更多。 mysql.com/fr/why-mysql/benchmarks/mysql-cluster
-
你执行什么样的连接是相同的过程?还是每个查询都有一个新的连接?
-
@DanB 太糟糕了,如果这只是我们可以用 mysql 服务器做多远。我有一个应用程序可以每秒进行 60-100k 连接,但是当连接到 mysql 时,它很难管理只有一个实例的连接,我同意你,集群可能是我的下一步。但是,如果有一个关系数据库服务器可以比 mysql 服务器为 1 个实例做得更好,那可能会很有趣。
-
@Alex 它是一个连接池,但我不管理该池。如果我没记错的话,游泳池大约是 16k。
-
“MariaDB 服务器在大约 1 毫秒内完成每个请求”——这看起来相当不错......
标签: mariadb database-performance