環境: MySQL5.7,Ubuntu16 64位操做系統,4核CPU,8G運行內存mysql
!includedir /etc/mysql/conf.d/ !includedir /etc/mysql/percona-server.conf.d/ [mysqld] max_connections=600 back_log=600 # default size is 170 max_allowed_packet=16M sort_buffer_size=2M join_buffer_size=2M thread_cache_size=300 max_prepared_stmt_count=20000
List-1sql
sysbench /usr/share/sysbench/oltp_read_write.lua --db-driver=mysql --table_size=1000000 --tables=4 --mysql-host=localhost --mysql-db=foo --mysql-user=root --mysql-password=密碼 prepare
List-2bash
sysbench /usr/share/sysbench/oltp_read_write.lua --num-threads=250 --db-driver=mysql --table_size=1000000 --tables=4 --mysql-host=localhost --mysql-db=foo --mysql-user=root --mysql-password=密碼 run
List-3 List-2的結果dom
WARNING: --num-threads is deprecated, use --threads instead sysbench 1.0.14 (using bundled LuaJIT 2.1.0-beta2) Running the test with following options: Number of threads: 250 Initializing random number generator from current time Initializing worker threads... Threads started! SQL statistics: queries performed: read: 63154 write: 18026 other: 9015 total: 90195 transactions: 4504 (442.58 per sec.) queries: 90195 (8862.98 per sec.) ignored errors: 7 (0.69 per sec.) reconnects: 0 (0.00 per sec.) General statistics: total time: 10.1751s total number of events: 4504 Latency (ms): min: 4.32 avg: 559.02 max: 5581.71 95th percentile: 1739.68 sum: 2517847.32 Threads fairness: events (avg/stddev): 18.0160/4.48 execution time (avg/stddev): 10.0714/0.04
List-4測試
sysbench /usr/share/sysbench/oltp_read_write.lua --db-driver=mysql --table_size=1000000 --tables=4 --mysql-host=localhost --mysql-db=foo --mysql-user=root --mysql-password=密碼 prepare
List-5lua
WARNING: --num-threads is deprecated, use --threads instead sysbench 1.0.14 (using bundled LuaJIT 2.1.0-beta2) Running the test with following options: Number of threads: 500 Initializing random number generator from current time Initializing worker threads... Threads started! SQL statistics: queries performed: read: 56126 write: 16001 other: 8006 total: 80133 transactions: 3997 (380.36 per sec.) queries: 80133 (7625.52 per sec.) ignored errors: 12 (1.14 per sec.) reconnects: 0 (0.00 per sec.) General statistics: total time: 10.5067s total number of events: 3997 Latency (ms): min: 8.67 avg: 1284.46 max: 10394.83 95th percentile: 4055.23 sum: 5133991.11 Threads fairness: events (avg/stddev): 7.9940/3.22 execution time (avg/stddev): 10.2680/0.14
從List-3和List-5看出,線程個數從250增長到500後:spa