Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nginx delay #309

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
9 changes: 8 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ RUN apt-get update && apt-get install -y \
build-essential \
libssl-dev \
pkg-config \
nginx \
openjdk-17-jdk \
git \
curl \
Expand All @@ -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 \
Expand Down
2 changes: 2 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion nginx/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions wrk/bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading