-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adding nginx benchmark in ci (#1929)
- Loading branch information
1 parent
8b6db44
commit c39faf0
Showing
3 changed files
with
135 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: Nginx Benchmark | ||
|
||
on: | ||
push: | ||
paths-ignore: ["docs/**", "**.md"] | ||
branches: | ||
- main | ||
pull_request: | ||
paths-ignore: ["docs/**", "**.md"] | ||
types: [opened, reopened, synchronize, labeled] | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
nginx_benchmarks: | ||
name: Nginx Benchmarks | ||
if: "contains(github.event.pull_request.labels.*.name, 'ci: benchmark') || github.event_name == 'push'" | ||
runs-on: benchmarking-runner | ||
permissions: | ||
pull-requests: write | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Install Stable Toolchain | ||
uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
|
||
- name: Run Cargo Build | ||
run: cargo build --release | ||
|
||
- name: Run Tailcall | ||
run: | | ||
TAILCALL_LOG_LEVEL=error ./target/release/tailcall start ci-benchmark/nginx-benchmark.graphql & | ||
- name: Install Nginx | ||
run: | | ||
sudo apt-get install -y nginx | ||
- name: Start Nginx | ||
working-directory: ci-benchmark | ||
run: | | ||
nginx -c "$(pwd)/nginx.conf" | ||
- name: Install Wrk | ||
run: | | ||
sudo apt-get install -y wrk | ||
- name: Run Test Query | ||
run: | | ||
curl -i -X POST -d '{"query": "{posts{title}}"}' http://localhost:8000/graphql -H "Content-Type: application/json" | ||
- name: Warmup Wrk | ||
working-directory: ci-benchmark | ||
run: | | ||
wrk -d 10 -t 4 -c 100 -s wrk.lua http://localhost:8000/graphql | ||
- id: run_wrk | ||
name: Run Wrk | ||
working-directory: ci-benchmark | ||
run: | | ||
wrk -d 30 -t 4 -c 100 -s wrk.lua http://localhost:8000/graphql > wrk-output.txt | ||
- id: convert_wrk_output_markdown | ||
name: Convert Output to Markdown | ||
working-directory: ci-benchmark | ||
run: | | ||
node wrk-output-to-md.js wrk-output.txt > body.md | ||
- id: cat_md | ||
name: Cat Markdown | ||
working-directory: ci-benchmark | ||
run: | | ||
cat body.md | ||
- name: "Upload Artifact" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: body | ||
path: ci-benchmark/body.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
schema | ||
@server(hostname: "0.0.0.0", port: 8000) | ||
@upstream( | ||
baseURL: "http://jsonplaceholder.typicode.com" | ||
poolMaxIdlePerHost: 200 | ||
tcpKeepAlive: 60 | ||
proxy: {url: "http://127.0.0.1:3000"} | ||
) { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
posts: [Post] @http(path: "/posts") | ||
} | ||
|
||
type User { | ||
id: Int! | ||
name: String! | ||
username: String! | ||
email: String! | ||
phone: String | ||
website: String | ||
} | ||
|
||
type Post { | ||
id: Int! | ||
userId: Int! | ||
title: String! | ||
body: String! | ||
user: User @http(path: "/users/{{value.userId}}") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
pid /tmp/nginx.pid; | ||
worker_processes auto; | ||
worker_rlimit_nofile 65536; | ||
|
||
events { | ||
worker_connections 1024; | ||
worker_connections 512; | ||
} | ||
|
||
http { | ||
proxy_cache_path /var/cache/nginx-cache levels=1:2 keys_zone=http_cache:10m max_size=1g inactive=60m use_temp_path=on; | ||
error_log /tmp/error.log error; | ||
|
||
server { | ||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
http { | ||
proxy_cache_path /tmp/nginx-cache levels=1:2 keys_zone=http_cache:10m max_size=1g inactive=60m use_temp_path=on; | ||
access_log /dev/null; | ||
client_body_temp_path /tmp/nginx-client-body; | ||
proxy_temp_path /tmp/nginx-proxy; | ||
fastcgi_temp_path /tmp/nginx-fastcgi; | ||
uwsgi_temp_path /tmp/nginx-uwsgi; | ||
scgi_temp_path /tmp/nginx-scgi; | ||
|
||
resolver 8.8.8.8 valid=100s ipv6=off; | ||
listen 8080; | ||
location / { | ||
proxy_set_header Host $proxy_host; | ||
proxy_ssl_verify off; | ||
proxy_ssl_server_name on; | ||
proxy_pass http://$host; | ||
proxy_cache http_cache; | ||
proxy_cache_valid 200 302 60m; | ||
proxy_cache_valid 404 1m; | ||
} | ||
} | ||
} | ||
server { | ||
resolver 8.8.8.8 valid=100s ipv6=off; | ||
listen 3000; | ||
location / { | ||
proxy_set_header Host $proxy_host; | ||
proxy_ssl_verify off; | ||
proxy_ssl_server_name on; | ||
proxy_pass http://$host; | ||
proxy_cache http_cache; | ||
proxy_cache_valid 200 302 60m; | ||
proxy_cache_valid 404 1m; | ||
} | ||
} | ||
} |
c39faf0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running 30s test @ http://localhost:8000/graphql
4 threads and 100 connections
423587 requests in 30.01s, 2.12GB read
Requests/sec: 14117.19
Transfer/sec: 72.46MB