Jsh0s
Jsh0s

Reputation: 599

How to decrease MySQL container memory usage?

Problem:

MySQL is taking over 350MB on idle, as shown in docker stats

Tried:

Tweaking the configuration file as suggested in posts like this one.


Added these lines to the file: /etc/mysql/my.cnf

innodb_buffer_pool_size=64M
innodb_log_buffer_size=256K
max_connections=5
key_buffer_size=8
thread_cache_size=0
host_cache_size=0
innodb_ft_cache_size=1600000
innodb_ft_total_cache_size=32000000
thread_stack=131072
sort_buffer_size=32K
read_buffer_size=8200
read_rnd_buffer_size=8200
max_heap_table_size=16K
tmp_table_size=1K
bulk_insert_buffer_size=0
join_buffer_size=128
net_buffer_length=1K
innodb_sort_buffer_size=64K

Dockerfile

FROM mysql
COPY my.cnf /etc/mysql/

Actual:

I made sure my.cnf changes were in the container, however its still taking over 350MB idle, is it possible to get it below that or am I trying something just not possible?

Upvotes: 0

Views: 9224

Answers (3)

Mark Muizer
Mark Muizer

Reputation: 11

A lot of these tags can be used as commands in your docker-compose or Dockerfile actually.

Use docker run -it --rm mysql:8 --verbose --help to get all available commands for mysql 8 for example. For me, --skip-performance-schema and --skip-mysqlx were sufficient to cut mem usage by 2/3!

Upvotes: 1

Mehmet Gökalp
Mehmet Gökalp

Reputation: 464

Prepared repository: https://github.com/alexanderkoller/low-memory-mysql

Before using this repository's configurations memory is about 458Mib/s After: 31.12Mib/s

Tested on mysql 5.6

Upvotes: 5

Natarajan N Napoleon
Natarajan N Napoleon

Reputation: 367

You can try and appropriately reduce footage.

https://github.com/major/MySQLTuner-perl

Upvotes: 0

Related Questions