ASP.NET Core Benchmarking on Debian using Docker

Authored by

I am using Windows Server 2016 VM on Azure. The size of the VM is a Standard D4s v3 (4 vcpus, 16 GB memory). I have installed Docker for Windows inside the VM. It means that I am running containers on Docker for Windows on HyperV on Windows Server 2016 on Azure VM!

Disclaimer : I am trying to learn how to do ASP.NET Core benchmarks using Docker. This could help developers to benchmark their Web Apps in order to improve their performance.


PS C:\Users\Maher\Documents> git clone https://github.com/aspnet/benchmarks.git
Cloning into 'benchmarks'...
remote: Counting objects: 4957, done.
remote: Compressing objects: 100% (113/113), done.
remote: Total 4957 (delta 96), reused 101 (delta 55), pack-reused 4787
Receiving objects: 100% (4957/4957), 1.48 MiB | 4.51 MiB/s, done.
Resolving deltas: 100% (3444/3444), done.
PS C:\Users\Maher\Documents> cd benchmarks\docker\benchmarks
PS C:\Users\Maher\Documents\benchmarks\docker\benchmarks> docker build -t benchmarks -f Dockerfile ../../

I choose to create a Debian Linux distribution release called jessie.

Step 1 :
PS C:\Users\Maher\Documents\benchmarks\docker\benchmarks> docker build -t benchmarks -f Dockerfile ../../
Sending build context to Docker daemon  9.461MB
Step 1/9 : FROM microsoft/dotnet:2.0-sdk-jessie
2.0-sdk-jessie: Pulling from microsoft/dotnet
f2b6b4884fc8: Pull complete
4fb899b4df21: Pull complete
74eaa8be7221: Pull complete
b28345b42ba1: Pull complete
108eb2672d46: Pull complete
e4211d9b683b: Extracting [===================>                               ]  111.4MB/289.7MB
Step 2 :
Digest: sha256:a1805a24d7e3a74043f8825bc47c761a81692da3d06e36d6170d99c836edec87
Status: Downloaded newer image for microsoft/dotnet:2.0-sdk-jessie
 ---> c92566b377c9
