$ -weight: 600;">sudo -weight: 500;">pacman -S nginx
-weight: 600;">sudo -weight: 500;">pacman -S nginx
-weight: 600;">sudo -weight: 500;">pacman -S nginx
mkdir nginx-lb
cd nginx-lb
mkdir nginx-lb
cd nginx-lb
mkdir nginx-lb
cd nginx-lb
<h1>App 1</h1>
<h1>App 1</h1>
<h1>App 1</h1>
<h1>App 2</h1>
<h1>App 2</h1>
<h1>App 2</h1>
<h1>App 3</h1>
<h1>App 3</h1>
<h1>App 3</h1>
version: '3' services: app1: image: nginx volumes: - ./app1:/usr/share/nginx/html app2: image: nginx volumes: - ./app2:/usr/share/nginx/html app3: image: nginx volumes: - ./app3:/usr/share/nginx/html nginx-lb: image: nginx container_name: nginx-lb ports: - "80:80" volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf
version: '3' services: app1: image: nginx volumes: - ./app1:/usr/share/nginx/html app2: image: nginx volumes: - ./app2:/usr/share/nginx/html app3: image: nginx volumes: - ./app3:/usr/share/nginx/html nginx-lb: image: nginx container_name: nginx-lb ports: - "80:80" volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf
version: '3' services: app1: image: nginx volumes: - ./app1:/usr/share/nginx/html app2: image: nginx volumes: - ./app2:/usr/share/nginx/html app3: image: nginx volumes: - ./app3:/usr/share/nginx/html nginx-lb: image: nginx container_name: nginx-lb ports: - "80:80" volumes: - ./nginx/nginx.conf:/etc/nginx/nginx.conf
events {} http { upstream backend { server app1:80; server app2:80; server app3:80; } server { listen 80; location / { proxy_pass http://backend; } } }
events {} http { upstream backend { server app1:80; server app2:80; server app3:80; } server { listen 80; location / { proxy_pass http://backend; } } }
events {} http { upstream backend { server app1:80; server app2:80; server app3:80; } server { listen 80; location / { proxy_pass http://backend; } } }
-weight: 500;">docker compose up -d
-weight: 500;">docker compose up -d
-weight: 500;">docker compose up -d
Windows localhost:8080 -> VM port 80
Windows localhost:8080 -> VM port 80
Windows localhost:8080 -> VM port 80
http://10.93.5.4
http://10.93.5.4
http://10.93.5.4
wrk -t4 -c100 -d30 http://127.0.0.1
wrk -t4 -c100 -d30 http://127.0.0.1
wrk -t4 -c100 -d30 http://127.0.0.1
Running 30s test @ http://127.0.0.1
4 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev
Latency 21.78ms 28.04ms 238.82ms 86.21%
Req/Sec 1.36k 1.06k 8.34k 75.55% 141456 requests in 30.05s, 34.13MB read Socket errors: connect 0, read 0, write 0, timeout 102 Requests/sec: 4706.85
Transfer/sec: 1.14MB
Running 30s test @ http://127.0.0.1
4 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev
Latency 21.78ms 28.04ms 238.82ms 86.21%
Req/Sec 1.36k 1.06k 8.34k 75.55% 141456 requests in 30.05s, 34.13MB read Socket errors: connect 0, read 0, write 0, timeout 102 Requests/sec: 4706.85
Transfer/sec: 1.14MB
Running 30s test @ http://127.0.0.1
4 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev
Latency 21.78ms 28.04ms 238.82ms 86.21%
Req/Sec 1.36k 1.06k 8.34k 75.55% 141456 requests in 30.05s, 34.13MB read Socket errors: connect 0, read 0, write 0, timeout 102 Requests/sec: 4706.85
Transfer/sec: 1.14MB
Running 30s test @ http://127.0.0.1
4 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev
Latency 10.39ms 10.07ms 146.04ms 89.23%
Req/Sec 1.76k 1.01k 6.95k 82.19% 110705 requests in 30.10s, 26.71MB read Socket errors: connect 0, read 0, write 0, timeout 100 Requests/sec: 3678.10
Transfer/sec: 0.89MB
Running 30s test @ http://127.0.0.1
4 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev
Latency 10.39ms 10.07ms 146.04ms 89.23%
Req/Sec 1.76k 1.01k 6.95k 82.19% 110705 requests in 30.10s, 26.71MB read Socket errors: connect 0, read 0, write 0, timeout 100 Requests/sec: 3678.10
Transfer/sec: 0.89MB
Running 30s test @ http://127.0.0.1
4 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev
Latency 10.39ms 10.07ms 146.04ms 89.23%
Req/Sec 1.76k 1.01k 6.95k 82.19% 110705 requests in 30.10s, 26.71MB read Socket errors: connect 0, read 0, write 0, timeout 100 Requests/sec: 3678.10
Transfer/sec: 0.89MB
Thread Stats Avg Stdev Max +/- Stdev
Latency 13.85ms 11.87ms 247.23ms 87.54%
Req/Sec 1.74k 672.33 6.35k 75.85% 207100 requests in 30.03s, 49.97MB read Requests/sec: 6895.35
Transfer/sec: 1.66MB
Thread Stats Avg Stdev Max +/- Stdev
Latency 13.85ms 11.87ms 247.23ms 87.54%
Req/Sec 1.74k 672.33 6.35k 75.85% 207100 requests in 30.03s, 49.97MB read Requests/sec: 6895.35
Transfer/sec: 1.66MB
Thread Stats Avg Stdev Max +/- Stdev
Latency 13.85ms 11.87ms 247.23ms 87.54%
Req/Sec 1.74k 672.33 6.35k 75.85% 207100 requests in 30.03s, 49.97MB read Requests/sec: 6895.35
Transfer/sec: 1.66MB - experiment freely
- break things safely
- learn networking
- build servers manually
- understand infrastructure properly - load balancing
- benchmarking - an Nginx config
- a Docker Compose setup - Host Port: 8080
- Guest Port: 80 - -t4 → 4 threads
- -c100 → 100 concurrent connections
- -d30 → run test for 30 seconds - 1 backend container
- 2 backend containers
- 3 backend containers - reverse proxies
- traffic routing
- load balancing