Debugging MySQL Memory Alerts: When innodb_buffer_pool_size Isn't the Whole Story

Image
Posted on MySQL Ninjas | August 2026 Every DBA has been there. An alert fires. You SSH into the box, run free -h , and see MySQL consuming far more RAM than you configured. You double-check innodb_buffer_pool_size . It's set correctly. So where is the memory going? This is the story of debugging exactly that — on a Google Cloud c4d-standard-4 instance with 14.7 GB RAM, MySQL configured with a 7168 MB buffer pool, and mysqld RSS sitting at 10.4 GB . That's a 3.2 GB gap nobody could explain. The Setup We run a large MySQL fleet on GCP — over 200 DR replica nodes across three datacenters. As part of a buffer pool tuning project (fitting the right pool size to the right machine class), we set innodb_buffer_pool_size = 7168 MB on our c4d-standard-4 nodes (16 GB RAM, 14.7 GB usable). Shortly after, memory alerts started firing. When I looked at what was actually happening: $ ps aux | grep mysqld | awk '{print $6/1024 " MB"}' 10490 MB ...

Running Maxwell (MySQL Binlog Reader) As Service In Ubuntu



As Many of DBA's are already running Maxwell (http://maxwells-daemon.io/) if not Let me introduce you to Maxwell. It reads MySQL binlogs and writes row updates as JSON to Kafka, Kinesis, or other streaming platforms. Maxwell is very nice tool to build pipelines from MySQL to other NoSQL DB's like (Elastic Search, AeroSpike, Cassandra etc).

A common approach which is being used widely is to run maxwell on a box which reads bin-logs from MySQL box and write it to Kafka (A Distributed Streaming Platform) Later consumer's consume data from kafka and write it to its own DB (Elastic Search, AeroSpike etc).

Now major issue is to run maxwell as service on Ubuntu VM. Which we tried to solve using Upstart Job for Ubuntu 14.x and Systemd service for Ubuntu 16.x.

Maxwell Binaries can be downloaded from https://github.com/zendesk/maxwell/releases.

Upstart for Ubuntu 14.x (Assuming maxwell binary placed in /opt/maxwell/ directory):

Create file: /etc/init/maxwell.conf
       
description "Start and stop the maxwell service "

author "Ankit Kumar"

env APP_HOME=/opt/maxwell/

start on (net-device-up

          and local-filesystems

          and runlevel [2345])

stop on runlevel [016]

respawn

respawn limit 5 60

limit nofile 24000 24000

pre-start script

    test -x $APP_HOME/bin/maxwell || { stop; exit 1; }

    test -e $APP_HOME/config.properties || { stop; exit 1; }

end script

script

    echo $$ > /var/run/maxwell.pid

    chdir $APP_HOME

    exec $APP_HOME/bin/maxwell

end script

post-stop script

    rm -f /var/run/maxwell.pid

end script 
Now maxwell can be started using command service maxwell start & can be stopped using command service maxwell stop.

Upstart for Ubuntu 16.x (Assuming maxwell binary placed in /opt/maxwell/ directory):

Create file: /etc/systemd/system/maxwell.service
       
[Unit]

Description=Maxwell service

After=network.target

[Service]

WorkingDirectory=/opt/maxwell/

Restart=always

RestartSec=3

ExecStart=/opt/maxwell/bin/maxwell

#ExecStartPost=/bin/bash "touch /var/run/maxwell.pid && `echo $MAINPID` > /var/run/maxwell.pid"

ExecStop=/bin/kill -9 $MAINPID

KillMode=mixed

TimeoutSec=180

[Install]

WantedBy=multi-user.target 
Enable Maxwell systemd service: systemctl enable maxwell.service

Now maxwell can be started using command systemctl start maxwell.service & can be stopped using command systemctl stop maxwell.service.

Monitoring Maxwell Service: Using /var/run/maxwell.pid monitoring on maxwell service can be enabled.

Comments

Popular posts from this blog

Azure VM Application Consistent MySQL DB Disk Snapshots

Debugging MySQL Memory Alerts: When innodb_buffer_pool_size Isn't the Whole Story

MongoDB InPlace Version Upgrade 3.4x to 3.6x