Skip to content

Commit c0a440c

Browse files
committed
Initial content
1 parent 2be12b1 commit c0a440c

14 files changed

+1020
-1
lines changed

Dockerfiles/Dockerfile_c7perf

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM centos:centos7
2+
MAINTAINER jeder <[email protected]>
3+
4+
# Install some useful utilities
5+
RUN yum install -y bc blktrace btrfs-progs ethtool findutils gcc gdb git glibc-common glibc-utils gnuplot hwloc iotop iproute iputils less pciutils ltrace mailx man-db netsniff-ng net-tools numactl numactl-devel passwd perf procps-ng psmisc screen strace tar tcpdump vim-enhanced wget xauth which
6+
7+
# Clone git repos for test tooling. # Could also be curl or whatever else...
8+
RUN git clone https://github.com/jeremyeder/docker-performance.git /root/docker-performance
9+
10+
# Lay down some basic environment stuff
11+
ENV container docker
12+
ENV HOME /root
13+
ENV USER root
14+
WORKDIR /root

Dockerfiles/README.selinux

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Until something like PR5910 lands, you have to set SELinux permissions manually.
2+
3+
There are 2 options with varying levels of security.
4+
5+
1) Set svirt_sandbox_file_t context on the volume directory on your Docker host.
6+
- This will allow any container to read/write to that directory.
7+
8+
# chcon -Rt svirt_sandbox_file_t /results
9+
10+
2) Each time a container is created, it is allocated unique SELinux MCS labels.
11+
- Since this is dynamically generated at docker run time, you cannot label the host directory properly until after the container is created.
12+
- This is the most secure method since no other containers will be able to access this directory.
13+
- To determine the label:
14+
15+
# sudo docker run -v /results ...
16+
# cat /etc/hostname
17+
2bf50285b249
18+
chcon -Rt svirt_sandbox_file_t /results
19+
# chcon --reference /var/lib/docker/devicemapper/mnt/2bf50285b249d1513c5481a992b12495fc8e8e0d3fdf2b2345b760c5fd675db1 /results

README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
docker-performance
22
==================
33

4-
Docker Performance
4+
Repository to accompany https://slides.com/jeremyeder/docker-performance-analysis
5+
6+
# git clone https://github.com/jeremyeder/docker-performance.git
7+
# docker build -t c7perf --rm=true - < /root/docker-performance/Dockerfiles/Dockerfile_c7perf
8+
# docker images
9+
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
10+
c7perf latest f275641e482b 38 seconds ago 663.7 MB
11+
centos centos7 1a7dc42f78ba 2 weeks ago 236.4 MB
12+
13+
# mkdir /results
14+
# chcon -Rt svirt_sandbox_file_t /results
15+
# docker run -it -v /results:/results c7perf bash
16+
# /root/docker-performance/bench/sysbench/run-sysbench.sh cpu test1
17+
# cat /results/*histogram
18+
19+
...
20+
# cat /etc/hostname
21+
2bf50285b249
22+
# chcon --reference /var/lib/docker/devicemapper/mnt/2bf50285b249d1513c5481a992b12495fc8e8e0d3fdf2b2345b760c5fd675db1 /results

bench/sysbench/README

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20140502 - this srpm comes from EPEL.
Binary file not shown.
Binary file not shown.

