4

I have MS Azure MySQL Flexible server running in Azure with 4vCPU and 32GB of RAM.

It consumes all memory it gets and definitely is choking at lower configurations than 32GB, which seems to be an overkill for the use. Most of the workload is inserting/updating data.

I've tried to understand what exactly is using my memory and was playing with innodb_buffer_pool_size assuming it is a problem but even at 32GB host and innodb_buffer_pool_size = 6.5GB memory is quickly drained.

Basic memory troubleshooting guidelines does not give me a clear answer. I suspect tmp_tables but can't figure out how to determine where exactly is the rest of the memory allocated.

Microsoft Support is not helpful with telling me solutions or recommendations from documentation which does not work.

Here it is what the basic memory allocation check shows:

basic memory allocation check

I tried most of the checks based on the other similar threads. I tried to reduce the size of the memory in host but with 16GB the system ran out of memory seen by missing metrics in Azure.

This is an Azure PaaS service, but I guess it runs on Linux, storage is provided as part of the service.


SELECT COUNT(*), sum(data_length), sum(index_length), sum(data_free)
FROM information_schema.tables;
COUNT(*) sum(data_length) sum(index_length) sum(data_free)
668 106841464051 17000455168 776994816
SHOW GLOBAL STATUS;

https://justpaste.it/7oj0m

SHOW GLOBAL VARIABLES;

https://justpaste.it/5b8rb

SHOW FULL PROCESSLIST;

Only my session now on process list

STATUS;

https://justpaste.it/1u9z5

SHOW ENGINE INNODB STATUS; 

https://justpaste.it/6mr1z

2
  • Are other apps running (and consuming RAM) on the same server? What tells you "consumes all memory"? Do you begin transactions but fail to COMMIT them? Let's see some of the queries.
    – Rick James
    Apr 6 at 6:06
  • 1
    It runs on Azure and I can see the overall host memory consumption in % for the host. After a restart of service it uses as much as the innodb_buffer is set to (which is expected) but after 1-3 days of operations it hits almost 100% and keeps running like this.
    – ArUnio
    Apr 7 at 10:06

1 Answer 1

0
Analysis of GLOBAL STATUS and VARIABLES:

Observations:

  • Version: 5.7.40-log
  • 32 GB of RAM
  • Uptime = 1d 03:53:33
  • 43.6 QPS

The More Important Issues:

Well, nothing urgent. Here are the somewhat important ones:

innodb_lru_scan_depth = 256

If using SSD, not HDD:

innodb_io_capacity = 500
innodb_io_capacity_max = 4000
max_allowed_packet = 50M
max_connections = 50

Details and other observations:

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

( binlog_cache_size * max_connections ) = (8M * 300) / 32768M = 7.3% -- RAM used for caching transactions on the way to the binlog. -- Decrease binlog_cache_size (now 8388608) and/or max_connections (now 300)

( innodb_buffer_pool_size ) = 6,144M / 32768M = 18.8% -- % of RAM used for InnoDB buffer_pool -- Set to about 70% of available RAM. (Too low is less efficient; too high risks swapping.)

( innodb_lru_scan_depth * innodb_page_cleaners ) = 1,024 * 4 = 4,096 -- Amount of work for page cleaners every second. -- "InnoDB: page_cleaner: 1000ms intended loop took ..." may be fixable by lowering lru_scan_depth: Consider 1000 / innodb_page_cleaners (now 4). Also check for swapping.

( innodb_lru_scan_depth ) = 1,024 -- innodb_lru_scan_depth is a very poorly named variable. A better name would be innodb_free_page_target_per_buffer_pool. It is the number of pages InnoDB tries to keep free in each buffer pool instance to speed up read and page creation operations. -- "InnoDB: page_cleaner: 1000ms intended loop took ..." may be fixed by lowering lru_scan_depth

( innodb_io_capacity_max / innodb_io_capacity ) = 2,000 / 200 = 10 -- Capacity: max/plain -- Recommend 2. Max should be about equal to the IOPs your I/O subsystem can handle. (If the drive type is unknown 2000/200 may be a reasonable pair.)

( Innodb_buffer_pool_read_ahead_evicted / Innodb_buffer_pool_read_ahead ) = 34,621 / 50483 = 68.6% -- Utility of read_ahead. -- Turn off innodb_random_read_ahead (now OFF).

( innodb_doublewrite ) = innodb_doublewrite = OFF -- ON leads to extra I/O, but extra safety in crash. -- OFF is OK for FusionIO, Galera, Replicas, ZFS, EXT4.

( innodb_flush_method ) = innodb_flush_method = fsync -- How InnoDB should ask the OS to write blocks. Suggest O_DIRECT or O_ALL_DIRECT (Percona) to avoid double buffering. (At least for Unix.) See chrischandler for caveat about O_ALL_DIRECT

( innodb_io_capacity ) = 200 -- I/O ops per second capable on disk . 100 for slow drives; 200 for spinning drives; 1000-2000 for SSDs; multiply by RAID factor. Limits write IO requests per second (IOPS). -- For starters: HDD: 200; SSD: 2000.

( innodb_flush_log_at_trx_commit ) = 1 -- 1 = secure; 2 = faster -- (You decide) Use 1, along with sync_binlog (now 1)=1 for the greatest level of fault tolerance. 0 is best for speed. 2 is a compromise between 0 and 1.