Step 2/9 : RUN apt-get update     && apt-get install -y --no-install-recommends         build-essential         libssl-dev         unzip         wget         git         procps     && rm -rf /var/lib/apt/lists/*
 ---> Running in 1c4f83f449cd
Get:1 http://security.debian.org jessie/updates InRelease [63.1 kB]
Ign http://deb.debian.org jessie InRelease
Get:2 http://deb.debian.org jessie-updates InRelease [145 kB]
Get:3 http://deb.debian.org jessie Release.gpg [2434 B]
Get:4 http://security.debian.org jessie/updates/main amd64 Packages [643 kB]
Get:5 http://deb.debian.org jessie Release [148 kB]
Get:6 http://deb.debian.org jessie-updates/main amd64 Packages [23.1 kB]
Get:7 http://deb.debian.org jessie/main amd64 Packages [9064 kB]
Fetched 10.1 MB in 9s (1035 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
git is already the newest version.
procps is already the newest version.
wget is already the newest version.
The following extra packages will be installed:
  binutils bzip2 cpp cpp-4.9 dpkg-dev g++ g++-4.9 gcc gcc-4.9 libasan1
  libatomic1 libc-dev-bin libc6-dev libcilkrts5 libcloog-isl4 libdpkg-perl
  libgcc-4.9-dev libgomp1 libisl10 libitm1 liblsan0 libmpc3 libmpfr4
  libquadmath0 libssl1.0.0 libstdc++-4.9-dev libtimedate-perl libtsan0
  libubsan0 linux-libc-dev make patch xz-utils zlib1g-dev
Suggested packages:
  binutils-doc bzip2-doc cpp-doc gcc-4.9-locales debian-keyring g++-multilib
  g++-4.9-multilib gcc-4.9-doc libstdc++6-4.9-dbg gcc-multilib manpages-dev
  autoconf automake libtool flex bison gdb gcc-doc gcc-4.9-multilib
  libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan1-dbg
  liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libquadmath0-dbg
  glibc-doc libstdc++-4.9-doc make-doc ed diffutils-doc zip
Recommended packages:
  fakeroot libalgorithm-merge-perl libfile-fcntllock-perl libssl-doc
The following NEW packages will be installed:
  binutils build-essential bzip2 cpp cpp-4.9 dpkg-dev g++ g++-4.9 gcc gcc-4.9
  libasan1 libatomic1 libc-dev-bin libc6-dev libcilkrts5 libcloog-isl4
  libdpkg-perl libgcc-4.9-dev libgomp1 libisl10 libitm1 liblsan0 libmpc3
  libmpfr4 libquadmath0 libssl-dev libstdc++-4.9-dev libtimedate-perl libtsan0
  libubsan0 linux-libc-dev make patch unzip xz-utils zlib1g-dev
The following packages will be upgraded:
  libssl1.0.0
1 upgraded, 36 newly installed, 0 to remove and 3 not upgraded.
Need to get 45.5 MB of archives.
After this operation, 144 MB of additional disk space will be used.
Get:1 http://security.debian.org/ jessie/updates/main libssl1.0.0 amd64 1.0.1t-1+deb8u8 [1044 kB]
Get:2 http://security.debian.org/ jessie/updates/main libasan1 amd64 4.9.2-10+deb8u1 [195 kB]
Get:3 http://security.debian.org/ jessie/updates/main libatomic1 amd64 4.9.2-10+deb8u1 [9014 B]
Get:4 http://security.debian.org/ jessie/updates/main libcilkrts5 amd64 4.9.2-10+deb8u1 [40.1 kB]
Get:5 http://security.debian.org/ jessie/updates/main libgomp1 amd64 4.9.2-10+deb8u1 [37.8 kB]
Get:6 http://security.debian.org/ jessie/updates/main libitm1 amd64 4.9.2-10+deb8u1 [29.3 kB]
Get:7 http://security.debian.org/ jessie/updates/main liblsan0 amd64 4.9.2-10+deb8u1 [92.7 kB]
Get:8 http://security.debian.org/ jessie/updates/main libquadmath0 amd64 4.9.2-10+deb8u1 [129 kB]
Get:9 http://security.debian.org/ jessie/updates/main libtsan0 amd64 4.9.2-10+deb8u1 [212 kB]
Get:10 http://security.debian.org/ jessie/updates/main libubsan0 amd64 4.9.2-10+deb8u1 [82.4 kB]
Get:11 http://deb.debian.org/debian/ jessie/main libisl10 amd64 0.12.2-2 [440 kB]
Get:12 http://deb.debian.org/debian/ jessie/main libcloog-isl4 amd64 0.18.2-1+b2 [61.8 kB]
Get:13 http://security.debian.org/ jessie/updates/main cpp-4.9 amd64 4.9.2-10+deb8u1 [5002 kB]
Get:14 http://deb.debian.org/debian/ jessie/main libmpfr4 amd64 3.1.2-2 [527 kB]
Get:15 http://security.debian.org/ jessie/updates/main linux-libc-dev amd64 3.16.51-3+deb8u1 [1083 kB]
Get:16 http://deb.debian.org/debian/ jessie/main libmpc3 amd64 1.0.2-1 [39.3 kB]
Get:17 http://deb.debian.org/debian/ jessie/main bzip2 amd64 1.0.6-7+b3 [46.9 kB]
Get:18 http://deb.debian.org/debian/ jessie/main patch amd64 2.7.5-1 [109 kB]
Get:19 http://deb.debian.org/debian/ jessie/main xz-utils amd64 5.1.1alpha+20120614-2+b3 [221 kB]
Get:20 http://deb.debian.org/debian/ jessie/main binutils amd64 2.25-5+deb8u1 [3496 kB]
Get:21 http://security.debian.org/ jessie/updates/main libgcc-4.9-dev amd64 4.9.2-10+deb8u1 [2066 kB]
Get:22 http://deb.debian.org/debian/ jessie/main libc-dev-bin amd64 2.19-18+deb8u10 [238 kB]
Get:23 http://deb.debian.org/debian/ jessie/main libc6-dev amd64 2.19-18+deb8u10 [2003 kB]
Get:24 http://security.debian.org/ jessie/updates/main gcc-4.9 amd64 4.9.2-10+deb8u1 [5184 kB]
Get:25 http://deb.debian.org/debian/ jessie/main cpp amd64 4:4.9.2-2 [17.3 kB]
Get:26 http://deb.debian.org/debian/ jessie/main gcc amd64 4:4.9.2-2 [5136 B]
Get:27 http://deb.debian.org/debian/ jessie/main g++ amd64 4:4.9.2-2 [1530 B]
Get:28 http://deb.debian.org/debian/ jessie/main make amd64 4.0-8.1 [349 kB]
Get:29 http://deb.debian.org/debian/ jessie/main libtimedate-perl all 2.3000-2 [42.2 kB]
Get:30 http://deb.debian.org/debian/ jessie/main libdpkg-perl all 1.17.27 [1075 kB]
Get:31 http://security.debian.org/ jessie/updates/main libstdc++-4.9-dev amd64 4.9.2-10+deb8u1 [1120 kB]
Get:32 http://deb.debian.org/debian/ jessie/main dpkg-dev all 1.17.27 [1548 kB]
Get:33 http://security.debian.org/ jessie/updates/main g++-4.9 amd64 4.9.2-10+deb8u1 [17.3 MB]
Get:34 http://deb.debian.org/debian/ jessie/main build-essential amd64 11.7 [7114 B]
Get:35 http://deb.debian.org/debian/ jessie/main zlib1g-dev amd64 1:1.2.8.dfsg-2+b1 [206 kB]
Get:36 http://deb.debian.org/debian/ jessie/main unzip amd64 6.0-16+deb8u3 [162 kB]
Get:37 http://security.debian.org/ jessie/updates/main libssl-dev amd64 1.0.1t-1+deb8u8 [1279 kB]
debconf: delaying package configuration, since apt-utils is not installed
Fetched 45.5 MB in 5s (8728 kB/s)
(Reading database ... 12156 files and directories currently installed.)
Preparing to unpack .../libssl1.0.0_1.0.1t-1+deb8u8_amd64.deb ...
Steps 3 and 4 :
Setting up libssl-dev:amd64 (1.0.1t-1+deb8u8) ...
Setting up unzip (6.0-16+deb8u3) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Removing intermediate container 1c4f83f449cd
 ---> 44be2c07a36f
Step 3/9 : ENV WRK_VERSION 4.0.2
 ---> Running in 30de2082890a
Removing intermediate container 30de2082890a
 ---> afc946937b1a
Step 4/9 : RUN cd /tmp     && wget https://github.com/wg/wrk/archive/$WRK_VERSION.tar.gz -O wrk.tar.gz     && tar xvzf wrk.tar.gz     && cd wrk-$WRK_VERSION     && make     && cp wrk /usr/local/bin     && cd ..     && rm -rf wrk.tar.gz wrk-$WRK_VERSION
 ---> Running in 365d93c74bc2
converted 'https://github.com/wg/wrk/archive/4.0.2.tar.gz' (ANSI_X3.4-1968) -> 'https://github.com/wg/wrk/archive/4.0.2.tar.gz' (UTF-8)
--2018-04-02 10:16:00--  https://github.com/wg/wrk/archive/4.0.2.tar.gz
Resolving github.com (github.com)... 192.30.253.112, 192.30.253.113
Connecting to github.com (github.com)|192.30.253.112|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/wg/wrk/tar.gz/4.0.2 [following]
converted 'https://codeload.github.com/wg/wrk/tar.gz/4.0.2' (ANSI_X3.4-1968) -> 'https://codeload.github.com/wg/wrk/tar.gz/4.0.2' (UTF-8)
--2018-04-02 10:16:01--  https://codeload.github.com/wg/wrk/tar.gz/4.0.2
Resolving codeload.github.com (codeload.github.com)... 192.30.253.121, 192.30.253.120
Connecting to codeload.github.com (codeload.github.com)|192.30.253.121|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: 'wrk.tar.gz'

     0K .......... .......... .......... .......... ..........  297K
    50K .......... .......... .......... .......... ..........  609K
   100K .......... .......... .......... .......... .......... 3.80M
   150K .......... .......... .......... .......... ..........  743K
   200K .......... .......... .......... .......... .......... 2.64M
   250K .......... .......... .......... .......... .......... 4.59M
   300K .......... .......... .......... .......... .......... 6.90M
   350K .......... .......... .......... .......... .......... 14.1M
   400K .......... .......... .......... .......... ..........  886K
   450K .......... .......... .......... .......... .......... 3.00M
   500K .......... .......... .......... .......... .......... 4.30M
   550K .......... .......... .......... .......... .......... 6.76M
   600K .......... .......... .......... .......... .......... 10.6M
Steps 5 and 6 :
Step 5/9 : ENV DOCKER_VERSION 17.09.0-ce
 ---> Running in 29be6e902dcf
Removing intermediate container 29be6e902dcf
 ---> 87abbc3604ef
Step 6/9 : RUN cd /tmp     && wget https://download.docker.com/linux/static/stable/x86_64/docker-$DOCKER_VERSION.tgz -O docker.tgz     && tar xvzf docker.tgz     && cp docker/docker /usr/bin     && rm -rf docker.tgz docker
 ---> Running in 1bed3cbfcdfe
converted 'https://download.docker.com/linux/static/stable/x86_64/docker-17.09.0-ce.tgz' (ANSI_X3.4-1968) -> 'https://download.docker.com/linux/static/stable/x86_64/docker-17.09.0-ce.tgz' (UTF-8)
--2018-04-02 10:19:46--  https://download.docker.com/linux/static/stable/x86_64/docker-17.09.0-ce.tgz
Resolving download.docker.com (download.docker.com)... 54.230.14.226, 54.230.14.164, 54.230.14.139, ...
Connecting to download.docker.com (download.docker.com)|54.230.14.226|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 30365949 (29M) [application/x-tar]
Saving to: 'docker.tgz'

     0K .......... .......... .......... .......... ..........  0% 13.2M 2s
    50K .......... .......... .......... .......... ..........  0% 8.46M 3s
   100K .......... .......... .......... .......... ..........  0% 9.47M 3s
   150K .......... .......... .......... .......... ..........  0% 8.07M 3s
Steps 7 through 9 :
29150K .......... .......... .......... .......... .......... 98% 13.9M 0s
 29200K .......... .......... .......... .......... .......... 98% 6.86M 0s
 29250K .......... .......... .......... .......... .......... 98% 11.6M 0s
 29300K .......... .......... .......... .......... .......... 98% 15.1M 0s
 29350K .......... .......... .......... .......... .......... 99% 7.94M 0s
 29400K .......... .......... .......... .......... .......... 99% 14.1M 0s
 29450K .......... .......... .......... .......... .......... 99% 29.1M 0s
 29500K .......... .......... .......... .......... .......... 99% 5.69M 0s
 29550K .......... .......... .......... .......... .......... 99% 12.1M 0s
 29600K .......... .......... .......... .......... .......... 99% 18.1M 0s
 29650K ....                                                  100% 62.9M=2.3s

2018-04-02 10:19:49 (12.4 MB/s) - 'docker.tgz' saved [30365949/30365949]

docker/
docker/docker-containerd-shim
docker/docker-containerd
docker/docker-runc
docker/docker
docker/docker-init
docker/docker-containerd-ctr
docker/docker-proxy
docker/dockerd
Removing intermediate container 1bed3cbfcdfe
 ---> 38187f52aa1c
Step 7/9 : WORKDIR /benchmarks
Removing intermediate container d7725fe8761f
 ---> 7a9f88ac66c0
Step 8/9 : ENV DOTNET_SKIP_FIRST_TIME_EXPERIENCE true
 ---> Running in 78307e5827f0
Removing intermediate container 78307e5827f0
 ---> d165866af6e5
Step 9/9 : COPY . .
 ---> 73d827fcbb1a
Successfully built 73d827fcbb1a
Successfully tagged benchmarks:latest
SECURITY WARNING: You are building a Docker image from Windows against a non-Windows Docker host. All files and directories added to build context will have '-rwxr-xr-x' permissions. It is recommended to double check and reset permissions for sensitive files and directories.
PS C:\Users\Maher\Documents\benchmarks\docker\benchmarks>
PS C:\Users\Maher\Documents\benchmarks\docker\benchmarks> docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
benchmarks          latest              73d827fcbb1a        38 minutes ago      1.94GB
microsoft/dotnet    2.0-sdk-jessie      c92566b377c9        3 days ago          1.76GB
PS C:\Users\Maher\Documents\benchmarks\docker\benchmarks>

PS C:\Users\Maher\Documents\Benchmarks\src\benchmarksdriver> cat run-job.ps1
dotnet run -c Debug `
 --server "http://localhost:5001" `
 --client "http://localhost:5002" `
 --jobs "../Benchmarks/benchmarks.Json.json" `
 -n Json
PS C:\Users\Maher\Documents\Benchmarks\src\benchmarksdriver>
PS C:\Users\Maher\Documents\Benchmarks\src\benchmarksdriver> .\run-job.ps1
[12:25:40.353] Using worker Wrk
[12:25:40.475] Running session '8de1c42117874044afa89ac5f63ca33f' with description ''
[12:25:40.476] Starting scenario Json on benchmark server...
[12:27:29.761] Job failed on benchmark server, stopping...
Job failed at runtime

ASP.NET Core Benchmarks
-----------------------
Current directory: /tmp/tmpfv7CEm.tmp/3mumjcii.t43/benchmarks/src/Benchmarks
WebHostBuilder loading from: /tmp/tmpfv7CEm.tmp/3mumjcii.t43/benchmarks/src/Benchmarks/published/Microsoft.AspNetCore.Hosting.dll
Scenario configuration found in scenarios.json and/or command line args

The following scenarios were enabled:
  Json -> /json

Database: None
Using server Kestrel
Server GC is currently ENABLED
Using Libuv with 1 threads

[12:27:29.767] Deleting scenario Json on benchmark server...
PS C:\Users\Maher\Documents\Benchmarks\src\benchmarksdriver>
[12:27:28.009] Starting process '/tmp/tmpfv7CEm.tmp/0xizyjx0.f2b/dotnet published/Benchmarks.dll   --nonInteractive true --scenarios Json --server Kestrel --kestrelTransport Libuv --server.urls http://10.0.75.0:5000'
[12:27:28.144]
[12:27:28.147] ASP.NET Core Benchmarks
[12:27:28.147] -----------------------
[12:27:28.152] Current directory: /tmp/tmpfv7CEm.tmp/3mumjcii.t43/benchmarks/src/Benchmarks
[12:27:28.152] WebHostBuilder loading from: /tmp/tmpfv7CEm.tmp/3mumjcii.t43/benchmarks/src/Benchmarks/published/Microsoft.AspNetCore.Hosting.dll
[12:27:28.359] Scenario configuration found in scenarios.json and/or command line args
[12:27:28.368]
[12:27:28.369] The following scenarios were enabled:
[12:27:28.390]   Json -> /json
[12:27:28.390]
[12:27:28.600] Database: None
[12:27:28.603] Using server Kestrel
[12:27:28.604] Server GC is currently ENABLED
[12:27:28.638] Using Libuv with 1 threads

Unhandled Exception: Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvException: Error -99 EADDRNOTAVAIL address not available
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.LibuvFunctions.ThrowError(Int32 statusCode)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Networking.UvTcpHandle.Bind(IPEndPoint endPoint)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Listener.ListenTcp(Boolean useFileHandle)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.Listener.<>c.b__8_0(Listener listener)
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvThread.DoPostWork()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvTransport.BindAsync()   at Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv.Internal.LibuvTransport.BindAsync()   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.<>c__DisplayClass22_0`1.<g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.EndpointsStrategy.BindAsync(AddressBindContext context)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IServerAddressesFeature addresses, KestrelServerOptions serverOptions, ILogger logger, Func`2 createBinding)
   at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServer.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at Benchmarks.Program.Main(String[] args) in /tmp/tmpfv7CEm.tmp/3mumjcii.t43/benchmarks/src/Benchmarks/Program.cs:line 177
[12:27:29.018] Job failed
[12:27:29.829] Deleting job '1' with scenario 'Json'
[12:27:29.837] Waiting for process 4156 to stop ...
[12:27:30.832] Deleting directory '/tmp/tmpfv7CEm.tmp/3mumjcii.t43'
[12:27:30.917] SUCCESS

Authored by

Maher Jendoubi

Husband and Dad. Medical Imaging and Radiation Therapy Project Manager @GustaveRoussy 🏥. Microsoft @MVPAward 🏆 on Developer Technologies.

Subscribe to Maher Jendoubi

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.