diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8ed1a156..aa11a4f2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -6,7 +6,6 @@ RUN apt-get update && apt-get install -y \ build-essential \ libssl-dev \ pkg-config \ - nginx \ openjdk-17-jdk \ git \ curl \ @@ -25,6 +24,14 @@ RUN curl -L https://deb.nodesource.com/nsolid_setup_deb.sh | bash -s -- 18 && \ RUN wget https://dl.google.com/go/go1.21.1.linux-amd64.tar.gz -O- | tar xz -C /usr/local ENV PATH=$PATH:/usr/local/go/bin +# Install Openresty +RUN apt-get update && \ + apt-get -y install --no-install-recommends wget gnupg ca-certificates lsb-release && \ + wget -O - https://openresty.org/package/pubkey.gpg | gpg --dearmor -o /usr/share/keyrings/openresty.gpg && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/openresty.list && \ + apt-get update && \ + apt-get -y install --no-install-recommends openresty + # Nginx configurations RUN mkdir -p /var/cache/nginx-cache \ /var/lib/nginx/body \ diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 826d0788..eb1aef0a 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -20,6 +20,8 @@ http { resolver 8.8.8.8 valid=100s ipv6=off; listen 3000; location / { + # Delay each request by 4ms + access_by_lua_block { ngx.sleep(0.004) } proxy_set_header Host $proxy_host; proxy_ssl_verify off; proxy_ssl_server_name on; diff --git a/nginx/run.sh b/nginx/run.sh index ccb5b7c0..1cafde4c 100755 --- a/nginx/run.sh +++ b/nginx/run.sh @@ -5,4 +5,4 @@ ulimit -n 1000000 current_dir=$(pwd) # Start nginx using the configuration file from the current directory -nginx -c "$current_dir/nginx/nginx.conf" +openresty -c "$current_dir/nginx/nginx.conf" diff --git a/wrk/bench.sh b/wrk/bench.sh index a271a4b7..9088a653 100755 --- a/wrk/bench.sh +++ b/wrk/bench.sh @@ -2,7 +2,7 @@ graphqlEndpoint="${1:-http://localhost:8000/graphql}" whichBench=$2 if [ "$whichBench" == "2" ]; then - wrk -d 30 -t 4 -c 100 -s $(pwd)/wrk/wrk2.lua "$graphqlEndpoint" + wrk -d 30 -t 4 -c 100 -s $(pwd)/wrk/wrk2.lua "$graphqlEndpoint" --timeout 10 else - wrk -d 10 -t 4 -c 100 -s "$(pwd)/wrk/wrk${whichBench}.lua" "$graphqlEndpoint" + wrk -d 10 -t 4 -c 100 -s "$(pwd)/wrk/wrk${whichBench}.lua" "$graphqlEndpoint" --timeout 10 fi