8

A little backstory, some time ago we started to experience high CPU system time on one of our MySQL databases. This database was also suffering from high disk utilization so we figured that those things are connected. And since we already had plans to migrate it to SSD we thought that it will solve both issues.

It helped... but not for long.

For a couple of weeks after migration CPU graph was like this: good cpu load graph

But now we are back to this: bad cpu load graph

This happened out of nowhere, without any apparent changes in load or application logic.

DB stats:

  • MySQL version - 5.7.20
  • OS - Debian
  • DB size - 1.2Tb
  • RAM - 700Gb
  • CPU cores - 56
  • Peek load - about 5kq/s read, 600q/s write (although select queries are often pretty complex)
  • Threads - 50 running, 300 connected
  • It has about 300 tables, all InnoDB

MySQL config:

[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

[mysqld_safe]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /opt/mysql-data
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
explicit_defaults_for_timestamp

sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

log-error = /opt/mysql-log/error.log

# Replication

server-id = 76

gtid-mode = ON
enforce-gtid-consistency = true

relay-log = /opt/mysql-log/mysql-relay-bin
relay-log-index = /opt/mysql-log/mysql-relay-bin.index
replicate-wild-do-table = dbname.%

log-bin = /opt/mysql-log/mysql-bin.log
expire_logs_days = 7
max_binlog_size = 1024M
binlog-format = ROW
log-bin-trust-function-creators = 1
log_slave_updates = 1

# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/

# Here goes

skip_name_resolve = 1
general_log = 0
slow_query_log = 1
slow_query_log_file = /opt/mysql-log/slow.log
long_query_time = 3

max_allowed_packet = 16M
max_connections = 700
max_execution_time = 200000

open_files_limit = 32000
table_open_cache = 8000
thread_cache_size = 128
innodb_buffer_pool_size = 550G
innodb_buffer_pool_instances = 28
innodb_log_file_size = 15G
innodb_log_files_in_group = 2
innodb_flush_method = O_DIRECT

max_heap_table_size = 16M
tmp_table_size = 128M
join_buffer_size = 1M
sort_buffer_size = 2M

innodb_lru_scan_depth = 256

query_cache_type = 0
query_cache_size = 0

innodb_temp_data_file_path = ibtmp1:12M:autoextend:max:30G 

Other observations

perf of mysql process during peak load:

68,31%    68,31%  mysqld  [kernel.kallsyms]    [k] _raw_spin_lock                                                                                                                                                                                                        
   - _raw_spin_lock                                                                                                                                                                                                                                                          
      + 51,63% 0x7fd118e9dbd9                                                                                                                                                                                                                                                
      + 48,37% 0x7fd118e9dbab                                                                                                                                                                                                                                                
+   37,36%     0,02%  mysqld  libc-2.19.so         [.] 0x00000000000f4bd9                                                                                                                                                                                                    
+   33,83%     0,01%  mysqld  libc-2.19.so         [.] 0x00000000000f4bab                                                                                                                                                                                                    
+   26,92%     0,00%  mysqld  libpthread-2.19.so   [.] start_thread                                                                                                                                                                                                          
+   26,82%     0,00%  mysqld  mysqld               [.] pfs_spawn_thread                                                                                                                                                                                                      
+   26,82%     0,00%  mysqld  mysqld               [.] handle_connection                                                                                                                                                                                                     
+   26,81%     0,01%  mysqld  mysqld               [.] do_command(THD*)                                                                                                                                                                                                      
+   26,65%     0,02%  mysqld  mysqld               [.] dispatch_command(THD*, COM_DATA const*, enum_server_command)                                                                                                                                                          
+   26,29%     0,01%  mysqld  mysqld               [.] mysql_parse(THD*, Parser_state*)                                                                                                                                                                                      
+   24,85%     0,01%  mysqld  mysqld               [.] mysql_execute_command(THD*, bool)                                                                                                                                                                                     
+   23,61%     0,00%  mysqld  mysqld               [.] handle_query(THD*, LEX*, Query_result*, unsigned long long, unsigned long long)                                                                                                                                       
+   23,54%     0,00%  mysqld  mysqld               [.] 0x0000000000374103                                                                                                                                                                                                    
+   19,78%     0,00%  mysqld  mysqld               [.] JOIN::exec()                                                                                                                                                                                                          
+   19,13%     0,15%  mysqld  mysqld               [.] sub_select(JOIN*, QEP_TAB*, bool)                                                                                                                                                                                     
+   13,86%     1,48%  mysqld  mysqld               [.] row_search_mvcc(unsigned char*, page_cur_mode_t, row_prebuilt_t*, unsigned long, unsigned long)                                                                                                                       
+    8,48%     0,25%  mysqld  mysqld               [.] ha_innobase::general_fetch(unsigned char*, unsigned int, unsigned int)                                                                                                                                                
+    7,93%     0,00%  mysqld  [unknown]            [.] 0x00007f40c4d7a6f8                                                                                                                                                                                                    
+    7,57%     0,00%  mysqld  mysqld               [.] 0x0000000000828f74                                                                                                                                                                                                    
+    7,25%     0,11%  mysqld  mysqld               [.] handler::ha_index_next_same(unsigned char*, unsigned char const*, unsigned int)                                                                                                                                       

It shows that mysql is spending a lot of time on spin_locks. I was hoping to get some clue on where are those locks are coming from, sadly, no luck.

Query profile during high load shows extreme amount of context switches. I used select * from MyTable where pk = 123, MyTable has about 90M rows. Profile output:

Status               Duration CPU_user CPU_system Context_voluntary Context_involuntary Block_ops_in Block_ops_out Messages_sent Messages_received Page_faults_major Page_faults_minor Swaps Source_function       Source_file          Source_line
starting             0,000756 0,028000 0,012000   81                1                   0            0             0             0                 0                 0                 0                             
checking permissions 0,000057 0,004000 0,000000   4                 0                   0            0             0             0                 0                 0                 0     check_access          sql_authorization.cc 810
Opening tables       0,000285 0,008000 0,004000   31                0                   0            40            0             0                 0                 0                 0     open_tables           sql_base.cc          5650
init                 0,000304 0,012000 0,004000   31                1                   0            0             0             0                 0                 0                 0     handle_query          sql_select.cc        121
System lock          0,000303 0,012000 0,004000   33                0                   0            0             0             0                 0                 0                 0     mysql_lock_tables     lock.cc              323
optimizing           0,000196 0,008000 0,004000   20                0                   0            0             0             0                 0                 0                 0     optimize              sql_optimizer.cc     151
statistics           0,000885 0,036000 0,012000   99                6                   0            0             0             0                 0                 0                 0     optimize              sql_optimizer.cc     367
preparing            0,000794 0,000000 0,096000   76                2                   32           8             0             0                 0                 0                 0     optimize              sql_optimizer.cc     475
executing            0,000067 0,000000 0,000000   10                1                   0            0             0             0                 0                 0                 0     exec                  sql_executor.cc      119
Sending data         0,000469 0,000000 0,000000   54                1                   32           0             0             0                 0                 0                 0     exec                  sql_executor.cc      195
end                  0,000609 0,000000 0,016000   64                4                   0            0             0             0                 0                 0                 0     handle_query          sql_select.cc        199
query end            0,000063 0,000000 0,000000   3                 1                   0            0             0             0                 0                 0                 0     mysql_execute_command sql_parse.cc         4968
closing tables       0,000156 0,000000 0,000000   20                4                   0            0             0             0                 0                 0                 0     mysql_execute_command sql_parse.cc         5020
freeing items        0,000071 0,000000 0,004000   7                 1                   0            0             0             0                 0                 0                 0     mysql_parse           sql_parse.cc         5596
cleaning up          0,000533 0,024000 0,008000   62                0                   0            0             0             0                 0                 0                 0     dispatch_command      sql_parse.cc         1902

Peter Zaitsev made a post recently about context switches, where he says:

In the real world, though, I would not worry about contention being a big issue if you have less than ten context switches per query.

But it shows more than 600 switches!

What can cause these symptoms and what can be done about it? I`ll appreciate any pointers or info on the matter, everything that I come across so far is rather old and/or inconclusive.

P.S. I will gladly provide additional information, if required.

Output of SHOW GLOBAL STATUS and SHOW VARIABLES

I cannot post it here because contents exceed post size limit.

SHOW GLOBAL STATUS
SHOW VARIABLES

iostat

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           7,35    0,00    5,44    0,20    0,00   87,01

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
fd0               0,00     0,00    0,00    0,00     0,00     0,00     8,00     0,00   32,00   32,00    0,00  32,00   0,00
sda               0,04     2,27    0,13    0,96     0,86    46,52    87,05     0,00    2,52    0,41    2,80   0,28   0,03
sdb               0,21   232,57   30,86  482,91   503,42  7769,88    32,21     0,34    0,67    0,83    0,66   0,34  17,50

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           9,98    0,00   77,52    0,46    0,00   12,04

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
fd0               0,00     0,00    0,00    0,00     0,00     0,00     0,00     0,00    0,00    0,00    0,00   0,00   0,00
sda               0,00     1,60    0,00    0,60     0,00     8,80    29,33     0,00    0,00    0,00    0,00   0,00   0,00
sdb               0,00   566,40   55,60  981,60   889,60 16173,60    32,90     0,84    0,81    0,76    0,81   0,51  53,28

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          11,83    0,00   72,72    0,35    0,00   15,10

Device:         rrqm/s   wrqm/s     r/s     w/s    rkB/s    wkB/s avgrq-sz avgqu-sz   await r_await w_await  svctm  %util
fd0               0,00     0,00    0,00    0,00     0,00     0,00     0,00     0,00    0,00    0,00    0,00   0,00   0,00
sda               0,00     2,60    0,00    0,40     0,00    12,00    60,00     0,00    0,00    0,00    0,00   0,00   0,00
sdb               0,00   565,20   51,60  962,80   825,60 15569,60    32,32     0,85    0,84    0,98    0,83   0,54  54,56

Update 2018-03-15

> show global status like 'uptime%'
Uptime;720899
Uptime_since_flush_status;720899

> show global status like '%rollback'
Com_rollback;351422
Com_xa_rollback;0
Handler_rollback;371088
Handler_savepoint_rollback;0
  • How long (elapsed time) does select * from MyTable where pk = 123 take on average? – Rick James Jan 13 '18 at 22:58
  • 1
    @RickJames It takes about 5ms on average. – chimmi Jan 15 '18 at 16:09
  • 1
    @WilsonHauck Tests show about 30k write IOps. As for dirty pages, the amount of 9% that we have, doesnt seem like a problem to me. We discovered that after reboot CPU usage stays normal for about a week, so the plan is to wait for next reboot and monitor global status to see if anything correlates with increasing CPU usage. I dont believe anything can be achieved with the data available at the moment. I will ask another question if I find anything new. – chimmi Feb 22 '18 at 8:40
  • 1
    @WilsonHauck We had a reboot and it went like before: system time started growing. Still looking for the source of the issue. – chimmi Mar 13 '18 at 8:17
  • 1
    @WilsonHauck Question updated. – chimmi Mar 15 '18 at 10:39
6

600q/s write with a flush per commit is probably hitting the limit of your current spinning disks. Switching to SSDs would relieve the pressure.

The quick fix (before getting SSDs) is probably to change to this setting:

innodb_flush_log_at_trx_commit = 2

But read the caveats on making that change.

Having that setting and SSDs would let you grow further.

Another possible fix is to combine some writes into a single COMMIT (where the logic is not violated).

Almost always, high CPU and/or I/O is due to poor indexes and/or poor formulation of queries. Turn on the slowlog with long_query_time=1, wait a while, then see what turns up. With queries in hand, provide SELECT, EXPLAIN SELECT ..., and SHOW CREATE TABLE. Ditto for the write queries. From those, we can probably tame the CPU and/or I/O. Even with your current setting of 3, pt-query-digest might find some interesting things.

Note that with 50 "running" threads, there is a lot of contention; this may be causing the switching, etc, that you noted. We need to get queries to finish faster. With 5.7, the system may keel over with 100 running threads. Increasing beyond about 64, the context switches, mutexes, locks, etc, conspire to slow down every thread, leading to no improvement in throughput while latency goes through the roof.

For a different approach to analyzing the problem, please provide SHOW VARIABLES and SHOW GLOBAL STATUS? More discussion here.

Analysis of VARIABLES & STATUS

(Sorry, nothing jumps out as addressing your Question.)

Observations:

  • Version: 5.7.20-log
  • 700 GB of RAM
  • Uptime = 36d 13:21:34
  • You are not running on Windows.
  • Running 64-bit version
  • You appear to be running entirely (or mostly) InnoDB.

The More Important Issues:

A lot of temp tables, especially disk-based, are created for complex queries. Let's hope that the slow log will identifiy some queries that can be improved (via indexing / reformulating / etc.) Other indicators are joins without indexes and sort_merge_passes; however, neither of these is conclusive, we need to see the queries.

Max_used_connections = 701 is >= Max_connections = 700, so there were probably some connections refused. Also, if that indicated more than, say, 64 threads running, then system performance probably sufferd at that time. Consider throttling the number of connections by throttling the clients. Are you using Apache, Tomcat, or something else? 70 Threads_running indicates that, at the moment of doing this SHOW, the system was in trouble.

Increasing the number of statements in each COMMIT (when reasonable) may help performance some.

innodb_log_file_size, at 15GB, is bigger than necessary, but I see not need to change it.

Thousands of tables is usually not a good design.

eq_range_index_dive_limit = 200 concerns me, but I don't know how to advise. Was it a deliberate choice?

Why so many CREATE+DROP PROCEDURE ?

Why so many SHOW commands?

Details and other observations:

( Innodb_buffer_pool_pages_flushed ) = 523,716,598 / 3158494 = 165 /sec -- Writes (flushes) -- check innodb_buffer_pool_size

( table_open_cache ) = 10,000 -- Number of table descriptors to cache -- Several hundred is usually good.

( (Innodb_buffer_pool_reads + Innodb_buffer_pool_pages_flushed) ) = ((61,040,718 + 523,716,598) ) / 3158494 = 185 /sec -- InnoDB I/O

( Innodb_dblwr_pages_written/Innodb_pages_written ) = 459,782,684/523,717,889 = 87.8% -- Seems like these values should be equal?

( Innodb_os_log_written ) = 1,071,443,919,360 / 3158494 = 339226 /sec -- This is an indicator of how busy InnoDB is. -- Very busy InnoDB.

( Innodb_log_writes ) = 110,905,716 / 3158494 = 35 /sec

( Innodb_os_log_written / (Uptime / 3600) / innodb_log_files_in_group / innodb_log_file_size ) = 1,071,443,919,360 / (3158494 / 3600) / 2 / 15360M = 0.0379 -- Ratio -- (see minutes)

( Uptime / 60 * innodb_log_file_size / Innodb_os_log_written ) = 3,158,494 / 60 * 15360M / 1071443919360 = 791 -- Minutes between InnoDB log rotations Beginning with 5.6.8, this can be changed dynamically; be sure to also change my.cnf. -- (The recommendation of 60 minutes between rotations is somewhat arbitrary.) Adjust innodb_log_file_size. (Cannot change in AWS.)

( Com_rollback ) = 770,457 / 3158494 = 0.24 /sec -- ROLLBACKs in InnoDB. -- An excessive frequency of rollbacks may indicate inefficient app logic.

( Innodb_row_lock_waits ) = 632,292 / 3158494 = 0.2 /sec -- How often there is a delay in getting a row lock. -- May be caused by complex queries that could be optimized.

( Innodb_dblwr_writes ) = 97,725,876 / 3158494 = 31 /sec -- "Doublewrite buffer" writes to disk. "Doublewrites" are a reliability feature. Some newer versions / configurations don't need them. -- (Symptom of other issues)

( Innodb_row_lock_current_waits ) = 13 -- The number of row locks currently being waited for by operations on InnoDB tables. Zero is pretty normal. -- Something big is going on?

( innodb_print_all_deadlocks ) = OFF -- Whether to log all Deadlocks. -- If you are plagued with Deadlocks, turn this on. Caution: If you have lots of deadlocks, this may write a lot to disk.

( local_infile ) = ON -- local_infile = ON is a potential security issue

( bulk_insert_buffer_size / _ram ) = 8M / 716800M = 0.00% -- Buffer for multi-row INSERTs and LOAD DATA -- Too big could threaten RAM size. Too small could hinder such operations.

( Questions ) = 9,658,430,713 / 3158494 = 3057 /sec -- Queries (outside SP) -- "qps" -- >2000 may be stressing server

( Queries ) = 9,678,805,194 / 3158494 = 3064 /sec -- Queries (including inside SP) -- >3000 may be stressing server

( Created_tmp_tables ) = 1,107,271,497 / 3158494 = 350 /sec -- Frequency of creating "temp" tables as part of complex SELECTs.

( Created_tmp_disk_tables ) = 297,023,373 / 3158494 = 94 /sec -- Frequency of creating disk "temp" tables as part of complex SELECTs -- increase tmp_table_size and max_heap_table_size. Check the rules for temp tables on when MEMORY is used instead of MyISAM. Perhaps minor schema or query changes can avoid MyISAM. Better indexes and reformulation of queries are more likely to help.

( (Com_insert + Com_update + Com_delete + Com_replace) / Com_commit ) = (693300264 + 214511608 + 37537668 + 0) / 1672382928 = 0.565 -- Statements per Commit (assuming all InnoDB) -- Low: Might help to group queries together in transactions; High: long transactions strain various things.

( Select_full_join ) = 338,957,314 / 3158494 = 107 /sec -- joins without index -- Add suitable index(es) to tables used in JOINs.

( Select_full_join / Com_select ) = 338,957,314 / 6763083714 = 5.0% -- % of selects that are indexless join -- Add suitable index(es) to tables used in JOINs.

( Select_scan ) = 124,606,973 / 3158494 = 39 /sec -- full table scans -- Add indexes / optimize queries (unless they are tiny tables)

( Sort_merge_passes ) = 1,136,548 / 3158494 = 0.36 /sec -- Heafty sorts -- Increase sort_buffer_size and/or optimize complex queries.

( Com_insert + Com_delete + Com_delete_multi + Com_replace + Com_update + Com_update_multi ) = (693300264 + 37537668 + 198418338 + 0 + 214511608 + 79274476) / 3158494 = 387 /sec -- writes/sec -- 50 writes/sec + log flushes will probably max out I/O write capacity of normal drives

( ( Com_stmt_prepare - Com_stmt_close ) / ( Com_stmt_prepare + Com_stmt_close ) ) = ( 39 - 38 ) / ( 39 + 38 ) = 1.3% -- Are you closing your prepared statements? -- Add Closes.

( Com_stmt_close / Com_stmt_prepare ) = 38 / 39 = 97.4% -- Prepared statements should be Closed. -- Check whether all Prepared statements are "Closed".

( innodb_autoinc_lock_mode ) = 1 -- Galera: desires 2 -- 2 = "interleaved"; 1 = "consecutive" is typical; 0 = "traditional".

( Max_used_connections / max_connections ) = 701 / 700 = 100.1% -- Peak % of connections -- increase max_connections and/or decrease wait_timeout

( Threads_running - 1 ) = 71 - 1 = 70 -- Active threads (concurrency when data collected) -- Optimize queries and/or schema

Abnormally large: (Most of these stem from being a very busy system.)

Com_commit = 529 /sec
Com_create_procedure = 0.01 /HR
Com_drop_procedure = 0.01 /HR
Com_delete = 12 /sec
Com_delete_multi = 63 /sec
Com_insert = 219 /sec
Com_kill = 0.69 /HR
Com_reset = 0.0011 /HR
Com_revoke = 0.0023 /HR
Com_select = 2141 /sec
Com_show_binlogs = 12 /HR
Com_show_create_func = 0.011 /HR
Com_show_privileges = 0.0034 /HR
Com_show_profile = 0.027 /HR
Com_show_profiles = 0.028 /HR
Com_show_slave_status = 0.037 /sec
Com_show_storage_engines = 12 /HR
Com_show_warnings = 0.14 /sec
Com_slave_stop = 0.0011 /HR
Com_update_multi = 25 /sec
Created_tmp_files = 0.3 /sec
Handler_commit = 3251 /sec
Handler_external_lock = 18787 /sec
Handler_prepare = 615 /sec
Handler_read_first = 239 /sec
Handler_read_key = 173669 /sec
Handler_read_next = 1291439 /sec
Handler_read_prev = 28535 /sec
Handler_read_rnd = 32789 /sec

(continued)

Innodb_buffer_pool_bytes_dirty = 7.03e+10
Innodb_buffer_pool_pages_data = 3.41e+7
Innodb_buffer_pool_pages_dirty = 4.29e+6
Innodb_buffer_pool_pages_misc = 2.15e+6
Innodb_buffer_pool_pages_total = 3.62e+7
Innodb_data_fsyncs = 132 /sec
Innodb_data_writes = 232 /sec
Innodb_data_written = 5440151 /sec
Innodb_dblwr_pages_written = 145 /sec
Innodb_os_log_written / (Uptime / 3600) / innodb_log_files_in_group = 582.3MB
Innodb_pages_written = 165 /sec
Innodb_row_lock_time = 5.97e+7
Innodb_rows_deleted + Innodb_rows_inserted = 2180 /sec
Innodb_rows_inserted = 2155 /sec
Innodb_rows_read = 1398531 /sec
Max_used_connections = 701
Open_tables = 10,000
Select_full_range_join = 2.57e+7
Select_range = 130 /sec
Sort_range = 30 /sec
Sort_scan = 332 /sec
Table_open_cache_hits = 9354 /sec
Threads_running = 71
eq_range_index_dive_limit = 200
innodb_purge_threads = 4
innodb_thread_sleep_delay = 16,925
  • 1
    Yes, thank you, I appreciate your work. Unfortunately, I dont see anything that can explain our sudden change in CPU usage (which happened basically overnight without apparent changes to DB size or load or application). innodb_flush_log_at_trx_commit = 2 does not seem to have any effect and thread contention also does not seem to be the issue because even at moderate loads (Threads runnig < 50) CPU sys/CPU user is something like 3 to 1. – chimmi Jan 17 '18 at 6:16
4

We never figured out what was the exact cause of this issue, but to offer some closure I`m going to tell what I can.

Our team made some load tests and concluded that MySQL had troubles allocating memory. So they tried using jemalloc instead of glibc and the problem disappeared. We have been using jemalloc in production more than 6 month now, without ever seeing this issue again.

I'm not saying that jemalloc is better, or that everyone should use it with MySQL. But it seems like for our specific case glibc just wasn't working properly .

2
+25

My 2cents.

Run "iostat -xk 5" to try to see if the disk still a problem. Also the CPU system is related to system code (kernell), double check the new disk/drivers/config.

  • 1
    iostat does not show any big numbers. – chimmi Jan 17 '18 at 14:02
  • yup i can see the iostat above but the numbers displaied does not match the graph. Did you run the iostat at the same time frame? – andres Jan 17 '18 at 22:26
  • 1
    More or less, we made some changes to application to lower number of queries that hit this DB, so CPU does not stick at 100% no more. I have attached another iostat output, at the moment average CPU was at 75%, 60% system. – chimmi Jan 18 '18 at 6:49
0

Suggestions for my.cnf/ini [mysqld] section for your VERY BUSY

max_heap_table_size=128M  # from 16M to match tmp_table_size
innodb_lru_scan_depth=100  # from 256 to reduce depth every second
innodb_change_buffer_max_size=15  # from 25 max used misc is 6%
innodb_flush_neighbors=0  # from 1 with SSD there is no rotational delay
innodb_read_ahead_threshold=8  # from 56 to expedite RD nxt extent
read_rnd_buffer_size=128K  # from 256K to reduce RD RPS

My expectation is a gradual decrease in results of SHOW GLOBAL STATUS LIKE 'innodb_buffer_pool_pages_dirty'; with these suggestions applied. On 1/13/18 you had over 4M dirty pages.

I hope these help. These may be dynamically modified. Many more opportunities exist, if you want them, let me know.

  • Thanks for your suggestions, but this issue was resolved long ago. See my answer for details. – chimmi Nov 16 '18 at 10:59
0

With IOPS at 30K tested (we need a number of IOPS for Random Writes), consider this Suggestion for my.cnf/ini [mysqld] section

innodb_io_capacity_max=20000  # from 2000 and keep top 10000 free for now
innodb_io_capacity=10000  # from 200 to ensure we stay away from the limits

may be Dynamically changed with SET GLOBAL and should reduce innodb_buffer_pool_pages_dirty rapidly.

The cause of COM_ROLLBACK averaging 1 every 4 seconds will remain a performance problem until resolved.

@chimmi Apr 9, 2018 Pick up this MySQL script from https://pastebin.com/aZAu2zZ0 for a quick check on Global Status resources used or released for nn seconds you can set in SLEEP. This will allow you to see if anyone has helped reduce your COM_ROLLBACK frequency. Would like to hear from you by email.

  • @chimmi Please start a new Question with Additional information request, please. Post on pastebin.com or here. complete (not edited) my.cnf-ini Text results of: A) SHOW GLOBAL STATUS; B) SHOW GLOBAL VARIABLES; C) complete MySQLTuner.com report if readily available - 7 or more days uptime is helpful D) SHOW ENGINE INNODB STATUS; Optional very helpful information, if available includes - htop OR top for most active apps, ulimit -a for a list of limits, df -h for a free space list by device, free -m for a linux/unix free memory for current server analysis. – Wilson Hauck May 9 '18 at 11:47
  • @chimmi Also, please post cat/proc/meminfo for context switch counts. Let me know the link for the new question, please. Thanks – Wilson Hauck May 9 '18 at 11:49
0

Your SHOW GLOBAL STATUS indicates innodb_buffer_pool_pages_dirty were 4,291,574.

To monitor current count,

SHOW GLOBAL STATUS LIKE '%pages_dirty';

To encourage reducing this count,

SET GLOBAL innodb_flushing_avg_loops=5;

In one hour run the monitor request to see where you stand with pages dirty.

Please let me know your counts at beginning and an hour later.

Apply the change to your my.cnf for long term better health of pages dirty reduction.

  • @chimmi Thanks for sharing the jemalloc primary resolution. This monitoring process for pages_dirty could be helpful to your production environment. Please give try it and share your numbers with me. Thanks – Wilson Hauck Nov 16 '18 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.