Differentiate between 2 parameters Total memory usage and Memory usage?

3,184 views
Skip to first unread message

Nguyen Van Vuong

unread,
Jun 21, 2022, 10:52:33 AM6/21/22
to Google Cloud SQL discuss
I am using CloudSQL with MySQL 5.7
This is my configuration
  • vCPUs: 1
  • Memory: 614.4 MB
  • SSD storage: 10 GB
Lately my application has been running pretty slow, and I'm guessing it's due to a bottleneck in MySQL.

But when I look at the following 2 parameters, I don't understand why Total memory usage is smaller than Memory usage.??? (Attachment)

Total memory usage.png
 
Memory usage.png
As references, we known:
  • Total memory usage: Total RAM usage in bytes including buffer cache. Sampled every 60 seconds. After sampling, data is not visible for up to 210 seconds.
  • Memory usage: RAM usage in bytes. Sampled every 60 seconds. After sampling, data is not visible for up to 210 seconds.
Can anyone help me explain in more detail about these 2 metrics?

Thanks very much

lopezacuna

unread,
Jun 21, 2022, 3:17:28 PM6/21/22
to Google Cloud SQL discuss

The Memory usage metric is measured at the VM level and does not include the OS cache. It's equivalent to "MemTotal - MemAvailable" from the VM's /proc/meminfo.

The Total memory usage metric is measured at the database container level. It includes memory used by the database container itself, and the OS cache.

The metric names might suggest that Total memory usage is always higher or equal to Memory usage. This is not true because those metrics are measured at different levels. (VM versus Docker). In other words, it's not Memory usage and Total memory usage for the same thing, but rather Memory usage for one thing and Total memory usage for another thing.

For example: 

  • Memory usage can be higher than Total memory usage because it's measured at the entire VM level, so it includes memory usage by components other than the database container. If the container and cache usage is low (e.g. because the database is small, idle, and doesn't use much OS cache), VM usage can potentially be higher than container usage. There are also differences in how memory allocation is measured in Docker versus the OS, which can contribute to the discrepancy.

  • Total memory usage can be, and often is, higher than Memory usage because it includes OS cache. Busy, warm databases can use large amounts of OS cache, which inflates Total memory usage.

Reply all
Reply to author
Forward
0 new messages