Mariadb – High memory usage in Masters with MariaDB and Vitess

mariadbmaster-slave-replicationmemory

I'm running a Kubernetes Cluster with MariaDB 10.3.20 and Vitess 6. Everything is running fine, but the memory usage in the Master nodes is always around 90%. I don't have OOM right now, but I was keen to understand this high memory usage.

Currently, each node (master and replica) has the same configuration of 10GB RAM and 10 CPU cores. The MariaDB configurations, for now, are the default ones (innodb_buffer_pool_size has 128MB, I will try to update to 70% of the node memory), except for the number of max_connections which is set to 15758.

The data inside database is bellow 1GB and 5 tables. SELECT peak is around 700 queries per seconds, INSERT peak is around 200 QPS and UPDATE 100 QPS.

Masters are receiving only writes (INSERT, UPDATE, DELETE) and replicas are receiving only reads (SELECT).

Below are two charts for memory usage (the top ones are masters, the ones at the bottom are replicas).

The master's memory does an interesting "pattern" every week, not sure why.

I've tried to understand this behavior, reading MariaDB Memory Allocation, but couldn't anything that could explain this.

enter image description here

The chart below has a span of 15 days.
enter image description here

Best Answer

max_connections which is set to 15758.

Far too high. Try 200.

Do those interesting mem spikes correspond to big queries? Or garbage collection in Vitess? "Every week" sounds like a backup by the host?

Do increase the buffer_pool to 2G, but not until you get the memory under control.

That the heck are those 12 things in the first image?