Docker Management using JMeter
Posted On February 19, 2016 by Geeta Priya filed under Enterprise
Gayathri Nelavigi & Dr. B. Thangaraju
In the advent of server virtualization, IT business is having numerous benefits such as being able to provide sufficient infrastructure with limited physical systems, quick system provisioning from a master template, avoid hardware vendor lock-in, get better disaster recovery, dedicated virtual system to run your application or services and facilitate to move your infrastructure into cloud environment. The virtualization technology uses hypervisor to create a new virtual machine by hardware level virtualization. Some of the popular virtualization software are VMWare, Virtual Box and KVM (Kernel based Virtual Machine). The next generation of virtualization technology is software container, it is based on operating system level virtualization and not using hypervisor. More specifically, Linux container uses namespace and cgroup features to create an isolated environment from a host for a user. Docker is an open source tool to build and launch a Linux container from a host server. Compared to the traditional virtual machine, docker is lightweight, so it can be created, launched and destroyed very quickly. To run a specific service or application, container is the best suit than a full-fledged virtual machine since the Linux container uses very less resources and incredibly fast, so we can run large number of containers inside a host server.
Manually administering a large number of containers, which are running in a Linux server is a herculean task. Docker management tools are helping a system administrator to manage containers remotely with GUI environment. Some of the Docker management tools are Kubernetes, Dockersh, Docker Compose, Kitematic, Logspout, etc., Apache JMeter is one of the open source tool for testing software. The tool provides a GUI to create, record and playback the test scripts. It is developed using high level language such as Java and hence JMeter is platform independent. JMeter provides unlimited testing capability and is highly extensible. The main purpose of this tool is to do the performance testing of applications. It gives multiprotocol support like ftp, http, SOAP, LDAP etc. Using JMeter, testing can be done and then the results can be monitored and also collected in different formats like table, graph, tree etc. The obtained results can then be analyzed offline. The advantages of this tool compared to other testing tools are that it is very simple to install, has good GUI feature and is easy to use. Installation is just a matter of downloading the executable from the Apache website http://JMeter.apache.org/download_JMeter.cgiand run JMeter.bat execution file.
JMeter can be used as a standalone or distributed testing environment. Distributed environment is used to simulate virtual users from multiple machines for heavy load testing or stress testing to measure the performance of a system. In this article, we attempted to manage docker containers like creation, deletion and monitoring docker by Jmeter and we are going to demonstrate, how easily we can manage the docker remotely using JMeter. We are running JMeter from windows machine and connecting to Linux host through SSH. Benefits of managing docker using Jmeter are, one who manages Docker need not be a Linux expert, JMeter uses GUI and hence it is user friendly, monitoring of the docker can be done easily, docker management can be done locally or remotely, managing docker locally by using OS Process Sampler and for remote managing, SSH sampler is used. SSH Sampler is not there by default in JMeter, so we need to use extra plug-in. Sampler will connect to Linux server and execute the given Linux commands. Only after completion of the command execution, response is returned to the JMeter.
Procedure to install SSH sampler plugin in JMeter is explained in detail by SuganthiThangavel, “ How to execute Linux Command or shell script from APACHE JMETER” - http://www.technix.in/execute-linux-command-shell-script-apache-jmeter/.
2. Docker Management through JMeter
Docker is installed and running in a Linux Server. So, from Windows system, first we need to connect to the Linux server through SSH by providing login credentials. Since we are going to manage the docker, we need root privileges. Figure 1 illustrates the login details like Hostname (Host ip address), username and password. The port number 22 is used since we used ssh to establish connection between host and target systems. After connecting successfully to the Linux host, we are issuing the “docker ps –a” to list the existing docker containers. The details of the existing docker containers can be seen in Figure 2.
Figure 1: Connecting to the Linux host and issuing the command to see the existing docker containers
Figure 2. List of containers in the Linux Server
Figure 2: “docker ps –a” command listing the details of the existing docker containers. The information like container id, image name, command, docker creation time and running status of the containers can be seen in the Response Data.
We can create docker container from JMeter, either by executing the command directly to create container by specifying in the “execute command” box or we create shell script for container creation and execute the script. In this case, we used the script called cre.sh, which will create 100 user accounts and create container for each user. The script file with full path has to be mentioned as a value to “execute Command” as shown in the Figure 3.
Figure 3. Procedure to execute cre.sh
Figure 4 shows that the users and containers are created and the details for each user and container id are seen in the Response Data. For viewing the result, we are using the “View Results Tree” Listener. The Listeners are added by right click on the Thread Group->Add->Listeners->View Results Tree.
Figure 4. Result of cre.sh in the Response Data.
We can also see the containers resource usage statistics like CPU usage, memory usage, network I/O and disk utilization etc. In this sample, we are looking at resource utilization for 3 containers. And by using the –no-stream=”true” option we are limiting the statistics to collect only the first output. Figure 5 and 6 shows the command and result for the container’s resource usage statistics.
Figure 5. Command issued to find the resource usage statistics of 3 containers
Figure 6. Resource usage statistics of 3 containers
We can also view log information of the active containers. The log file remains in the host server till we delete the container. In Figure 7 and 8, we can see the command executed to capture the log of the container with container id = 2a607bedd691 and the log information respectively.
Figure 7. Command execution to capture the log.
Figure 8. Container log detail
Finally, we can delete the docker containers using JMeter. In Figure 9, we used del.sh shell script to delete 100 user accounts and their containers.
Figure 9. Procedure to execute container deletion script.
Figure 10. List of deleted containers ID
As and when the user is deleted, the container id of the deleted users can be seen in the result as seen in Figure 10.
Docker is open source software to deploy applications into a Linux container. JMeter is used to manage containers remotely through ssh from Windows system. Through JMeter, creation of containers along with user accounts, listing of existing containers, view system resources usage by containers, log information and deletion of containers were explained in detail.
Authors would like to thank Venkatachalam Subramanian for his critical reading of the manuscript.
About the Authors
Gayathri Nelavigi is a consultant, who works at Talent Transformation, Wipro Technologies, Bangalore. Her scope of work includes training the Wipro Employees in the technical areas, JMeter is one of them. She can be reached at firstname.lastname@example.org.
Dr B. Thangaraju is an open source software (OSS) evangelist, who works at Talent Transformation, Wipro Technologies, Bangalore and he can be reached at email@example.com.