[英]Jmeter and Docker
I saw some blog posts where people talk about JMeter and Docker. 我看到一些博客文章,人们谈论JMeter和Docker。 I understand that Docker will be helpful for setting up a container with all the dependencies.
我知道Docker将有助于设置一个包含所有依赖项的容器。 But they all run/create the containers in the same host.
但它们都在同一主机中运行/创建容器。 So ideally all the containers will share the host resources.
理想情况下,所有容器都将共享主机资源。 It is like you run multiple instances of jmeter in the same host.
就像在同一主机中运行多个jmeter实例一样。 It will not be helpful to generate more load.
生成更多负载没有帮助。
When a host has 12GB RAM, I think 1 instance of JMeter with 10GB heap can generate more load than running 10 containers with 1 jmeter instance in each container. 当主机有12GB RAM时,我认为1个具有10GB堆的JMeter实例可以比在每个容器中运行10个带有1个jmeter实例的容器产生更多的负载。
What is the point of running docker here? 在这里运行码头工具有什么意义?
I made an automatic solution that can be easily integrated with Jenkins . 我制作了一个可以轻松与Jenkins集成的自动解决方案 。
The dockerfile should be extended from java8
and add the JMeter build. 应该从
java8
扩展java8
并添加JMeter构建。 This Docker image I will call jmeter-base: 这个Docker镜像我将调用jmeter-base:
FROM java:8
RUN mkdir /jmeter \
&& cd /jmeter/ \
&& wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-3.3.tgz \
&& tar -xvzf apache-jmeter-3.3.tgz \
&& rm apache-jmeter-3.3.tgz
ENV JMETER_HOME /jmeter/apache-jmeter-3.3/
# Add Jmeter to the Path
ENV PATH $JMETER_HOME/bin:$PATH
If you want to use a master-slave solution, this is the jmeter master Dockerfile: 如果你想使用主从解决方案,这是jmeter主Dockerfile:
FROM jmeter-base
WORKDIR $JMETER_HOME
# Ports to be exposed from the container for JMeter Master
RUN mkdir scripts
EXPOSE 60000
And this is the jmeter slave Dockerfile: 这是jmeter奴隶Dockerfile:
FROM jmeter-base
# Ports to be exposed from the container for JMeter Slaves/Server
EXPOSE 1099 50000
# Application to run on starting the container
ENTRYPOINT $JMETER_HOME/bin/jmeter-server \
-Dserver.rmi.localport=50000 \
-Dserver_port=1099
Now, with the both images, you should execute a script to execute you should know all slave IPs. 现在,使用这两个图像,您应该执行一个脚本来执行您应该知道所有从属IP。 This script make all the job:
这个脚本完成所有工作:
#!/bin/bash
COUNT=${1-1}
docker build -t jmeter-base jmeter-base
docker-compose build && docker-compose up -d && docker-compose scale master=1 slave=$COUNT
SLAVE_IP=$(docker inspect -f '{{.Name}} {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq) | grep slave | awk -F' ' '{print $2}' | tr '\n' ',' | sed 's/.$//')
WDIR=`docker exec -it master /bin/pwd | tr -d '\r'`
mkdir -p results
for filename in scripts/*.jmx; do
NAME=$(basename $filename)
NAME="${NAME%.*}"
eval "docker cp $filename master:$WDIR/scripts/"
eval "docker exec -it master /bin/bash -c 'mkdir $NAME && cd $NAME && ../bin/jmeter -n -t ../$filename -R$SLAVE_IP'"
eval "docker cp master:$WDIR/$NAME results/"
done
docker-compose stop && docker-compose rm -f
I came to understand from this post from a friend of mine that we should not be running multiple docker containers in the same host to generate more load. 我从我的一位朋友的帖子中了解到,我们不应该在同一主机中运行多个docker容器来产生更多负载。
http://www.testautomationguru.com/jmeter-distributed-load-testing-using-docker/ http://www.testautomationguru.com/jmeter-distributed-load-testing-using-docker/
Instead the usage of docker here is to quickly setup the jmeter environment. 相反,这里使用docker是为了快速设置jmeter环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.