bench/sysbench/run-sysbench.sh

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/bin/sh
2+
3+
################################################################################
4+
#
5+
# run-sysbench.sh
6+
#
7+
# - sysbench automation script
8+
#
9+
# Usage: Adjust variables below before running
10+
#
11+
# MAINTAINER: [email protected]
12+
#
13+
#
14+
################################################################################
15+
16+
################################################################################
17+
# Define Global Variables and Functions
18+
################################################################################
19+
20+
if [ $# -lt 2 ]; then
21+
echo "syntax $0 test_type test_name"
22+
echo " i.e. $0 cpu|oltp docker.test1"
23+
exit 1;
24+
fi
25+
26+
function timestamp {
27+
echo "$(date +%Y-%m-%d_%H_%M_%S)"
28+
}
29+
30+
TESTTYPE=$1
31+
TESTNAME=$2
32+
DB_DIR=/root
33+
DB_DATA_DIR=$DB_DIR/data
34+
DB_LOG_DIR=$DB_DIR/log
35+
CPU_SAMPLES=10
36+
CPU_PRIME=4000
37+
OLTP_ROWS=2000000
38+
OLTP_SECONDS=300
39+
OUTDIR=/results
40+
41+
if [ $container == docker ]; then
42+
echo "Running in a container"
43+
fi
44+
45+
if [ ! -d $OUTDIR ]; then
46+
echo "$OUTDIR does not exist. Exiting."
47+
exit 1
48+
fi
49+
50+
if [[ ! -d $DB_DATA_DIR && ! -d $DB_LOG_DIR ]]; then
51+
echo "Database storage directories do not exist; creating $DB_DATA_DIR and $DB_LOG_DIR"
52+
mkdir -p $DB_DATA_DIR $DB_LOG_DIR
53+
fi
54+
55+
if [ ! $(which sysbench) ]; then echo "sysbench not installed...installing" ; yum install -y -q /root/docker-performance/bench/sysbench/rhel7/*rpm ; fi
56+
57+
function run_cpu_test {
58+
OUTFILE=$OUTDIR/`timestamp`.sysbench.$TESTNAME.cpu.cpu.max.prime.$CPU_PRIME.samples.$CPU_SAMPLES.log
59+
for i in `seq $CPU_SAMPLES` ; do sysbench --test=cpu --cpu-max-prime=$CPU_PRIME run >> $OUTFILE ; done
60+
grep "total time:" $OUTFILE | awk '{print $3}' | sed -e 's/s//g' | /root/docker-performance/utils/histogram.py | tee -a > $OUTFILE.histogram
61+
}
62+
63+
function setup_oltp_test {
64+
DB=mariadb
65+
ENGINE=innodb
66+
67+
if [ ! $(which mysqld_safe) ]; then echo "mariadb not installed...installing" ; yum install -y -q mariadb-server mariadb ; fi
68+
69+
echo "starting database"
70+
pkill mysqld_safe
71+
mysqld_safe --user=root --basedir=/usr --skip-grant-tables --innodb_data_home_dir=$DB_DATA_DIR \
72+
--innodb_buffer_pool_size=2048M --innodb_log_group_home_dir=$DB_LOG_DIR --innodb_log_buffer_size=64M \
73+
--innodb_additional_mem_pool_size=32M --innodb_flush_log_at_trx_commit=0 --innodb_log_file_size=1G \
74+
--innodb_thread_concurrency=1000 --max_connections=1000 --table_cache=4096 --innodb_flush_method=O_DIRECT &
75+
# gotta wait for db to initialize itself before continuing
76+
sleep 30
77+
}
78+
79+
function setup_oltp_database {
80+
echo "setting up sysbench database"
81+
mysqladmin -uroot -f drop sbtest
82+
mysqladmin -uroot create sbtest
83+
}
84+
85+
function run_oltp_test {
86+
OUTFILE=$OUTDIR/`timestamp`.sysbench.$container.$TESTNAME.oltp.$DB.rows.$OLTP_ROWS.seconds.$OLTP_SECONDS.$ENGINE.log
87+
88+
for NUM_THREADS in 1 2 4 8 16 32;
89+
do
90+
setup_oltp_database
91+
sysbench --test=oltp --db-driver=mysql --oltp-table-size=$OLTP_ROWS --max-requests=0 --mysql-table-engine=InnoDB \
92+
--mysql-user=root --mysql-engine-trx=yes --num-threads=1 prepare
93+
echo 3 > /proc/sys/vm/drop_caches ; sync
94+
sleep 5
95+
sysbench --test=oltp --db-driver=mysql --oltp-table-size=$OLTP_ROWS --max-time=$OLTP_SECONDS --max-requests=0 \
96+
--mysql-table-engine=InnoDB --mysql-user=root --mysql-engine-trx=yes --num-threads=$NUM_THREADS run >> $OUTFILE
97+
done
98+
}
99+
100+
if [ "$TESTTYPE" = cpu ]; then
101+
echo "`timestamp` running sysbench $TESTTYPE test for $CPU_SAMPLES samples"
102+
run_cpu_test
103+
fi
104+
105+
if [ "$TESTTYPE" = oltp ]; then
106+
echo "`timestamp` running sysbench $TESTTYPE test with $OLTP_ROWS rows for $OLTP_SECONDS seconds"
107+
setup_oltp_test
108+
setup_oltp_database
109+
run_oltp_test
110+
fi
Binary file not shown.

0 commit comments

Comments
 (0)