Skip to content

Commit

Permalink
update installation (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
amitksingh1490 authored Nov 22, 2024
1 parent 5b057ea commit be7ff1d
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 66 deletions.
29 changes: 14 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
FROM debian:trixie-slim
ARG WUNDER_URL="https://github.com/wundergraph/cosmo/releases/download/router%400.136.1/[email protected]"
ARG APOLLO_URL="https://github.com/apollographql/router/releases/download/v1.57.1/router-v1.57.1-x86_64-unknown-linux-gnu.tar.gz"
ARG GRAFBASE_URL="https://github.com/grafbase/grafbase/releases/download/gateway-0.17.0/grafbase-gateway-x86_64-unknown-linux-musl"
ARG TAILCALL_URL="https://github.com/tailcallhq/tailcall/releases/download/v0.124.0/tailcall-x86_64-unknown-linux-gnu"

WORKDIR /usr/src/benchmarks

# Update, upgrade, and install dependencies
RUN apt update && apt upgrade -y && \
apt install -y hey curl gcc musl-dev build-essential nginx=1.26.0-3+b1 wget && \
apt install -y hey lsof curl gcc musl-dev build-essential nginx=1.26.0-3+b1 wget nodejs npm && \
rm -rf /var/lib/apt/lists/*

# Setup Rust
Expand All @@ -25,21 +21,24 @@ RUN cargo build --release
# Configure NGINX
COPY nginx/nginx.conf /etc/nginx/sites-available/default

# Setup Wundergraph
RUN wget -O wunder.tar.gz "$WUNDER_URL" && \
tar -xvf wunder.tar.gz && rm wunder.tar.gz && \
mv router wunder && chmod +x wunder
# Install WunderGraph CLI and Router
RUN npm install -g wgc@latest && \
wgc router download-binary -o . && \
mv router wunder && \
chmod +x wunder

# Install Apollo Router
RUN curl -sSL https://router.apollo.dev/download/nix/latest | sh && \
mv router apollo && chmod +x apollo

# Setup Apollo
RUN wget -O apollo.tar.gz "$APOLLO_URL" && \
tar -xvf apollo.tar.gz && rm apollo.tar.gz && \
mv dist/router apollo && chmod +x apollo

# Setup Grafbase
RUN wget -O grafbase "$GRAFBASE_URL" && chmod +x grafbase
RUN curl -fsSL https://grafbase.com/downloads/gateway | bash && \
mv ~/.grafbase/bin/grafbase-gateway grafbase && chmod +x grafbase


# Setup Tailcall
RUN wget -O tailcall "$TAILCALL_URL" && chmod +x tailcall
RUN npm install -g @tailcallhq/tailcall

# Copy Configurations and Scripts
COPY configurations/* .
Expand Down
2 changes: 1 addition & 1 deletion configurations/employees-all.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ schema {

type Query {
employees: [Employee!]!
@http(url: "http://127.0.0.1:4001/employees", dedupe: true)
@http(url: "http://127.0.0.1:4006/employees", dedupe: true)
@cache(maxAge: 40)
}

Expand Down
2 changes: 1 addition & 1 deletion configurations/employees-basic.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ schema {
}

type Query {
employees: [Employee!]! @http(url: "http://127.0.0.1:4001/employees")
employees: [Employee!]! @http(url: "http://127.0.0.1:4006/employees")
}

enum Department {
Expand Down
2 changes: 1 addition & 1 deletion configurations/employees-cache.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ schema {

type Query {
employees: [Employee!]!
@http(url: "http://127.0.0.1:4001/employees")
@http(url: "http://127.0.0.1:4006/employees")
@cache(maxAge: 40)
}

Expand Down
2 changes: 1 addition & 1 deletion configurations/employees-dedupe.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ schema {

type Query {
employees: [Employee!]!
@http(url: "http://127.0.0.1:4001/employees", dedupe: true)
@http(url: "http://127.0.0.1:4006/employees", dedupe: true)
}

enum Department {
Expand Down
2 changes: 1 addition & 1 deletion configurations/supergraph.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ scalar join__FieldSet

enum join__Graph {
AVAILABILITY @join__graph(name: "availability", url: "http://127.0.0.1:4007/graphql")
EMPLOYEES @join__graph(name: "employees", url: "http://127.0.0.1:4001/graphql")
EMPLOYEES @join__graph(name: "employees", url: "http://127.0.0.1:4006/graphql")
FAMILY @join__graph(name: "family", url: "http://127.0.0.1:4002/graphql")
HOBBIES @join__graph(name: "hobbies", url: "http://127.0.0.1:4003/graphql")
MOOD @join__graph(name: "mood", url: "http://127.0.0.1:4008/graphql")
Expand Down
2 changes: 1 addition & 1 deletion configurations/wundergraph_config.json

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,3 @@ server {
proxy_pass http://127.0.0.1:4006/;
}
}

server {
listen 8091;
server_name _;

location / {
proxy_pass http://127.0.0.1:4001/;
}
}
65 changes: 45 additions & 20 deletions scripts/benchmark.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,49 @@
#!/bin/bash

benchmark_file="bench-hey-$1.json"
echo "Script executed from: ${PWD}"

echo "Setup Benchmark (payload=$1) (project=$2)"
# Define a function to kill processes running on a specific port
kill_port_process() {
local port=$1
echo "Checking for process on port $port..."
pid=$(lsof -ti:$port)
if [ -n "$pid" ]; then
echo "Killing process $pid running on port $port..."
kill -9 "$pid"
echo "Process terminated."
else
echo "No process found on port $port."
fi
}
cleanup() {
echo "Cleaning up..."
# List of processes to terminate
processes=("tailcall" "nginx" "wunder" "apollo" "grafbase")

for process in "${processes[@]}"; do
for pid in $(ls /proc | grep -E '^[0-9]+$' | xargs -I {} sh -c "grep -l '$process' /proc/{}/comm 2>/dev/null" | sed 's|/proc/||g' | sed 's|/comm||g'); do
echo "Terminating $process with PID $pid..."
kill -9 "$pid" 2>/dev/null || echo "Failed to terminate PID $pid"
done
done
kill_port_process 4006
kill_port_process 8090
kill_port_process 8030
echo "All processes terminated, ports freed."
}

# Trap to ensure cleanup on script exit
trap cleanup EXIT

# Start the server or application based on project
cargo run --release $1 &
sleep 1

if [ "$1" = "big" ]; then
source_port="4006"
nginx_port="8090"
elif [ "$1" = "medium" ]; then
source_port="4006"
nginx_port="8090"
elif [ "$1" = "small" ]; then
source_port="4001"
nginx_port="8091"
else
echo "Error: invalid argument $1"
exit 1
fi
echo "Setup Benchmark (payload=$1) (project=$2)"

source_port="4006"
nginx_port="8090"

echo "Running Benchmark (payload=$1) (project=$2)"

Expand All @@ -36,27 +60,27 @@ elif [ "$2" = "nginx_rest_api" ]; then
sleep 5
hey -n 200 -z 10s -m GET -H 'Accept: application/json' -H 'Content-Type: application/json' http://127.0.0.1:$nginx_port/$1-json
elif [ "$2" = "tailcall_default" ]; then
TC_LOG_LEVEL=error ./tailcall start ./1-basic.graphql &
TC_LOG_LEVEL=error tailcall start ./1-basic.graphql &
sleep 5
hey -n 200 -z 10s -m POST -H 'Accept: application/json' -H 'Content-Type: application/json' -D "bench-hey-$1.json" http://127.0.0.1:8030/graphql
elif [ "$2" = "tailcall_tweaks" ]; then
TC_LOG_LEVEL=error ./tailcall start ./2-http-tweaks.graphql &
TC_LOG_LEVEL=error tailcall start ./2-http-tweaks.graphql &
sleep 5
hey -n 200 -z 10s -m POST -H 'Accept: application/json' -H 'Content-Type: application/json' -D "bench-hey-$1.json" http://127.0.0.1:8030/graphql
elif [ "$2" = "tailcall_http_cache" ]; then
TC_LOG_LEVEL=error ./tailcall start ./3-http-cache.graphql &
TC_LOG_LEVEL=error tailcall start ./3-http-cache.graphql &
sleep 5
hey -n 200 -z 10s -m POST -H 'Accept: application/json' -H 'Content-Type: application/json' -D "bench-hey-$1.json" http://127.0.0.1:8030/graphql
elif [ "$2" = "tailcall_cache_dir" ]; then
TC_LOG_LEVEL=error ./tailcall start ./4-http-cache-directive.graphql &
TC_LOG_LEVEL=error tailcall start ./4-http-cache-directive.graphql &
sleep 5
hey -n 200 -z 10s -m POST -H 'Accept: application/json' -H 'Content-Type: application/json' -D "bench-hey-$1.json" http://127.0.0.1:8030/graphql
elif [ "$2" = "tailcall_dedupe_op" ]; then
TC_LOG_LEVEL=error ./tailcall start ./5-dedupe.graphql &
TC_LOG_LEVEL=error tailcall start ./5-dedupe.graphql &
sleep 5
hey -n 200 -z 10s -m POST -H 'Accept: application/json' -H 'Content-Type: application/json' -D "bench-hey-$1.json" http://127.0.0.1:8030/graphql
elif [ "$2" = "tailcall_full_conf" ]; then
TC_LOG_LEVEL=error ./tailcall start ./6-all.graphql &
TC_LOG_LEVEL=error tailcall start ./6-all.graphql &
sleep 5
hey -n 200 -z 10s -m POST -H 'Accept: application/json' -H 'Content-Type: application/json' -D "bench-hey-$1.json" http://127.0.0.1:8030/graphql
elif [ "$2" = "wundergraph_no_opt" ]; then
Expand Down Expand Up @@ -87,3 +111,4 @@ else
echo "Error: invalid argument $2"
exit 1
fi

Loading

0 comments on commit be7ff1d

Please sign in to comment.