( innodb_print_all_deadlocks ) = 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.

( innodb_purge_threads ) = 1 -- Number of threads to clean up history list. -- If you have a lot of writes, recommend 4 in versions 5.6 and 10.0 or later.

( max_allowed_packet ) = 1G / 32G = 3.1% -- If you do not have large blobs (etc) to load, then decrease the value. Else decrease innodb_buffer_pool_size (now 6442450944) to make room. Swapping is terrible for performance.

( character_set_client ) = character_set_client = latin1 -- -- If you will be using text from places other than Western Europe, consider switching to utf8mb4. (Beyond the scope of this discussion.)

( character_set_connection ) = character_set_connection = latin1 --

( character_set_results ) = character_set_results = latin1 --

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

( Com_delete / Com_insert ) = 275,515 / 10556 = 2610.0% -- Deletes / Inserts (as a pct). (Ignores LOAD, REPLACE, etc.)

( Com__biggest ) = Com__biggest = Com_update -- Which of the "Com_" metrics is biggest. -- Normally it is Com_select (now 440739). If something else, then it may be a sloppy platform, or may be something else.

( relay_log_space_limit ) = 1024M -- The max total size for relay logs on a Replica. (0=unlimited) -- Let's discuss the rationale for having a limit.

( slow_query_log ) = slow_query_log = OFF -- Whether to log slow queries. (5.1.12)

( long_query_time ) = 10 -- Cutoff (Seconds) for defining a "slow" query. -- Suggest 2

( log_slow_slave_statements ) = log_slow_slave_statements = OFF -- (5.6.11, 5.7.1) By default, replicated statements won't show up in the slowlog; this causes them to show. -- It can be helpful in the slowlog to see writes that could be interfering with Replica reads.

( Max_used_connections / max_connections ) = 7 / 300 = 2.3% -- Peak % of connections -- Since several memory factors can expand based on max_connections (now 300), it is good not to have that setting too high.

( thread_cache_size / Max_used_connections ) = 11 / 7 = 157.1% -- There is no advantage in having the thread cache bigger than your likely number of connections. Wasting space is the disadvantage.

Abnormally small:

(Com_select + Qcache_hits) / (Com_insert + Com_update + Com_delete + Com_replace) = 0.115
Com_show_fields = 0
Innodb_buffer_pool_pages_misc = 0
Innodb_buffer_pool_pages_misc * 16384 / innodb_buffer_pool_size = 0
Innodb_dblwr_pages_written = 0
net_buffer_length / max_allowed_packet = 0.00%

Abnormally large:

Com_change_repl_filter = 0.036 /HR
Com_lock_tables_for_backup = 0.072 /HR
Com_purge_before_date = 12 /HR
Com_show_master_status = 0.033 /sec
Com_show_open_tables = 0.036 /HR
Com_show_plugins = 18 /HR
Com_show_slave_status = 0.033 /sec
Com_show_status = 0.24 /sec
Com_show_warnings = 18 /HR
Com_slave_stop = 0.036 /HR
Handler_commit/Questions = 118.6%
Performance_schema_file_handles_lost = 248
Ssl_accepts = 14,343
Ssl_default_timeout = 7,200
Ssl_finished_accepts = 14,343
Ssl_session_cache_misses = 13,168
Ssl_session_cache_overflows = 211
Ssl_used_session_cache_entries = 49
Ssl_verify_depth = 1.84e+19
Ssl_verify_mode = 5
back_log / max_connections = 943.7%
binlog_cache_size = 8.39e+6
binlog_transaction_dependency_history_size = 32,000
net_read_timeout = 120
net_write_timeout = 240
slave_parallel_workers = 32
table_definition_cache = 10,000
table_open_cache / max_connections = 33.3

Abnormal strings:

auto_generate_certs = OFF
binlog_row_image = MINIMAL
binlog_transaction_dependency_tracking = WRITESET
core_file = ON
delay_key_write = OFF
disabled_storage_engines = MyISAM,MRG_MyISAM,BLACKHOLE,FEDEATED,ARCHIVE
innodb_fast_shutdown = 1
innodb_tmpdir = /mnt/temp
log_bin_trust_function_creators = ON
log_output = NONE
log_syslog = ON
lower_case_file_system = ON
lower_case_table_names = 1
opt_tf__dynamic_range = 
optimizer_trace = enabled=off,one_line=off
optimizer_trace_features = greedy_search=on,range_optimizer=on,dynamic_range=
relay_log_recovery = ON
require_secure_transport = ON
sha256_password_auto_generate_rsa_keys = OFF
slave_parallel_type = LOGICAL_CLOCK
slave_preserve_commit_order = ON
slave_rows_search_algorithms = TABLE_SCAN,INDEX_SCAN
sql_slave_skip_counter = 0
time_zone = +00:00
2
  • This is Azure Database for MySQL Flexible Server, much of this is set by Microsoft and quite a few bits can't be changed. This analysis doesn't really help identify endless memory growth.
    – badbod99
    Apr 11 at 10:40
  • @badbod99 - True. I ran the analysis because you provided the data; sometimes, interesting things pop out of the data. Alas, nothing exciting popped out this time. Memory leaks are hard to chase down; they may have come from the underlying MySQL, or maybe from Microsoft.
    – Rick James
    Apr 11 at 17:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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