From b5995292f467236a12128e828b110348a6afb2d0 Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Mon, 8 Jul 2024 18:39:40 +0530 Subject: [PATCH 01/11] add nginx delay Signed-off-by: Sahil Yeole --- .devcontainer/Dockerfile | 10 +++++++++- nginx/nginx.conf | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9f77c9ca..2a9ed136 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,15 @@ RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \ 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 Nginx with echo module +RUN wget http://nginx.org/download/nginx-1.11.2.tar.gz && \ + tar -xzvf nginx-1.11.2.tar.gz && \ + git clone https://github.com/openresty/echo-nginx-module.git && \ + cd nginx-1.11.2 && \ + ./configure --prefix=/opt/nginx --add-module=../echo-nginx-module && \ + make -j2 && \ + make install + # 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..4893ee23 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -20,6 +20,7 @@ http { resolver 8.8.8.8 valid=100s ipv6=off; listen 3000; location / { + echo_sleep 0.004; # Delay each request by 4ms proxy_set_header Host $proxy_host; proxy_ssl_verify off; proxy_ssl_server_name on; From 301fd8188eaf1d7a87b0b1ac0034a8fa02dab0ba Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Mon, 8 Jul 2024 18:48:04 +0530 Subject: [PATCH 02/11] install pcre Signed-off-by: Sahil Yeole --- .devcontainer/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2a9ed136..0071e6fd 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -6,6 +6,8 @@ RUN apt-get update && apt-get install -y \ build-essential \ libssl-dev \ pkg-config \ + libpcre3 \ + libpcre3-dev \ openjdk-17-jdk \ git \ curl \ From 4e8aae324fe5831626b80e1bb0dc505ee912b43f Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Mon, 8 Jul 2024 18:57:01 +0530 Subject: [PATCH 03/11] nginx build: dont treat warnings as errors Signed-off-by: Sahil Yeole --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0071e6fd..4af7140f 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -31,7 +31,7 @@ RUN wget http://nginx.org/download/nginx-1.11.2.tar.gz && \ tar -xzvf nginx-1.11.2.tar.gz && \ git clone https://github.com/openresty/echo-nginx-module.git && \ cd nginx-1.11.2 && \ - ./configure --prefix=/opt/nginx --add-module=../echo-nginx-module && \ + CFLAGS="-Wno-implicit-fallthrough" ./configure --prefix=/opt/nginx --add-module=../echo-nginx-module && \ make -j2 && \ make install From dbebb2562e2f5f51a15e9ce8a2e3494077278e81 Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Mon, 8 Jul 2024 19:04:45 +0530 Subject: [PATCH 04/11] upgrade nginx Signed-off-by: Sahil Yeole --- .devcontainer/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4af7140f..11d1b391 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -27,8 +27,8 @@ RUN wget https://dl.google.com/go/go1.21.1.linux-amd64.tar.gz -O- | tar xz -C /u ENV PATH=$PATH:/usr/local/go/bin # Install Nginx with echo module -RUN wget http://nginx.org/download/nginx-1.11.2.tar.gz && \ - tar -xzvf nginx-1.11.2.tar.gz && \ +RUN wget http://nginx.org/download/nginx-1.26.0.tar.gz && \ + tar -xzvf nginx-1.26.0.tar.gz && \ git clone https://github.com/openresty/echo-nginx-module.git && \ cd nginx-1.11.2 && \ CFLAGS="-Wno-implicit-fallthrough" ./configure --prefix=/opt/nginx --add-module=../echo-nginx-module && \ From 13a9a36385e71fed93e1e1f11fba61d818b63463 Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Mon, 8 Jul 2024 19:07:40 +0530 Subject: [PATCH 05/11] upgrade nginx Signed-off-by: Sahil Yeole --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 11d1b391..ad08ed8d 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -30,7 +30,7 @@ ENV PATH=$PATH:/usr/local/go/bin RUN wget http://nginx.org/download/nginx-1.26.0.tar.gz && \ tar -xzvf nginx-1.26.0.tar.gz && \ git clone https://github.com/openresty/echo-nginx-module.git && \ - cd nginx-1.11.2 && \ + cd nginx-1.26.0 && \ CFLAGS="-Wno-implicit-fallthrough" ./configure --prefix=/opt/nginx --add-module=../echo-nginx-module && \ make -j2 && \ make install From 07cd0537412e63fdde9c5c92077845b6cfe3860f Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Mon, 8 Jul 2024 23:05:12 +0530 Subject: [PATCH 06/11] use openresty instead of nginx Signed-off-by: Sahil Yeole --- .devcontainer/Dockerfile | 15 +++++++-------- nginx/run.sh | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index ad08ed8d..603d29ff 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -26,14 +26,13 @@ RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \ 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 Nginx with echo module -RUN wget http://nginx.org/download/nginx-1.26.0.tar.gz && \ - tar -xzvf nginx-1.26.0.tar.gz && \ - git clone https://github.com/openresty/echo-nginx-module.git && \ - cd nginx-1.26.0 && \ - CFLAGS="-Wno-implicit-fallthrough" ./configure --prefix=/opt/nginx --add-module=../echo-nginx-module && \ - make -j2 && \ - make install +# 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-archive-keyring.gpg && \ + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty-archive-keyring.gpg] http://openresty.org/package/$(dpkg --print-architecture)/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 \ 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" From 849f59ec0d676357bd2e73e1061abe573edef16c Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Mon, 8 Jul 2024 23:27:03 +0530 Subject: [PATCH 07/11] fix openresty install Signed-off-by: Sahil Yeole --- .devcontainer/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 603d29ff..e3984128 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -29,8 +29,8 @@ 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-archive-keyring.gpg && \ - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty-archive-keyring.gpg] http://openresty.org/package/$(dpkg --print-architecture)/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/openresty.list && \ + 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 From 206a4e7f6dd394f9cb1657fcf033e7b68f863fa0 Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Mon, 8 Jul 2024 23:44:27 +0530 Subject: [PATCH 08/11] remove unused libs Signed-off-by: Sahil Yeole --- .devcontainer/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e3984128..3e5c8b1a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -6,8 +6,6 @@ RUN apt-get update && apt-get install -y \ build-essential \ libssl-dev \ pkg-config \ - libpcre3 \ - libpcre3-dev \ openjdk-17-jdk \ git \ curl \ From 6f638c72cdb359d05ed0013a627f2c4b2811f69c Mon Sep 17 00:00:00 2001 From: Tushar Mathur Date: Tue, 9 Jul 2024 18:04:56 +0530 Subject: [PATCH 09/11] Update nginx.conf --- nginx/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 4893ee23..1f586b81 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -20,7 +20,7 @@ http { resolver 8.8.8.8 valid=100s ipv6=off; listen 3000; location / { - echo_sleep 0.004; # Delay each request by 4ms + echo_sleep 0.4; # Delay each request by 4ms proxy_set_header Host $proxy_host; proxy_ssl_verify off; proxy_ssl_server_name on; From 196058bb3d40e67b3c658138d4b315e73b177ade Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Mon, 15 Jul 2024 09:58:28 +0530 Subject: [PATCH 10/11] fix: nginx delay Signed-off-by: Sahil Yeole --- nginx/nginx.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 1f586b81..eb1aef0a 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -20,7 +20,8 @@ http { resolver 8.8.8.8 valid=100s ipv6=off; listen 3000; location / { - echo_sleep 0.4; # Delay each request by 4ms + # 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; From 30970639def3ddad60d96018d50d63c8a083a0ce Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Mon, 15 Jul 2024 18:09:55 +0530 Subject: [PATCH 11/11] increase wrk timeout to prevent timeout errors Signed-off-by: Sahil Yeole --- wrk/bench.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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