Collecting Docker Performance Metrics

181 VIEWS

·

Docker containers help make software deployment faster and more efficient.

In order to ensure that you’re getting as much efficiency out of Docker as you can, however, you need to track Docker performance metrics. Monitoring Docker container performance is also important for troubleshooting problems.

The tricky thing about Docker, however, is that it doesn’t log information to a central location. Unlike most other Linux apps, Docker doesn’t dump log data into a file in /var/log that you can access conveniently when you want to get information about application performance or problems.

This doesn’t mean that you can’t measure Docker performance. You can. You just have to know where to look—specifically, in particular directories. In this post, I’ll explain where to find Docker performance information and what to look for to help maximize Docker performance.

Accessing Docker Container Performance Metrics

Information about running Docker containers themselves—how much CPU, memory and so on they are consuming—is spread across a variety of small files (technically, these are pseudo-files, not actual files) that live deep inside your Docker host server’s /sys directory.

There are three main subdirectories of interest when you’re tracing Docker performance. Each corresponds to a different type of data: CPU usage, memory usage and disk I/O.

CPU Usage

Docker writes information about CPU usage inside this directory:

/sys/fs/cgroup/cpuacct/docker/

Each of the files in this directory contains real-time information related to CPU metrics. For details, check out the Docker documentation.

You can also view CPU information on a per-container basis by opening the subdirectory for the container whose information you want to view. The names of subdirectories map to your container IDs.

The most useful file in this directory is cpuacct.stat, which tells you the total CPU time accumulated by your container processes.

Memory Usage

You can find data about memory consumption in:

/sys/fs/cgroup/memory/docker

This directory works in the same way as the one described above that contains information about CPU usage.

The most interesting file is memory.stat. (Again, refer to the Docker documentation for details on interpreting the information within this file.)

Disk I/O

Last but not least is I/O data for your containers. You can find these metrics inside this directory:

/sys/fs/cgroup/blkio/docker/

You’ll see many files in this directory, and on most types of host systems you’ll find most of the files to be empty. The one worth paying attention to, however, is:

blkio.throttle.io_service_bytes

This file tells you the total I/O bytes consumed by your containers.

For information on the other types of data you can collect from the blkio pseudo-files, refer to the Docker documentation and Linux kernel documentation.

Conclusion

Measuring Docker performance by accessing the files described above can help you to track the overall health of your Docker environment and make sure your containers are running as efficiently as possible.

Reading these files manually is not a practical Docker monitoring solution in a large-scale environment, of course. For that, you’d want an APM tool that can collect Docker performance metrics automatically and help you interpret them.

Still, knowing where to find Docker performance information is important for troubleshooting performance problems with specific containers, as well as for understanding how your system resources are being allocated across your environment.

Do you think you can beat this Sweet post?

If so, you may have what it takes to become a Sweetcode contributor... Learn More.
http://www.fixate.io

Chris Tozzi has worked as a journalist and Linux systems administrator. He has particular interests in open source, agile infrastructure and networking. He is Senior Editor of content and a DevOps Analyst at Fixate IO.


Discussion

Click on a tab to select how you'd like to leave your comment

Leave a Comment

Your email address will not be published. Required fields are marked *

Menu