add bench docker
This commit is contained in:
parent
c0af62b6cd
commit
7172f932ca
8 changed files with 78 additions and 8 deletions
|
|
@ -24,13 +24,13 @@ 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 --no-default-features && \
|
cargo build --release && \
|
||||||
mkdir -p /opt/rpxy/sbin && \
|
mkdir -p /opt/rpxy/sbin && \
|
||||||
mv /tmp/target/release/rpxy /opt/rpxy/sbin/ && \
|
mv /tmp/target/release/rust-rpxy /opt/rpxy/sbin/rpxy && \
|
||||||
strip --strip-all /opt/rpxy/sbin/rpxy && \
|
strip --strip-all /opt/rpxy/sbin/rpxy && \
|
||||||
apt-get -qy purge $BUILD_DEPS && apt-get -qy autoremove && \
|
apt-get -qy purge $BUILD_DEPS && apt-get -qy autoremove && \
|
||||||
rm -fr ~/.cargo ~/.rustup && \
|
rm -fr ~/.cargo ~/.rustup && \
|
||||||
rm -fr /tmp/* /var/tmp/* /var/cache/apt/* /var/lib/apt/lists/* /var/log/apt/* /var/log/*.log
|
rm -fr /tmp/* /var/tmp/* /var/cache/apt/* /var/lib/apt/lists/* /var/log/apt/* /var/log/*.log &&\
|
||||||
rm -fr ~/.cargo ~/.rustup && \
|
rm -fr ~/.cargo ~/.rustup && \
|
||||||
rm -fr /tmp/* /var/tmp/* /var/cache/apt/* /var/lib/apt/lists/* /var/log/apt/* /var/log/*.log
|
rm -fr /tmp/* /var/tmp/* /var/cache/apt/* /var/lib/apt/lists/* /var/log/apt/* /var/log/*.log
|
||||||
|
|
||||||
|
|
|
||||||
13
bench/bench.sh
Normal file
13
bench/bench.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "----------------------------"
|
||||||
|
echo "Benchmark on rpxy"
|
||||||
|
ab -c 32 -n 10000 http://127.0.0.1:8080/
|
||||||
|
|
||||||
|
echo "----------------------------"
|
||||||
|
echo "Benchmark on nginx"
|
||||||
|
ab -c 32 -n 10000 http://127.0.0.1:8090/
|
||||||
|
|
||||||
|
echo "----------------------------"
|
||||||
|
echo "Benchmark on caddy"
|
||||||
|
ab -c 32 -n 10000 http://127.0.0.1:8100/
|
||||||
|
|
@ -15,13 +15,31 @@ services:
|
||||||
options:
|
options:
|
||||||
max-size: "10m"
|
max-size: "10m"
|
||||||
max-file: "3"
|
max-file: "3"
|
||||||
|
networks:
|
||||||
|
bench-nw:
|
||||||
|
ipv4_address: 192.168.100.100
|
||||||
|
|
||||||
|
rpxy-rp:
|
||||||
|
image: jqtype/rpxy
|
||||||
|
container_name: proxy-rpxy
|
||||||
|
build:
|
||||||
|
context: ../
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- 127.0.0.1:8080:8080
|
||||||
|
tty: false
|
||||||
|
privileged: true
|
||||||
|
volumes:
|
||||||
|
- ./rpxy.toml:/etc/rpxy.toml:ro
|
||||||
|
networks:
|
||||||
|
bench-nw:
|
||||||
|
|
||||||
nginx-rp:
|
nginx-rp:
|
||||||
image: jwilder/nginx-proxy:alpine
|
image: jwilder/nginx-proxy:alpine
|
||||||
container_name: proxy-nginx
|
container_name: proxy-nginx
|
||||||
ports:
|
ports:
|
||||||
- 127.0.0.1:8090:80
|
- 127.0.0.1:8090:80
|
||||||
restart: always
|
restart: unless-stopped
|
||||||
tty: false
|
tty: false
|
||||||
privileged: true
|
privileged: true
|
||||||
volumes:
|
volumes:
|
||||||
|
|
@ -30,6 +48,8 @@ services:
|
||||||
options:
|
options:
|
||||||
max-size: "10m"
|
max-size: "10m"
|
||||||
max-file: "3"
|
max-file: "3"
|
||||||
|
networks:
|
||||||
|
bench-nw:
|
||||||
|
|
||||||
caddy-rp:
|
caddy-rp:
|
||||||
image: caddy:2
|
image: caddy:2
|
||||||
|
|
@ -40,3 +60,14 @@ services:
|
||||||
tty: false
|
tty: false
|
||||||
volumes:
|
volumes:
|
||||||
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
||||||
|
networks:
|
||||||
|
bench-nw:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
bench-nw:
|
||||||
|
name: bench-nw
|
||||||
|
driver: bridge
|
||||||
|
ipam:
|
||||||
|
driver: default
|
||||||
|
config:
|
||||||
|
- subnet: 192.168.100.0/24
|
||||||
|
|
|
||||||
17
bench/rpxy.toml
Normal file
17
bench/rpxy.toml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
listen_port = 8080
|
||||||
|
listen_port_tls = 8443
|
||||||
|
listen_ipv6 = false
|
||||||
|
|
||||||
|
max_concurrent_streams = 128
|
||||||
|
max_clients = 512
|
||||||
|
|
||||||
|
|
||||||
|
[apps]
|
||||||
|
|
||||||
|
[apps.localhost]
|
||||||
|
server_name = 'localhost'
|
||||||
|
reverse_proxy = [
|
||||||
|
# default destination if path is not specified
|
||||||
|
# Array for load balancing
|
||||||
|
{ upstream = [{ location = '192.168.100.100', tls = false }] },
|
||||||
|
]
|
||||||
|
|
@ -13,6 +13,8 @@ listen_port_tls = 8443
|
||||||
max_concurrent_streams = 128
|
max_concurrent_streams = 128
|
||||||
max_clients = 512
|
max_clients = 512
|
||||||
|
|
||||||
|
listen_ipv6 = false
|
||||||
|
|
||||||
###################################
|
###################################
|
||||||
# Backend settings #
|
# Backend settings #
|
||||||
###################################
|
###################################
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,13 @@ pub fn parse_opts(globals: &mut Globals, backends: &mut HashMap<String, Backend>
|
||||||
},
|
},
|
||||||
anyhow!("Wrong port spec.")
|
anyhow!("Wrong port spec.")
|
||||||
);
|
);
|
||||||
globals.listen_sockets = LISTEN_ADDRESSES
|
let mut listen_addresses: Vec<&str> = LISTEN_ADDRESSES_V4.to_vec();
|
||||||
.to_vec()
|
if let Some(v) = config.listen_ipv6 {
|
||||||
|
if v {
|
||||||
|
listen_addresses.extend(LISTEN_ADDRESSES_V6.iter());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
globals.listen_sockets = listen_addresses
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|x| {
|
.flat_map(|x| {
|
||||||
let mut v: Vec<SocketAddr> = vec![];
|
let mut v: Vec<SocketAddr> = vec![];
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use std::{collections::HashMap, fs};
|
||||||
pub struct ConfigToml {
|
pub struct ConfigToml {
|
||||||
pub listen_port: Option<u16>,
|
pub listen_port: Option<u16>,
|
||||||
pub listen_port_tls: Option<u16>,
|
pub listen_port_tls: Option<u16>,
|
||||||
|
pub listen_ipv6: Option<bool>,
|
||||||
pub max_concurrent_streams: Option<u32>,
|
pub max_concurrent_streams: Option<u32>,
|
||||||
pub max_clients: Option<u32>,
|
pub max_clients: Option<u32>,
|
||||||
pub apps: Option<Apps>,
|
pub apps: Option<Apps>,
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
pub const LISTEN_ADDRESSES: &[&str] = &["0.0.0.0", "[::]"];
|
pub const LISTEN_ADDRESSES_V4: &[&str] = &["0.0.0.0"];
|
||||||
|
pub const LISTEN_ADDRESSES_V6: &[&str] = &["[::]"];
|
||||||
// pub const HTTP_LISTEN_PORT: u16 = 8080;
|
// pub const HTTP_LISTEN_PORT: u16 = 8080;
|
||||||
// pub const HTTPS_LISTEN_PORT: u16 = 8443;
|
// pub const HTTPS_LISTEN_PORT: u16 = 8443;
|
||||||
pub const TIMEOUT_SEC: u64 = 10;
|
pub const TIMEOUT_SEC: u64 = 10;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue