update dockerfile and benchmark result

This commit is contained in:
Jun Kurihara 2022-07-23 00:32:21 +09:00
commit b3d8886096
6 changed files with 110 additions and 27 deletions

View file

@ -1,18 +1,13 @@
FROM ubuntu:22.04 FROM ubuntu:22.04 AS base
LABEL maintainer="Jun Kurihara"
SHELL ["/bin/sh", "-x", "-c"] SHELL ["/bin/sh", "-x", "-c"]
ENV SERIAL 2 ENV SERIAL 2
FROM base as builder
ENV CFLAGS=-Ofast ENV CFLAGS=-Ofast
ENV BUILD_DEPS curl make build-essential libevent-dev libexpat1-dev autoconf file libssl-dev byacc pkg-config ENV BUILD_DEPS curl make build-essential libevent-dev libexpat1-dev autoconf file libssl-dev byacc pkg-config ca-certificates
ENV RUNTIME_DEPS bash util-linux coreutils findutils grep libssl3 ldnsutils libevent-2.1 expat ca-certificates jed logrotate
RUN apt-get update; apt-get -qy dist-upgrade; apt-get -qy clean && \
apt-get install -qy --no-install-recommends $RUNTIME_DEPS && \
rm -fr /tmp/* /var/tmp/* /var/cache/apt/* /var/lib/apt/lists/* /var/log/apt/* /var/log/*.log
RUN update-ca-certificates 2> /dev/null || true
WORKDIR /tmp WORKDIR /tmp
@ -20,21 +15,28 @@ COPY . /tmp/
ENV RUSTFLAGS "-C link-arg=-s" ENV RUSTFLAGS "-C link-arg=-s"
RUN update-ca-certificates 2> /dev/null || true
RUN apt-get update && apt-get install -qy --no-install-recommends $BUILD_DEPS && \ RUN apt-get update && apt-get install -qy --no-install-recommends $BUILD_DEPS && \
curl -sSf https://sh.rustup.rs | bash -s -- -y --default-toolchain stable && \ curl -sSf https://sh.rustup.rs | bash -s -- -y --default-toolchain stable && \
export PATH="$HOME/.cargo/bin:$PATH" && \ export PATH="$HOME/.cargo/bin:$PATH" && \
echo "Building rpxy from source" && \ echo "Building rpxy from source" && \
cargo build --release && \ cargo build --release && \
mkdir -p /opt/rpxy/sbin && \ strip --strip-all /tmp/target/release/rpxy
mv /tmp/target/release/rpxy /opt/rpxy/sbin/rpxy && \
strip --strip-all /opt/rpxy/sbin/rpxy && \
apt-get -qy purge $BUILD_DEPS && apt-get -qy autoremove && \
rm -fr ~/.cargo ~/.rustup && \
rm -fr /tmp/* /var/tmp/* /var/cache/apt/* /var/lib/apt/lists/* /var/log/apt/* /var/log/*.log &&\
rm -fr ~/.cargo ~/.rustup && \
rm -fr /tmp/* /var/tmp/* /var/cache/apt/* /var/lib/apt/lists/* /var/log/apt/* /var/log/*.log &&\
mkdir -p /var/log/rpxy && touch /var/log/rpxy/rpxy.log
FROM base AS runner
LABEL maintainer="Jun Kurihara"
ENV RUNTIME_DEPS bash logrotate
RUN apt-get update; apt-get -qy dist-upgrade; apt-get -qy clean && \
apt-get install -qy --no-install-recommends $RUNTIME_DEPS && \
rm -fr /tmp/* /var/tmp/* /var/cache/apt/* /var/lib/apt/lists/* /var/log/apt/* /var/log/*.log &&\
mkdir -p /opt/rpxy/sbin &&\
mkdir -p /var/log/rpxy && \
touch /var/log/rpxy/rpxy.log
COPY --from=builder /tmp/target/release/rpxy /opt/rpxy/sbin/rpxy
COPY docker-bin/run.sh / COPY docker-bin/run.sh /
COPY docker-bin/entrypoint.sh / COPY docker-bin/entrypoint.sh /

83
bench/README.md Normal file
View file

@ -0,0 +1,83 @@
# Sample Benchmark Result
Using `rewrk` and Docker on a Macbook Pro 14 to simply measure the performance of several reverse proxy through HTTP1.1.
```
$ rewrk -c 512 -t 4 -d 15s -h http://localhost:8080 --pct
```
```
----------------------------
Benchmark on rpxy
Beginning round 1...
Benchmarking 512 connections @ http://localhost:8080 for 15 second(s)
Latencies:
Avg Stdev Min Max
26.81ms 11.96ms 2.96ms 226.04ms
Requests:
Total: 285390 Req/Sec: 19032.01
Transfer:
Total: 222.85 MB Transfer Rate: 14.86 MB/Sec
+ --------------- + --------------- +
| Percentile | Avg Latency |
+ --------------- + --------------- +
| 99.9% | 145.89ms |
| 99% | 81.33ms |
| 95% | 59.08ms |
| 90% | 51.67ms |
| 75% | 42.45ms |
| 50% | 35.39ms |
+ --------------- + --------------- +
767 Errors: error shutting down connection: Socket is not connected (os error 57)
sleep 3 secs
----------------------------
Benchmark on nginx
Beginning round 1...
Benchmarking 512 connections @ http://localhost:8090 for 15 second(s)
Latencies:
Avg Stdev Min Max
38.39ms 21.06ms 2.91ms 248.32ms
Requests:
Total: 199210 Req/Sec: 13288.91
Transfer:
Total: 161.46 MB Transfer Rate: 10.77 MB/Sec
+ --------------- + --------------- +
| Percentile | Avg Latency |
+ --------------- + --------------- +
| 99.9% | 164.33ms |
| 99% | 121.55ms |
| 95% | 96.43ms |
| 90% | 85.05ms |
| 75% | 67.80ms |
| 50% | 53.85ms |
+ --------------- + --------------- +
736 Errors: error shutting down connection: Socket is not connected (os error 57)
sleep 3 secs
----------------------------
Benchmark on caddy
Beginning round 1...
Benchmarking 512 connections @ http://localhost:8100 for 15 second(s)
Latencies:
Avg Stdev Min Max
83.17ms 73.71ms 1.24ms 734.67ms
Requests:
Total: 91685 Req/Sec: 6114.05
Transfer:
Total: 73.20 MB Transfer Rate: 4.88 MB/Sec
+ --------------- + --------------- +
| Percentile | Avg Latency |
+ --------------- + --------------- +
| 99.9% | 642.29ms |
| 99% | 507.21ms |
| 95% | 324.34ms |
| 90% | 249.55ms |
| 75% | 174.62ms |
| 50% | 128.85ms |
+ --------------- + --------------- +
740 Errors: error shutting down connection: Socket is not connected (os error 57)
```

View file

@ -16,7 +16,7 @@
echo "----------------------------" echo "----------------------------"
echo "Benchmark on rpxy" echo "Benchmark on rpxy"
#wrk -t8 -c100 -d30s http://127.0.0.1:8080/index.html #wrk -t8 -c100 -d30s http://127.0.0.1:8080/index.html
rewrk -c 256 -t 4 -d 10s -h http://localhost:8080 --pct rewrk -c 512 -t 4 -d 15s -h http://localhost:8080 --pct
echo "sleep 3 secs" echo "sleep 3 secs"
sleep 3 sleep 3
@ -24,7 +24,7 @@ sleep 3
echo "----------------------------" echo "----------------------------"
echo "Benchmark on nginx" echo "Benchmark on nginx"
# wrk -t8 -c100 -d30s http://127.0.0.1:8090/index.html # wrk -t8 -c100 -d30s http://127.0.0.1:8090/index.html
rewrk -c 256 -t 4 -d 10s -h http://localhost:8090 --pct rewrk -c 512 -t 4 -d 15s -h http://localhost:8090 --pct
echo "sleep 3 secs" echo "sleep 3 secs"
sleep 3 sleep 3
@ -32,4 +32,4 @@ sleep 3
echo "----------------------------" echo "----------------------------"
echo "Benchmark on caddy" echo "Benchmark on caddy"
# wrk -t8 -c100 -d30s http://127.0.0.1:8100/index.html # wrk -t8 -c100 -d30s http://127.0.0.1:8100/index.html
rewrk -c 256 -t 4 -d 10s -h http://localhost:8100 --pct rewrk -c 512 -t 4 -d 15s -h http://localhost:8100 --pct

View file

@ -38,7 +38,7 @@ services:
bench-nw: bench-nw:
nginx-rp: nginx-rp:
image: jwilder/nginx-proxy:alpine image: nginx:alpine
container_name: proxy-nginx container_name: proxy-nginx
ports: ports:
- 127.0.0.1:8090:80 - 127.0.0.1:8090:80
@ -46,8 +46,7 @@ services:
tty: false tty: false
privileged: true privileged: true
volumes: volumes:
- ./nginx_data/vhost:/etc/nginx/vhost.d:ro - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./nginx_data/conf:/etc/nginx/conf.d/:ro
- /var/run/docker.sock:/tmp/docker.sock:ro - /var/run/docker.sock:/tmp/docker.sock:ro
logging: logging:
options: options:

View file

@ -5,7 +5,7 @@ listen_port = 8080
max_concurrent_streams = 128 max_concurrent_streams = 128
max_clients = 512 max_clients = 512
default_app = 'localhost' # passing through 127.0.0.1 # default_app = 'localhost' # passing through 127.0.0.1
[apps] [apps]
@ -20,4 +20,3 @@ reverse_proxy = [
[experimental] [experimental]
h3 = false