Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: docker-based benchmarks comparing OpenSSL perf #2050

Open
wants to merge 43 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a2eabe1
try ...
DeagleGross Jan 21, 2025
8920333
correct layout
DeagleGross Jan 21, 2025
e55a727
sources not source
DeagleGross Jan 21, 2025
96bd8f6
typo back
DeagleGross Jan 21, 2025
c64ee87
try
DeagleGross Jan 21, 2025
051c1fc
indent
DeagleGross Jan 21, 2025
a4624f9
rollback
DeagleGross Jan 21, 2025
a6ebf50
another move indent?
DeagleGross Jan 22, 2025
27de7d9
sources
DeagleGross Jan 22, 2025
97c91a7
push push
DeagleGross Jan 22, 2025
65fc61c
fix docker args
DeagleGross Jan 22, 2025
f421171
multiline
DeagleGross Jan 22, 2025
2f09ff8
properly pass args
DeagleGross Jan 22, 2025
e5e8c93
urls as build arg
DeagleGross Jan 22, 2025
a8929e3
dont override the serevr port
DeagleGross Jan 22, 2025
f746fff
any address !
DeagleGross Jan 22, 2025
4091377
ready state text
DeagleGross Jan 22, 2025
940f683
more logs, proper build args,
DeagleGross Jan 22, 2025
3abe8a7
indents?
DeagleGross Jan 22, 2025
54c2b81
one line!
DeagleGross Jan 22, 2025
9376cce
just env
DeagleGross Jan 22, 2025
7b10961
wildcard!
DeagleGross Jan 23, 2025
9ec8ffd
include details in config
DeagleGross Jan 23, 2025
84cde4f
wrap
DeagleGross Jan 23, 2025
640cefc
try again
DeagleGross Jan 23, 2025
8f38060
just explicitly
DeagleGross Jan 23, 2025
1907ca7
openssl 111 support fofr scenario
DeagleGross Jan 23, 2025
3694e67
fix naming
DeagleGross Jan 23, 2025
5814aa7
overriden by job
DeagleGross Jan 23, 2025
d0e0e56
base on alpine!
DeagleGross Jan 23, 2025
8b7494f
fix path
DeagleGross Jan 23, 2025
a164a2c
sdk alpine
DeagleGross Jan 23, 2025
04c736b
just try
DeagleGross Jan 23, 2025
7b67fca
maybe log from app itself?
DeagleGross Jan 23, 2025
d63ff37
try
DeagleGross Jan 23, 2025
8765f4e
qwe
DeagleGross Jan 23, 2025
4506c30
dont do crazy stuff
DeagleGross Jan 23, 2025
b53e58b
logs!
DeagleGross Jan 23, 2025
1af4f50
wrap in function + include openssl 3.0.15 comparison
DeagleGross Jan 23, 2025
6480bd1
dont use before script
DeagleGross Jan 23, 2025
9821148
resolve conflicts
DeagleGross Jan 23, 2025
6a9e021
build fix
DeagleGross Jan 23, 2025
d54b043
prettify + no links to custom repo
DeagleGross Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion scenarios/tls.benchmarks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
imports:
- https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.Wrk/wrk.yml
- https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.Bombardier/bombardier.yml
- https://raw.githubusercontent.com/dotnet/crank/main/src/Microsoft.Crank.Jobs.HttpClient/httpclient.yml
- https://github.com/aspnet/Benchmarks/blob/main/scenarios/aspnet.profiles.yml?raw=true
Expand Down Expand Up @@ -42,6 +41,23 @@ jobs:
logRequestDetails: false
arguments: "--urls https://{{serverAddress}}:{{serverPort}} --mTLS {{mTLS}} --certValidationConsoleEnabled {{certValidationConsoleEnabled}} --tlsProtocols {{tlsProtocols}} --statsEnabled {{statsEnabled}} --tlsRenegotiation {{tlsRenegotiation}} --logRequestDetails {{logRequestDetails}}"

dockerLinuxKestrelServer:
sources:
dockerKestrel:
repository: https://github.com/aspnet/benchmarks.git
branchOrCommit: main
dockerFile: dockerKestrel/src/BenchmarksApps/TLS/Kestrel/Dockerfile
dockerImageName: dockerKestrel
dockerContextDirectory: dockerKestrel/src/BenchmarksApps/TLS/Kestrel
port: 8080
readyStateText: Application started.
environmentVariables:
urls: "https://*:8080" # any ip, port 8080
mTLS: false
tlsRenegotiation: false
certValidationConsoleEnabled: false
statsEnabled: false

scenarios:

# HTTP.SYS
Expand Down Expand Up @@ -145,4 +161,59 @@ scenarios:
serverScheme: https
certPath: https://raw.githubusercontent.com/aspnet/Benchmarks/refs/heads/main/src/BenchmarksApps/TLS/Kestrel/testCert.pfx
certPwd: testPassword
sslProtocol: tls12

# Kestrel in Docker
tls-handshakes-docker-openssl-332:
application:
job: dockerLinuxKestrelServer
buildArguments:
# openssl version to install
- OPENSSL_VERSION="3.3.2-r4"
# lookup for openssl+branch version here https://pkgs.alpinelinux.org/packages?name=openssl&branch=v3.20&repo=&arch=x86_64
- ALPINE_BRANCH="v3.21"
load:
job: httpclient
variables:
path: /hello-world
serverPort: 8080
presetHeaders: connectionclose
connections: 32
serverScheme: https
sslProtocol: tls12

tls-handshakes-docker-openssl-111:
application:
job: dockerLinuxKestrelServer
buildArguments:
# openssl version to install
- OPENSSL_VERSION="1.1.1w-r1"
# lookup for openssl+branch version here https://pkgs.alpinelinux.org/packages?name=openssl&branch=v3.20&repo=&arch=x86_64
- ALPINE_BRANCH="v3.16"
load:
job: httpclient
variables:
path: /hello-world
serverPort: 8080
presetHeaders: connectionclose
connections: 32
serverScheme: https
sslProtocol: tls12

tls-handshakes-docker-openssl-3015:
application:
job: dockerLinuxKestrelServer
buildArguments:
# openssl version to install
- OPENSSL_VERSION="3.0.15-r1"
# lookup for openssl+branch version here https://pkgs.alpinelinux.org/packages?name=openssl&branch=v3.20&repo=&arch=x86_64
- ALPINE_BRANCH="v3.17"
load:
job: httpclient
variables:
path: /hello-world
serverPort: 8080
presetHeaders: connectionclose
connections: 32
serverScheme: https
sslProtocol: tls12
30 changes: 30 additions & 0 deletions src/BenchmarksApps/TLS/Kestrel/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/azds.yaml
**/bin
**/charts
**/docker-compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
38 changes: 38 additions & 0 deletions src/BenchmarksApps/TLS/Kestrel/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This stage is used when running from VS in fast mode (Default for Debug configuration)
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine AS base
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

base on azure mariner base image (linux vms)

USER root
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

# Define a build argument for the OpenSSL version
# lookup for openssl+branch version here https://pkgs.alpinelinux.org/packages?name=openssl&branch=v3.20&repo=&arch=x86_64
ARG OPENSSL_VERSION=1.1.1w-r1
ARG ALPINE_BRANCH=v3.16

# Add the specified Alpine branch repository and install OpenSSL
RUN echo "http://dl-cdn.alpinelinux.org/alpine/${ALPINE_BRANCH}/main" >> /etc/apk/repositories && \
apk add --no-cache openssl=${OPENSSL_VERSION} wget perl build-base && \
rm -rf /var/lib/apt/lists/*

# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Kestrel.csproj", "."]
RUN dotnet restore "./Kestrel.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "./Kestrel.csproj" -c $BUILD_CONFIGURATION -o /app/build

# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Kestrel.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

ENTRYPOINT [ "dotnet", "Kestrel.dll" ]
4 changes: 4 additions & 0 deletions src/BenchmarksApps/TLS/Kestrel/Kestrel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
<UserSecretsId>1b89f0d2-44eb-4070-94ec-e963a14ec8b0</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Certificate" Version="9.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
</ItemGroup>

<ItemGroup>
Expand Down
25 changes: 25 additions & 0 deletions src/BenchmarksApps/TLS/Kestrel/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
Expand All @@ -9,6 +10,8 @@
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Https;

Console.WriteLine("Starting application...");

var builder = WebApplication.CreateBuilder(args);
builder.Logging.ClearProviders();

Expand Down Expand Up @@ -156,6 +159,7 @@
await app.StartAsync();

Console.WriteLine("Application Info:");
LogOpenSSLVersion();
if (mTlsEnabled)
{
Console.WriteLine($"\tmTLS is enabled (client cert is required)");
Expand Down Expand Up @@ -187,7 +191,7 @@
{
ip = IPAddress.Loopback;
}
else if (!IPAddress.TryParse(urlPrefix.Host, out ip))

Check warning on line 194 in src/BenchmarksApps/TLS/Kestrel/Program.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

Converting null literal or possible null value to non-nullable type.
{
ip = IPAddress.IPv6Any;
}
Expand Down Expand Up @@ -219,4 +223,25 @@
}

return protocols;
}

static void LogOpenSSLVersion()
{
using var process = new Process()
{
StartInfo =
{
FileName = "/usr/bin/env",
Arguments = "openssl version",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true
},
};

process.Start();
process.WaitForExit();
var output = process.StandardOutput.ReadToEnd();
Console.WriteLine(output);
}
25 changes: 18 additions & 7 deletions src/BenchmarksApps/TLS/Kestrel/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
{
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "hello-world",
"applicationUrl": "https://localhost:5000;http://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:5000;http://localhost:5001"
},
"Container (Dockerfile)": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/hello-world",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8080",
"ASPNETCORE_HTTP_PORTS": "8081"
},
"publishAllPorts": true,
"useSSL": true
}
}
}
},
"$schema": "http://json.schemastore.org/launchsettings.json"
}
Loading