diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7ac7cb72..f158e823 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,7 +10,7 @@ "dockerfile": "Dockerfile", "context": ".." }, - "runArgs": ["-v", "/var/run/docker.sock:/var/run/docker.sock"], + "runArgs": ["-v", "/var/run/docker.sock:/var/run/docker.sock", "--network=host"], "forwardPorts": [8000, 3000], "postCreateCommand": "bash ./setup.sh" } diff --git a/.github/workflows/bench.yml b/.github/workflows/bench.yml index fa4bc97a..84b7b283 100644 --- a/.github/workflows/bench.yml +++ b/.github/workflows/bench.yml @@ -1,23 +1,33 @@ name: "Run benchmark" - on: pull_request_target: types: [assigned, opened, synchronize, reopened, edited] push: branches: - main - permissions: contents: write pull-requests: write issues: write - jobs: build: runs-on: benchmarking-runner if: github.event.head_commit.message != 'Update performance results in README.md' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + strategy: + matrix: + service: + [ + apollo_server, + caliban, + netflix_dgs, + gqlgen, + tailcall, + async_graphql, + hasura, + graphql_jit, + ] steps: - name: Checkout (GitHub) uses: actions/checkout@v4 @@ -25,14 +35,44 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }} - - name: Build devcontainer and run benchmarks + - name: Build devcontainer and run setup and benchmark uses: devcontainers/ci@v0.3 with: imageName: graphql-benchmarks push: never runCmd: | - bash ./setup.sh - bash ./run_benchmarks.sh + bash ./graphql/${{ matrix.service }}/setup.sh + bash run_benchmarks.sh ${{ matrix.service }} + + - name: List benchmark files + run: | + ls -la bench*.txt || echo "No matching files found" + + - name: Upload benchmark results + uses: actions/upload-artifact@v3 + with: + name: benchmark-results + path: bench*.txt + + analyze: + needs: build + runs-on: benchmarking-runner + steps: + - name: Checkout (GitHub) + uses: actions/checkout@v4 + + - name: Download all benchmark results + uses: actions/download-artifact@v3 + with: + name: benchmark-results + path: . + + - name: List downloaded artifacts + run: ls -la bench*.txt || echo "No matching files found" + + - name: Analyze results + run: | + bash run_analyze_script.sh - name: Print benchmark results run: cat ./results.md @@ -51,4 +91,4 @@ jobs: with: branch: main commit_author: Author - commit_message: "Update performance results in README.md" + commit_message: "[ci skip] update performance results in README.md" diff --git a/README.md b/README.md index 28933aed..1df90ff7 100644 --- a/README.md +++ b/README.md @@ -51,32 +51,32 @@ Get started with the benchmarks: | Query | Server | Requests/sec | Latency (ms) | Relative | |-------:|--------:|--------------:|--------------:|---------:| | 1 | `{ posts { id userId title user { id name email }}}` | -|| [Tailcall] | `29,865.00` | `3.34` | `112.98x` | -|| [async-graphql] | `1,824.45` | `54.68` | `6.90x` | -|| [Caliban] | `1,631.74` | `60.96` | `6.17x` | -|| [Hasura] | `1,513.32` | `65.92` | `5.72x` | -|| [GraphQL JIT] | `1,308.30` | `76.09` | `4.95x` | -|| [Gqlgen] | `771.42` | `128.66` | `2.92x` | -|| [Netflix DGS] | `360.56` | `174.79` | `1.36x` | -|| [Apollo GraphQL] | `264.34` | `370.65` | `1.00x` | +|| [Tailcall] | `27,894.20` | `3.57` | `116.40x` | +|| [async-graphql] | `1,925.61` | `52.56` | `8.04x` | +|| [Caliban] | `1,755.13` | `56.75` | `7.32x` | +|| [GraphQL JIT] | `1,260.61` | `79.00` | `5.26x` | +|| [Gqlgen] | `774.95` | `128.05` | `3.23x` | +|| [Netflix DGS] | `363.59` | `177.99` | `1.52x` | +|| [Apollo GraphQL] | `269.21` | `364.28` | `1.12x` | +|| [Hasura] | `239.63` | `411.81` | `1.00x` | | 2 | `{ posts { title }}` | -|| [Tailcall] | `61,611.40` | `1.61` | `45.11x` | -|| [Caliban] | `9,406.21` | `10.99` | `6.89x` | -|| [async-graphql] | `9,366.90` | `10.76` | `6.86x` | -|| [Hasura] | `2,450.62` | `40.79` | `1.79x` | -|| [Gqlgen] | `2,150.47` | `48.08` | `1.57x` | -|| [Apollo GraphQL] | `1,745.86` | `57.22` | `1.28x` | -|| [Netflix DGS] | `1,602.77` | `69.19` | `1.17x` | -|| [GraphQL JIT] | `1,365.94` | `73.10` | `1.00x` | +|| [Tailcall] | `57,871.20` | `1.72` | `78.98x` | +|| [Caliban] | `10,019.30` | `10.31` | `13.67x` | +|| [async-graphql] | `9,838.23` | `10.26` | `13.43x` | +|| [Gqlgen] | `2,181.29` | `47.51` | `2.98x` | +|| [Apollo GraphQL] | `1,743.58` | `57.29` | `2.38x` | +|| [Netflix DGS] | `1,587.87` | `71.10` | `2.17x` | +|| [GraphQL JIT] | `1,325.13` | `75.35` | `1.81x` | +|| [Hasura] | `732.74` | `137.01` | `1.00x` | | 3 | `{ greet }` | -|| [Caliban] | `69,058.50` | `1.06` | `27.21x` | -|| [Tailcall] | `63,879.10` | `1.58` | `25.17x` | -|| [async-graphql] | `50,746.10` | `2.10` | `20.00x` | -|| [Gqlgen] | `46,935.70` | `5.11` | `18.50x` | -|| [Netflix DGS] | `8,233.67` | `14.43` | `3.24x` | -|| [Apollo GraphQL] | `8,028.37` | `12.66` | `3.16x` | -|| [GraphQL JIT] | `5,097.42` | `19.59` | `2.01x` | -|| [Hasura] | `2,537.66` | `39.39` | `1.00x` | +|| [Caliban] | `67,294.20` | `1.11` | `26.65x` | +|| [Tailcall] | `58,715.80` | `1.71` | `23.25x` | +|| [Gqlgen] | `47,750.10` | `5.05` | `18.91x` | +|| [async-graphql] | `46,947.60` | `2.15` | `18.59x` | +|| [Netflix DGS] | `8,157.51` | `14.95` | `3.23x` | +|| [Apollo GraphQL] | `8,061.32` | `12.58` | `3.19x` | +|| [GraphQL JIT] | `5,041.54` | `19.80` | `2.00x` | +|| [Hasura] | `2,524.95` | `40.06` | `1.00x` | diff --git a/analyze.sh b/analyze.sh index 17bbbce1..a52e8471 100755 --- a/analyze.sh +++ b/analyze.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Install gnuplot +sudo apt-get update && sudo apt-get install -y gnuplot + function extractMetric() { local file="$1" local metric="$2" @@ -161,4 +164,4 @@ mv $latencyHistogramFile assets/ # Delete the result TXT files for file in "${resultFiles[@]}"; do rm "$file" -done +done \ No newline at end of file diff --git a/assets/latency_histogram1.png b/assets/latency_histogram1.png index 4f17234c..fbf6d32a 100644 Binary files a/assets/latency_histogram1.png and b/assets/latency_histogram1.png differ diff --git a/assets/latency_histogram2.png b/assets/latency_histogram2.png index ea759626..56625561 100644 Binary files a/assets/latency_histogram2.png and b/assets/latency_histogram2.png differ diff --git a/assets/latency_histogram3.png b/assets/latency_histogram3.png index 139d1a49..91f302fa 100644 Binary files a/assets/latency_histogram3.png and b/assets/latency_histogram3.png differ diff --git a/assets/req_sec_histogram1.png b/assets/req_sec_histogram1.png index 2f14f59c..065dbc66 100644 Binary files a/assets/req_sec_histogram1.png and b/assets/req_sec_histogram1.png differ diff --git a/assets/req_sec_histogram2.png b/assets/req_sec_histogram2.png index 8ae5c33e..e2b690ba 100644 Binary files a/assets/req_sec_histogram2.png and b/assets/req_sec_histogram2.png differ diff --git a/assets/req_sec_histogram3.png b/assets/req_sec_histogram3.png index d0ddf870..b9f03638 100644 Binary files a/assets/req_sec_histogram3.png and b/assets/req_sec_histogram3.png differ diff --git a/graphql/apollo_server/package-lock.json b/graphql/apollo_server/package-lock.json index 211e157c..e01a0499 100644 --- a/graphql/apollo_server/package-lock.json +++ b/graphql/apollo_server/package-lock.json @@ -50,9 +50,9 @@ } }, "node_modules/@apollo/server": { - "version": "4.10.4", - "resolved": "https://registry.npmjs.org/@apollo/server/-/server-4.10.4.tgz", - "integrity": "sha512-HS12CUa1wq8f5zKXOKJRwRdESFp4por9AINecpcsEUV9jsCP/NqPILgx0hCOOFJuKxmnaL7070xO6l5xmOq4Fw==", + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/@apollo/server/-/server-4.11.0.tgz", + "integrity": "sha512-SWDvbbs0wl2zYhKG6aGLxwTJ72xpqp0awb2lotNpfezd9VcAvzaUizzKQqocephin2uMoaA8MguoyBmgtPzNWw==", "dependencies": { "@apollo/cache-control-types": "^1.0.3", "@apollo/server-gateway-interface": "^1.1.1", @@ -65,7 +65,6 @@ "@apollo/utils.usagereporting": "^2.1.0", "@apollo/utils.withrequired": "^2.0.0", "@graphql-tools/schema": "^9.0.0", - "@josephg/resolvable": "^1.0.0", "@types/express": "^4.17.13", "@types/express-serve-static-core": "^4.17.30", "@types/node-fetch": "^2.6.1", @@ -288,11 +287,6 @@ "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" } }, - "node_modules/@josephg/resolvable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@josephg/resolvable/-/resolvable-1.0.1.tgz", - "integrity": "sha512-CtzORUwWTTOTqfVtHaKRJ0I1kNQd1bpn3sUh8I3nJDVY+5/M/Oe1DnEWzPQvqq/xPIIkzzzIP7mfCoAjFRvDhg==" - }, "node_modules/@pm2/agent": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@pm2/agent/-/agent-2.0.3.tgz", @@ -756,9 +750,9 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", - "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", @@ -2888,9 +2882,9 @@ } }, "@apollo/server": { - "version": "4.10.4", - "resolved": "https://registry.npmjs.org/@apollo/server/-/server-4.10.4.tgz", - "integrity": "sha512-HS12CUa1wq8f5zKXOKJRwRdESFp4por9AINecpcsEUV9jsCP/NqPILgx0hCOOFJuKxmnaL7070xO6l5xmOq4Fw==", + "version": "4.11.0", + "resolved": "https://registry.npmjs.org/@apollo/server/-/server-4.11.0.tgz", + "integrity": "sha512-SWDvbbs0wl2zYhKG6aGLxwTJ72xpqp0awb2lotNpfezd9VcAvzaUizzKQqocephin2uMoaA8MguoyBmgtPzNWw==", "requires": { "@apollo/cache-control-types": "^1.0.3", "@apollo/server-gateway-interface": "^1.1.1", @@ -2903,7 +2897,6 @@ "@apollo/utils.usagereporting": "^2.1.0", "@apollo/utils.withrequired": "^2.0.0", "@graphql-tools/schema": "^9.0.0", - "@josephg/resolvable": "^1.0.0", "@types/express": "^4.17.13", "@types/express-serve-static-core": "^4.17.30", "@types/node-fetch": "^2.6.1", @@ -3056,11 +3049,6 @@ "integrity": "sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ==", "requires": {} }, - "@josephg/resolvable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@josephg/resolvable/-/resolvable-1.0.1.tgz", - "integrity": "sha512-CtzORUwWTTOTqfVtHaKRJ0I1kNQd1bpn3sUh8I3nJDVY+5/M/Oe1DnEWzPQvqq/xPIIkzzzIP7mfCoAjFRvDhg==" - }, "@pm2/agent": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@pm2/agent/-/agent-2.0.3.tgz", @@ -3467,9 +3455,9 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "axios": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", - "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", "requires": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", diff --git a/graphql/apollo_server/setup.sh b/graphql/apollo_server/setup.sh new file mode 100644 index 00000000..de2d8366 --- /dev/null +++ b/graphql/apollo_server/setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# For apollo server: +cd graphql/apollo_server +npm i +cd ../../ \ No newline at end of file diff --git a/graphql/async_graphql/Cargo.lock b/graphql/async_graphql/Cargo.lock index c760cdfa..166a5e40 100644 --- a/graphql/async_graphql/Cargo.lock +++ b/graphql/async_graphql/Cargo.lock @@ -687,9 +687,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.4" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d3d0e0f38255e7fa3cf31335b3a56f05febd18025f4db5ef7a0cfb4f8da651f" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "http" @@ -949,13 +949,14 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.10" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" dependencies = [ + "hermit-abi", "libc", "wasi", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -1003,16 +1004,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "object" version = "0.32.2" @@ -1287,9 +1278,9 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "reqwest" -version = "0.12.5" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ "base64 0.22.1", "bytes", @@ -1325,7 +1316,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg", + "windows-registry", ] [[package]] @@ -1454,18 +1445,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", @@ -1474,11 +1465,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -1620,23 +1612,26 @@ name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] [[package]] name = "system-configuration" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +checksum = "658bc6ee10a9b4fcf576e9b0819d95ec16f4d2c02d39fd83ac1c8789785c4a42" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.2", "core-foundation", "system-configuration-sys", ] [[package]] name = "system-configuration-sys" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" dependencies = [ "core-foundation-sys", "libc", @@ -1691,27 +1686,26 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.39.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" dependencies = [ "backtrace", "bytes", "libc", "mio", - "num_cpus", "parking_lot", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -2026,6 +2020,36 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -2041,7 +2065,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", ] [[package]] @@ -2061,17 +2085,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -2082,9 +2107,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -2094,9 +2119,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -2106,9 +2131,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -2118,9 +2149,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -2130,9 +2161,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -2142,9 +2173,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -2154,9 +2185,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -2167,16 +2198,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "zerocopy" version = "0.7.34" diff --git a/graphql/async_graphql/setup.sh b/graphql/async_graphql/setup.sh new file mode 100644 index 00000000..51a64569 --- /dev/null +++ b/graphql/async_graphql/setup.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# For async-graphql +./graphql/async_graphql/build.sh \ No newline at end of file diff --git a/graphql/caliban/build.sbt b/graphql/caliban/build.sbt index 04e37d3a..022056e9 100644 --- a/graphql/caliban/build.sbt +++ b/graphql/caliban/build.sbt @@ -1,4 +1,4 @@ -ThisBuild / scalaVersion := "3.4.2" +ThisBuild / scalaVersion := "3.5.0" ThisBuild / version := "0.1.0-SNAPSHOT" ThisBuild / organization := "com.example" ThisBuild / organizationName := "example" @@ -10,10 +10,10 @@ lazy val root = (project in file(".")) run / javaOptions ++= Seq("-Xms4G", "-Xmx4G"), libraryDependencies ++= Seq( "com.github.ghostdogpr" %% "caliban-quick" % "2.8.1", - "com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.30.7", - "com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.30.7" % Provided, + "com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.30.9", + "com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.30.9" % Provided, "org.apache.httpcomponents.client5" % "httpclient5" % "5.3.1", - "dev.zio" %% "zio" % "2.1.6" + "dev.zio" %% "zio" % "2.1.9" ) ) diff --git a/graphql/caliban/setup.sh b/graphql/caliban/setup.sh new file mode 100644 index 00000000..2c78ee45 --- /dev/null +++ b/graphql/caliban/setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# For caliban +cd graphql/caliban +./sbt compile +cd ../../ \ No newline at end of file diff --git a/graphql/gqlgen/setup.sh b/graphql/gqlgen/setup.sh new file mode 100644 index 00000000..76a50491 --- /dev/null +++ b/graphql/gqlgen/setup.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# For gqlgen: +cd graphql/gqlgen +go build -o main main.go \ No newline at end of file diff --git a/graphql/graphql_jit/package-lock.json b/graphql/graphql_jit/package-lock.json index 895740be..fda731b0 100644 --- a/graphql/graphql_jit/package-lock.json +++ b/graphql/graphql_jit/package-lock.json @@ -26,11 +26,12 @@ } }, "node_modules/@graphql-tools/merge": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/@graphql-tools/merge/-/merge-9.0.4.tgz", - "integrity": "sha512-MivbDLUQ+4Q8G/Hp/9V72hbn810IJDEZQ57F01sHnlrrijyadibfVhaQfW/pNH+9T/l8ySZpaR/DpL5i+ruZ+g==", + "version": "9.0.6", + "resolved": "https://registry.npmjs.org/@graphql-tools/merge/-/merge-9.0.6.tgz", + "integrity": "sha512-TmkzFTFVieHnqu9mPTF6RxAQltaprpDQnM5HMTPSyMLXnJGMTvdWejV0yORKj7DW1YSi791/sUnKf8HytepBFQ==", + "license": "MIT", "dependencies": { - "@graphql-tools/utils": "^10.0.13", + "@graphql-tools/utils": "^10.5.4", "tslib": "^2.4.0" }, "engines": { @@ -41,12 +42,13 @@ } }, "node_modules/@graphql-tools/schema": { - "version": "10.0.4", - "resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-10.0.4.tgz", - "integrity": "sha512-HuIwqbKxPaJujox25Ra4qwz0uQzlpsaBOzO6CVfzB/MemZdd+Gib8AIvfhQArK0YIN40aDran/yi+E5Xf0mQww==", + "version": "10.0.6", + "resolved": "https://registry.npmjs.org/@graphql-tools/schema/-/schema-10.0.6.tgz", + "integrity": "sha512-EIJgPRGzpvDFEjVp+RF1zNNYIC36BYuIeZ514jFoJnI6IdxyVyIRDLx/ykgMdaa1pKQerpfdqDnsF4JnZoDHSQ==", + "license": "MIT", "dependencies": { - "@graphql-tools/merge": "^9.0.3", - "@graphql-tools/utils": "^10.2.1", + "@graphql-tools/merge": "^9.0.6", + "@graphql-tools/utils": "^10.5.4", "tslib": "^2.4.0", "value-or-promise": "^1.0.12" }, @@ -58,12 +60,13 @@ } }, "node_modules/@graphql-tools/utils": { - "version": "10.3.1", - "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-10.3.1.tgz", - "integrity": "sha512-Yhk1F0MNk4/ctgl3d0DKq++ZPovvZuh1ixWuUEVAxrFloYOAVwJ+rvGI1lsopArdJly8QXClT9lkvOxQszMw/w==", + "version": "10.5.4", + "resolved": "https://registry.npmjs.org/@graphql-tools/utils/-/utils-10.5.4.tgz", + "integrity": "sha512-XHnyCWSlg1ccsD8s0y6ugo5GZ5TpkTiFVNPSYms5G0s6Z/xTuSmiLBfeqgkfaCwLmLaQnRCmNDL2JRnqc2R5bQ==", + "license": "MIT", "dependencies": { "@graphql-typed-document-node/core": "^3.1.1", - "cross-inspect": "1.0.0", + "cross-inspect": "1.0.1", "dset": "^3.1.2", "tslib": "^2.4.0" }, @@ -136,9 +139,10 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", - "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", + "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", @@ -238,9 +242,10 @@ "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, "node_modules/cross-inspect": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/cross-inspect/-/cross-inspect-1.0.0.tgz", - "integrity": "sha512-4PFfn4b5ZN6FMNGSZlyb7wUhuN8wvj8t/VQHZdM4JsDcruGJ8L2kf9zao98QIrBPFCpdk27qst/AGTl7pL3ypQ==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/cross-inspect/-/cross-inspect-1.0.1.tgz", + "integrity": "sha512-Pcw1JTvZLSJH83iiGWt6fRcT+BjZlCDRVwYLbUcHzv/CRpB7r0MlSrGbIyQvVSNyGnbt7G4AXuyCiDR3POvZ1A==", + "license": "MIT", "dependencies": { "tslib": "^2.4.0" }, @@ -306,6 +311,7 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/dset/-/dset-3.1.3.tgz", "integrity": "sha512-20TuZZHCEZ2O71q9/+8BwKwZ0QtD9D8ObhrihJPr+vLLYlSuAU3/zL4cSlgbfeoGHTjCSJBa7NGcrF9/Bx/WJQ==", + "license": "MIT", "engines": { "node": ">=4" } diff --git a/graphql/graphql_jit/setup.sh b/graphql/graphql_jit/setup.sh new file mode 100644 index 00000000..43d78ff7 --- /dev/null +++ b/graphql/graphql_jit/setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# For graphql_jit +cd graphql/graphql_jit +npm install +cd ../../ \ No newline at end of file diff --git a/graphql/hasura/handler.js b/graphql/hasura/handler.js index 58be8888..aa941b35 100644 --- a/graphql/hasura/handler.js +++ b/graphql/hasura/handler.js @@ -1,13 +1,72 @@ -const express = require('express'); +const express = require("express"); +const axios = require("axios"); +const DataLoader = require("dataloader"); +const { Agent } = require("http"); + +// Create a new axios instance with connection pooling. +const httpAgent = new Agent({ keepAlive: true }); +const axiosInstance = axios.create({ + httpAgent, +}); + const app = express(); const port = 4000; app.use(express.json()); +async function batchUsers(usersIds) { + const requests = usersIds.map(async (id) => { + const response = await axiosInstance.get( + `http://jsonplaceholder.typicode.com/users/${id}`, + { + proxy: { + protocol: "http", + host: "127.0.0.1", + port: 3000, + }, + }, + ); + return response.data; + }); + return await Promise.all(requests); +} + +// Route to greet app.post('/greet', (req, res) => { res.json('Hello World!'); }); +// Route to fetch posts +app.post('/posts', async (req, res) => { + try { + const response = await axiosInstance.get('http://jsonplaceholder.typicode.com/posts', { + proxy: { + protocol: "http", + host: "127.0.0.1", + port: 3000, + }, + }); + let posts = response.data; + + if (req.body.request_query.includes("user")) { + const userLoader = new DataLoader(batchUsers, { + batchScheduleFn: (callback) => setTimeout(callback, 1), + }); + posts = await Promise.all(posts.map(async (post) => { + const user = await userLoader.load(post.userId); + return { + ...post, + user, + }; + })) + } + + res.json(posts); + } catch (error) { + res.json(error); + } +}); + app.listen(port, () => { - console.log(`Greet action handler running on port ${port}`); + console.log(`Handler server running on port ${port}`); }); diff --git a/graphql/hasura/metadata/actions.graphql b/graphql/hasura/metadata/actions.graphql index 6510caeb..c8f684f8 100644 --- a/graphql/hasura/metadata/actions.graphql +++ b/graphql/hasura/metadata/actions.graphql @@ -1,3 +1,20 @@ type Query { greet: String! + posts: [Post!]! +} + +type Post { + id: ID! + userId: ID! + title: String! + body: String! + user: User +} + +type User { + id: ID! + name: String! + email: String! + phone: String! + website: String! } diff --git a/graphql/hasura/metadata/actions.yaml b/graphql/hasura/metadata/actions.yaml index ca5ed195..94c36632 100644 --- a/graphql/hasura/metadata/actions.yaml +++ b/graphql/hasura/metadata/actions.yaml @@ -2,4 +2,8 @@ actions: - name: greet definition: kind: synchronous - handler: '{{HASURA_GRAPHQL_ACTION_HANDLER_URL}}' + handler: '{{HASURA_GRAPHQL_ACTION_HANDLER_URL}}/greet' + - name: posts + definition: + kind: synchronous + handler: '{{HASURA_GRAPHQL_ACTION_HANDLER_URL}}/posts' diff --git a/graphql/hasura/metadata/databases/databases.yaml b/graphql/hasura/metadata/databases/databases.yaml index f71e88b0..fe51488c 100644 --- a/graphql/hasura/metadata/databases/databases.yaml +++ b/graphql/hasura/metadata/databases/databases.yaml @@ -1,14 +1 @@ -- name: default - kind: postgres - configuration: - connection_info: - use_prepared_statements: true - database_url: - from_env: HASURA_GRAPHQL_DATABASE_URL - isolation_level: read-committed - pool_settings: - connection_lifetime: 600 - retries: 1 - idle_timeout: 180 - max_connections: 50 - tables: "!include default/tables/tables.yaml" +[] diff --git a/graphql/hasura/metadata/databases/default/tables/public_posts.yaml b/graphql/hasura/metadata/databases/default/tables/public_posts.yaml deleted file mode 100644 index 953c9f55..00000000 --- a/graphql/hasura/metadata/databases/default/tables/public_posts.yaml +++ /dev/null @@ -1,7 +0,0 @@ -table: - schema: public - name: posts -object_relationships: - - name: user - using: - foreign_key_constraint_on: user_id diff --git a/graphql/hasura/metadata/databases/default/tables/public_users.yaml b/graphql/hasura/metadata/databases/default/tables/public_users.yaml deleted file mode 100644 index b9a3daf0..00000000 --- a/graphql/hasura/metadata/databases/default/tables/public_users.yaml +++ /dev/null @@ -1,11 +0,0 @@ -table: - schema: public - name: users -array_relationships: - - name: posts - using: - foreign_key_constraint_on: - column: user_id - table: - schema: public - name: posts diff --git a/graphql/hasura/metadata/databases/default/tables/tables.yaml b/graphql/hasura/metadata/databases/default/tables/tables.yaml deleted file mode 100644 index ce7b30f9..00000000 --- a/graphql/hasura/metadata/databases/default/tables/tables.yaml +++ /dev/null @@ -1,2 +0,0 @@ -- "!include public_posts.yaml" -- "!include public_users.yaml" diff --git a/graphql/hasura/package-lock.json b/graphql/hasura/package-lock.json index e7ba1ff9..aa6b460c 100644 --- a/graphql/hasura/package-lock.json +++ b/graphql/hasura/package-lock.json @@ -26,12 +26,19 @@ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "axios": { - "version": "0.21.4", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", - "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "version": "1.7.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.4.tgz", + "integrity": "sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw==", "requires": { - "follow-redirects": "^1.14.0" + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" } }, "body-parser": { @@ -93,6 +100,14 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==" }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, "content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -116,6 +131,11 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, + "dataloader": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/dataloader/-/dataloader-2.2.2.tgz", + "integrity": "sha512-8YnDaaf7N3k/q5HnTJVuzSyLETjoZjVmHc4AeKAzOvKHEFQKcn64OKBfzHYtE9zGjctNM7V9I0MfnUVLpi7M5g==" + }, "debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -134,6 +154,11 @@ "gopd": "^1.0.1" } }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" + }, "depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -239,6 +264,16 @@ "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==" }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, "forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -312,8 +347,23 @@ "requires": { "axios": "^0.21.1", "chalk": "^2.4.2" + }, + "dependencies": { + "axios": { + "version": "0.21.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz", + "integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==", + "requires": { + "follow-redirects": "^1.14.0" + } + } } }, + "http": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz", + "integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g==" + }, "http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -419,6 +469,11 @@ "ipaddr.js": "1.9.1" } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "qs": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", diff --git a/graphql/hasura/package.json b/graphql/hasura/package.json index 0bcfb376..ff1b6508 100644 --- a/graphql/hasura/package.json +++ b/graphql/hasura/package.json @@ -2,8 +2,15 @@ "name": "hasura", "version": "1.0.0", "main": "index.js", + "scripts": { + "start": "PORT=4000 pm2 start handler.js -i max", + "stop": "pm2 stop handler" + }, "dependencies": { + "axios": "^1.7.2", + "dataloader": "^2.2.2", "express": "^4.19.2", - "hasura-cli": "^2.36.1" + "hasura-cli": "2.36.1", + "http": "^0.0.1-security" } } diff --git a/graphql/hasura/run.sh b/graphql/hasura/run.sh index 3e988514..b30f38f7 100755 --- a/graphql/hasura/run.sh +++ b/graphql/hasura/run.sh @@ -14,7 +14,7 @@ docker run -d --name postgres \ -p $DB_PORT:5432 \ postgres:13 -DB_HOST=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' postgres) +DB_HOST=127.0.0.1 # Wait for PostgreSQL to be ready echo "Waiting for PostgreSQL to be ready..." @@ -24,12 +24,12 @@ done echo "PostgreSQL is ready!" docker run -d --name handler \ - -p 4000:4000 \ + --network host \ --mount type=bind,source="/home/runner/work/graphql-benchmarks/graphql-benchmarks/graphql/hasura",target=/app \ - node:14 bash -c "cd /app && npm install && node handler.js" + node:14 bash -c "cd /app && npm install -g pm2 && npm install && npm start && pm2 logs" -HANDLER_URL=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' handler) -HANDLER_URL="http://$HANDLER_URL:4000/greet" +HANDLER_URL=127.0.0.1 +HANDLER_URL="http://$HANDLER_URL:4000" # Start Hasura GraphQL Engine container docker run -d --name graphql-engine \ @@ -39,72 +39,10 @@ docker run -d --name graphql-engine \ -e HASURA_GRAPHQL_ENABLED_LOG_TYPES=startup,http-log,webhook-log,websocket-log,query-log \ -e HASURA_GRAPHQL_EXPERIMENTAL_FEATURES=naming_convention \ -e HASURA_GRAPHQL_DEFAULT_NAMING_CONVENTION=graphql-default \ - -p 8080:8080 \ + --network host \ hasura/graphql-engine:v2.40.0 -HASURA_URL=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' graphql-engine) - -# Create and insert data into PostgreSQL -psql "postgresql://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME" <users.json -echo "$POSTS_DATA" >posts.json - -# Insert users into the database -jq -c '.[]' users.json | while read -r user; do - id=$(echo "$user" | jq '.id') - userId=$(echo "$user" | jq '.userId') - name=$(echo "$user" | jq -r '.name' | sed "s/'/''/g") - username=$(echo "$user" | jq -r '.username' | sed "s/'/''/g") - email=$(echo "$user" | jq -r '.email' | sed "s/'/''/g") - phone=$(echo "$user" | jq -r '.phone' | sed "s/'/''/g") - website=$(echo "$user" | jq -r '.website' | sed "s/'/''/g") - - psql "postgresql://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME" -c "INSERT INTO public.users (id, user_id, name, username, email, phone, website) VALUES ($id, $userId, '$name', '$username', '$email', '$phone', '$website') ON CONFLICT (id) DO NOTHING;" -done - -# Insert posts into the database -jq -c '.[]' posts.json | while read -r post; do - id=$(echo "$post" | jq '.id') - user_id=$(echo "$post" | jq '.userId') - title=$(echo "$post" | jq -r '.title' | sed "s/'/''/g") - body=$(echo "$post" | jq -r '.body' | sed "s/'/''/g") - - psql "postgresql://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME" -c "INSERT INTO public.posts (id, user_id, title, body) VALUES ($id, $user_id, '$title', '$body') ON CONFLICT (id) DO NOTHING;" -done - -# Clean up temporary files -rm users.json posts.json - # Apply Hasura metadata cd ./graphql/hasura -npx hasura metadata apply --endpoint http://$HASURA_URL:8080 +npx hasura metadata apply cd ../.. diff --git a/graphql/hasura/setup.sh b/graphql/hasura/setup.sh new file mode 100644 index 00000000..a862ce28 --- /dev/null +++ b/graphql/hasura/setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# For hasura +cd graphql/hasura +npm install +cd ../../ diff --git a/graphql/netflix_dgs/build.gradle b/graphql/netflix_dgs/build.gradle index 5b280fc6..4a55ce6e 100644 --- a/graphql/netflix_dgs/build.gradle +++ b/graphql/netflix_dgs/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java' - id 'org.springframework.boot' version '3.3.1' + id 'org.springframework.boot' version '3.3.3' id 'io.spring.dependency-management' version '1.1.6' } @@ -17,8 +17,8 @@ repositories { dependencyManagement { imports { - mavenBom "com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:9.0.4" - mavenBom "io.projectreactor:reactor-bom:2023.0.8" + mavenBom "com.netflix.graphql.dgs:graphql-dgs-platform-dependencies:9.1.0" + mavenBom "io.projectreactor:reactor-bom:2023.0.9" } } diff --git a/graphql/netflix_dgs/gradle/wrapper/gradle-wrapper.jar b/graphql/netflix_dgs/gradle/wrapper/gradle-wrapper.jar index 2c352119..a4b76b95 100644 Binary files a/graphql/netflix_dgs/gradle/wrapper/gradle-wrapper.jar and b/graphql/netflix_dgs/gradle/wrapper/gradle-wrapper.jar differ diff --git a/graphql/netflix_dgs/gradle/wrapper/gradle-wrapper.properties b/graphql/netflix_dgs/gradle/wrapper/gradle-wrapper.properties index 09523c0e..9355b415 100644 --- a/graphql/netflix_dgs/gradle/wrapper/gradle-wrapper.properties +++ b/graphql/netflix_dgs/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/graphql/netflix_dgs/setup.sh b/graphql/netflix_dgs/setup.sh new file mode 100644 index 00000000..f0795b9e --- /dev/null +++ b/graphql/netflix_dgs/setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# For netflix dgs +cd graphql/netflix_dgs +./gradlew build +cd ../../ \ No newline at end of file diff --git a/graphql/tailcall/package-lock.json b/graphql/tailcall/package-lock.json index 759da13f..a264c1c0 100644 --- a/graphql/tailcall/package-lock.json +++ b/graphql/tailcall/package-lock.json @@ -7,7 +7,7 @@ "name": "tailcall", "license": "ISC", "dependencies": { - "@tailcallhq/tailcall": "0.96.5" + "@tailcallhq/tailcall": "0.111.2" } }, "node_modules/@scarf/scarf": { @@ -17,9 +17,9 @@ "hasInstallScript": true }, "node_modules/@tailcallhq/core-darwin-arm64": { - "version": "0.96.5", - "resolved": "https://registry.npmjs.org/@tailcallhq/core-darwin-arm64/-/core-darwin-arm64-0.96.5.tgz", - "integrity": "sha512-uTk/guc2RXIdqGGh45UKrqETG1tvqPRjh2nQzgyZHwvXAxPuuDOoUhwCc0IrIFGcEXNLtbKEaoDlG02BRkxAgw==", + "version": "0.111.2", + "resolved": "https://registry.npmjs.org/@tailcallhq/core-darwin-arm64/-/core-darwin-arm64-0.111.2.tgz", + "integrity": "sha512-NAZUhbyKtH0ccnEZAP7O0bOb9559n1ZOBBnt4Y3kl+tqdgfjLzijwfgytw1QSB55USS7bmB+Odb5TdazR53HbA==", "cpu": [ "arm64" ], @@ -33,9 +33,9 @@ } }, "node_modules/@tailcallhq/core-darwin-x64": { - "version": "0.96.5", - "resolved": "https://registry.npmjs.org/@tailcallhq/core-darwin-x64/-/core-darwin-x64-0.96.5.tgz", - "integrity": "sha512-7aDjw/aHVMt6/sYtdOm90AhnmZK2Y333hjf/u2kRfu/UXh9vT6GA2nVXBpN04Xvpj9cAQ7JK/yavgmMJ/7fX2Q==", + "version": "0.111.2", + "resolved": "https://registry.npmjs.org/@tailcallhq/core-darwin-x64/-/core-darwin-x64-0.111.2.tgz", + "integrity": "sha512-nNpRA2J/V6Sax7cAktocnlJhjytoaraDQVhn9bGiu+CCZhlhTezyMlN8FEuGJggPJIHI6sD4YdsQ2ULyPg/nUA==", "cpu": [ "x64" ], @@ -49,9 +49,9 @@ } }, "node_modules/@tailcallhq/core-linux-arm64-gnu": { - "version": "0.96.5", - "resolved": "https://registry.npmjs.org/@tailcallhq/core-linux-arm64-gnu/-/core-linux-arm64-gnu-0.96.5.tgz", - "integrity": "sha512-E34NwBDGr5/CG6LjqgAOUWtkGlo2diDliIpu/pWaAjdsCr3coTSe7FDnjCVH3ZOqPXXWxeGDBzgC3qdaAxEUNw==", + "version": "0.111.2", + "resolved": "https://registry.npmjs.org/@tailcallhq/core-linux-arm64-gnu/-/core-linux-arm64-gnu-0.111.2.tgz", + "integrity": "sha512-W71UgsJ13Klk/mH4dhEj3pw5v3IrErGYfyP+3YCmRIvcM+Q99KmSwOeiF0N9blr3eHZFi1UDf6hIlAyLkDQ5Kw==", "cpu": [ "arm64" ], @@ -65,9 +65,9 @@ } }, "node_modules/@tailcallhq/core-linux-arm64-musl": { - "version": "0.96.5", - "resolved": "https://registry.npmjs.org/@tailcallhq/core-linux-arm64-musl/-/core-linux-arm64-musl-0.96.5.tgz", - "integrity": "sha512-dtdolbyPF3DuHHLQSNoQrKeeu/PkIb1+JAproXIo9/bfysZZFFbKbRu0ED6wRHugvwkN672gMIU/K8tamFHe5g==", + "version": "0.111.2", + "resolved": "https://registry.npmjs.org/@tailcallhq/core-linux-arm64-musl/-/core-linux-arm64-musl-0.111.2.tgz", + "integrity": "sha512-gRz3iW03K0ZuRx2NHa03vlGy0lzl3Eclo8JztC4/3/LvaMWQfUqRuKi3e/DQBs9xlzaNiAWz5sb5Kzw77JDccg==", "cpu": [ "arm64" ], @@ -81,9 +81,9 @@ } }, "node_modules/@tailcallhq/core-linux-ia32-gnu": { - "version": "0.96.5", - "resolved": "https://registry.npmjs.org/@tailcallhq/core-linux-ia32-gnu/-/core-linux-ia32-gnu-0.96.5.tgz", - "integrity": "sha512-sBPn16fn2Z88RinYt6yU8GpR5sd/IZynvAllNLTnNuSVnXd4eK/4K5p8L2lfznuOs/wbLZBKXNyHCUc2jmrzwA==", + "version": "0.111.2", + "resolved": "https://registry.npmjs.org/@tailcallhq/core-linux-ia32-gnu/-/core-linux-ia32-gnu-0.111.2.tgz", + "integrity": "sha512-gTWKKAoeWTO0mNSdw+A6QjIIVTeKlEqrk5wadp/EqSaFh714//706lSdp3dTsCoUAnFB4kWLWBDLjZQzZzMOvQ==", "cpu": [ "ia32" ], @@ -97,9 +97,9 @@ } }, "node_modules/@tailcallhq/core-linux-x64-gnu": { - "version": "0.96.5", - "resolved": "https://registry.npmjs.org/@tailcallhq/core-linux-x64-gnu/-/core-linux-x64-gnu-0.96.5.tgz", - "integrity": "sha512-D2CpfNvils72IPa/yW/yYXOmwHx6BaPipkpvZJJjxVIv84zAiOu9sJOMgZFT5S8p68dL/QPpkswanhJOaM6xJw==", + "version": "0.111.2", + "resolved": "https://registry.npmjs.org/@tailcallhq/core-linux-x64-gnu/-/core-linux-x64-gnu-0.111.2.tgz", + "integrity": "sha512-21aPZDHs04eR4ArfaoY7rEENwhfrQUSqOEeh3Ee9uSxmWFZNEJJw9mA0cMECWm0Fn7Lj5BZ6JhkLHeaW3XQNmw==", "cpu": [ "x64" ], @@ -113,9 +113,9 @@ } }, "node_modules/@tailcallhq/core-linux-x64-musl": { - "version": "0.96.5", - "resolved": "https://registry.npmjs.org/@tailcallhq/core-linux-x64-musl/-/core-linux-x64-musl-0.96.5.tgz", - "integrity": "sha512-ELEt/tUHD9fZrVFaWVbkyfks7Da7LpzVyRWXdWHTfCxS9ovSMXW5mjyPdItNGnpaOUO04Or5Z0Rq/APlVXOzrg==", + "version": "0.111.2", + "resolved": "https://registry.npmjs.org/@tailcallhq/core-linux-x64-musl/-/core-linux-x64-musl-0.111.2.tgz", + "integrity": "sha512-GzMyp5PSjdUMmHdshl5g5M5JuNJqS0wwZAiXWM47Zt9yOTVBR5U3ckdrXD1q/QjptY2iJRaZhrMe++73z+3iIA==", "cpu": [ "x64" ], @@ -129,9 +129,9 @@ } }, "node_modules/@tailcallhq/core-win32-arm64-msvc": { - "version": "0.96.5", - "resolved": "https://registry.npmjs.org/@tailcallhq/core-win32-arm64-msvc/-/core-win32-arm64-msvc-0.96.5.tgz", - "integrity": "sha512-pCsbY3HQ1vlr1NX/iQSiGgA+kNdE5ojOFbb5k5P0itX7uY8/me19L1mZ6PaocIgKdrLMa86IaEWXb4Pg+i1jUg==", + "version": "0.111.2", + "resolved": "https://registry.npmjs.org/@tailcallhq/core-win32-arm64-msvc/-/core-win32-arm64-msvc-0.111.2.tgz", + "integrity": "sha512-ZQ10uroAd/IQN//zXED/vRouc+UQfHt3RI8KBla0hJytS9+GG7ndYU4IV/AzyWbgF4hdy5NsJxfc1zLaFsOrdg==", "cpu": [ "arm64" ], @@ -145,9 +145,9 @@ } }, "node_modules/@tailcallhq/core-win32-ia32-msvc": { - "version": "0.96.5", - "resolved": "https://registry.npmjs.org/@tailcallhq/core-win32-ia32-msvc/-/core-win32-ia32-msvc-0.96.5.tgz", - "integrity": "sha512-HFtZ7EVOec4RWd7+fkyX4YRCBMzbumltZgw42p6MwN9bAzhJdn/Yv1mK2L4fHimzBsqBhH9fSv4uUWQ2QObumw==", + "version": "0.111.2", + "resolved": "https://registry.npmjs.org/@tailcallhq/core-win32-ia32-msvc/-/core-win32-ia32-msvc-0.111.2.tgz", + "integrity": "sha512-vFoiJCRDVAIg+AGwaYoOD3o1mxazpsg+sBwCer2+y5JFLnP1n0czhx7aD7acOFF2DWDmb/qTeNncgQjsWIM46g==", "cpu": [ "ia32" ], @@ -161,9 +161,9 @@ } }, "node_modules/@tailcallhq/core-win32-x64-msvc": { - "version": "0.96.5", - "resolved": "https://registry.npmjs.org/@tailcallhq/core-win32-x64-msvc/-/core-win32-x64-msvc-0.96.5.tgz", - "integrity": "sha512-SAr6Z/QHSx3XxqvafdhLKMN1tDRqbHHi2BGLlJKB/ZBboCWz19kOXQSVVZPnFxa0faPo/v95nkXV29FlfTc9iw==", + "version": "0.111.2", + "resolved": "https://registry.npmjs.org/@tailcallhq/core-win32-x64-msvc/-/core-win32-x64-msvc-0.111.2.tgz", + "integrity": "sha512-b/MuQEJXnuvdrG+GjA0YZK9ZSjYSaCWctAiSVWJ2HUJJr8r/njWu5L444bStfS5nI/lIsQsmZc2d2LDveS084w==", "cpu": [ "x64" ], @@ -177,9 +177,9 @@ } }, "node_modules/@tailcallhq/tailcall": { - "version": "0.96.5", - "resolved": "https://registry.npmjs.org/@tailcallhq/tailcall/-/tailcall-0.96.5.tgz", - "integrity": "sha512-rNj2R8iEajxy1qoAUj4eMBVBGxr1Sunqvblv5lA+pavXggEtKlU2NfL22y8tFN5N/zpkmoSCehUB28aFyw37Qw==", + "version": "0.111.2", + "resolved": "https://registry.npmjs.org/@tailcallhq/tailcall/-/tailcall-0.111.2.tgz", + "integrity": "sha512-ilPm7/jek82i/ZAJvufMHuBW6cRGG+G7rBuFWF9BmPx8zZTDomKKiHNNLPUjPDlNB6Hw/N0qeyWR5tp2YoAEWw==", "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -187,16 +187,16 @@ "detect-libc": "^2.0.2" }, "optionalDependencies": { - "@tailcallhq/core-darwin-arm64": "v0.96.5", - "@tailcallhq/core-darwin-x64": "v0.96.5", - "@tailcallhq/core-linux-arm64-gnu": "v0.96.5", - "@tailcallhq/core-linux-arm64-musl": "v0.96.5", - "@tailcallhq/core-linux-ia32-gnu": "v0.96.5", - "@tailcallhq/core-linux-x64-gnu": "v0.96.5", - "@tailcallhq/core-linux-x64-musl": "v0.96.5", - "@tailcallhq/core-win32-arm64-msvc": "v0.96.5", - "@tailcallhq/core-win32-ia32-msvc": "v0.96.5", - "@tailcallhq/core-win32-x64-msvc": "v0.96.5" + "@tailcallhq/core-darwin-arm64": "v0.111.2", + "@tailcallhq/core-darwin-x64": "v0.111.2", + "@tailcallhq/core-linux-arm64-gnu": "v0.111.2", + "@tailcallhq/core-linux-arm64-musl": "v0.111.2", + "@tailcallhq/core-linux-ia32-gnu": "v0.111.2", + "@tailcallhq/core-linux-x64-gnu": "v0.111.2", + "@tailcallhq/core-linux-x64-musl": "v0.111.2", + "@tailcallhq/core-win32-arm64-msvc": "v0.111.2", + "@tailcallhq/core-win32-ia32-msvc": "v0.111.2", + "@tailcallhq/core-win32-x64-msvc": "v0.111.2" } }, "node_modules/detect-libc": { diff --git a/graphql/tailcall/package.json b/graphql/tailcall/package.json index 3bc9784a..444213d7 100644 --- a/graphql/tailcall/package.json +++ b/graphql/tailcall/package.json @@ -8,6 +8,6 @@ "author": "", "license": "ISC", "dependencies": { - "@tailcallhq/tailcall": "0.96.5" + "@tailcallhq/tailcall": "0.111.2" } } diff --git a/graphql/tailcall/setup.sh b/graphql/tailcall/setup.sh new file mode 100644 index 00000000..ed9c81cf --- /dev/null +++ b/graphql/tailcall/setup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# For tailcall: +cd graphql/tailcall +npm install +cd ../../ \ No newline at end of file diff --git a/results.md b/results.md index c7f343c1..72cbcaed 100644 --- a/results.md +++ b/results.md @@ -3,31 +3,31 @@ | Query | Server | Requests/sec | Latency (ms) | Relative | |-------:|--------:|--------------:|--------------:|---------:| | 1 | `{ posts { id userId title user { id name email }}}` | -|| [Tailcall] | `29,865.00` | `3.34` | `112.98x` | -|| [async-graphql] | `1,824.45` | `54.68` | `6.90x` | -|| [Caliban] | `1,631.74` | `60.96` | `6.17x` | -|| [Hasura] | `1,513.32` | `65.92` | `5.72x` | -|| [GraphQL JIT] | `1,308.30` | `76.09` | `4.95x` | -|| [Gqlgen] | `771.42` | `128.66` | `2.92x` | -|| [Netflix DGS] | `360.56` | `174.79` | `1.36x` | -|| [Apollo GraphQL] | `264.34` | `370.65` | `1.00x` | +|| [Tailcall] | `27,894.20` | `3.57` | `116.40x` | +|| [async-graphql] | `1,925.61` | `52.56` | `8.04x` | +|| [Caliban] | `1,755.13` | `56.75` | `7.32x` | +|| [GraphQL JIT] | `1,260.61` | `79.00` | `5.26x` | +|| [Gqlgen] | `774.95` | `128.05` | `3.23x` | +|| [Netflix DGS] | `363.59` | `177.99` | `1.52x` | +|| [Apollo GraphQL] | `269.21` | `364.28` | `1.12x` | +|| [Hasura] | `239.63` | `411.81` | `1.00x` | | 2 | `{ posts { title }}` | -|| [Tailcall] | `61,611.40` | `1.61` | `45.11x` | -|| [Caliban] | `9,406.21` | `10.99` | `6.89x` | -|| [async-graphql] | `9,366.90` | `10.76` | `6.86x` | -|| [Hasura] | `2,450.62` | `40.79` | `1.79x` | -|| [Gqlgen] | `2,150.47` | `48.08` | `1.57x` | -|| [Apollo GraphQL] | `1,745.86` | `57.22` | `1.28x` | -|| [Netflix DGS] | `1,602.77` | `69.19` | `1.17x` | -|| [GraphQL JIT] | `1,365.94` | `73.10` | `1.00x` | +|| [Tailcall] | `57,871.20` | `1.72` | `78.98x` | +|| [Caliban] | `10,019.30` | `10.31` | `13.67x` | +|| [async-graphql] | `9,838.23` | `10.26` | `13.43x` | +|| [Gqlgen] | `2,181.29` | `47.51` | `2.98x` | +|| [Apollo GraphQL] | `1,743.58` | `57.29` | `2.38x` | +|| [Netflix DGS] | `1,587.87` | `71.10` | `2.17x` | +|| [GraphQL JIT] | `1,325.13` | `75.35` | `1.81x` | +|| [Hasura] | `732.74` | `137.01` | `1.00x` | | 3 | `{ greet }` | -|| [Caliban] | `69,058.50` | `1.06` | `27.21x` | -|| [Tailcall] | `63,879.10` | `1.58` | `25.17x` | -|| [async-graphql] | `50,746.10` | `2.10` | `20.00x` | -|| [Gqlgen] | `46,935.70` | `5.11` | `18.50x` | -|| [Netflix DGS] | `8,233.67` | `14.43` | `3.24x` | -|| [Apollo GraphQL] | `8,028.37` | `12.66` | `3.16x` | -|| [GraphQL JIT] | `5,097.42` | `19.59` | `2.01x` | -|| [Hasura] | `2,537.66` | `39.39` | `1.00x` | +|| [Caliban] | `67,294.20` | `1.11` | `26.65x` | +|| [Tailcall] | `58,715.80` | `1.71` | `23.25x` | +|| [Gqlgen] | `47,750.10` | `5.05` | `18.91x` | +|| [async-graphql] | `46,947.60` | `2.15` | `18.59x` | +|| [Netflix DGS] | `8,157.51` | `14.95` | `3.23x` | +|| [Apollo GraphQL] | `8,061.32` | `12.58` | `3.19x` | +|| [GraphQL JIT] | `5,041.54` | `19.80` | `2.00x` | +|| [Hasura] | `2,524.95` | `40.06` | `1.00x` | diff --git a/run_analyze_script.sh b/run_analyze_script.sh new file mode 100755 index 00000000..84f7206a --- /dev/null +++ b/run_analyze_script.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Update and install gnuplot +sudo apt-get update && sudo apt-get install -y gnuplot + +# Remove existing results file +rm -f results.md + +services=("apollo" "caliban" "netflixdgs" "gqlgen" "tailcall" "async_graphql" "hasura" "graphql_jit") + +# Loop through each benchmark (1, 2, 3) +for bench in 1 2 3; do + echo "Processing files for bench${bench}:" + + # Construct the command for each benchmark + cmd="bash analyze.sh" + + # Loop through each service + for service in "${services[@]}"; do + # Convert service name to match file naming convention + case $service in + "apollo") file_service="apollo_server" ;; + "netflixdgs") file_service="netflix_dgs" ;; + *) file_service=$service ;; + esac + + # Add files for current service to the command + for run in 1 2 3; do + cmd+=" bench${bench}_result${run}_graphql_${file_service}_run.sh.txt" + done + done + + # Execute the command + echo "Executing: $cmd" + eval $cmd +done \ No newline at end of file diff --git a/run_benchmarks.sh b/run_benchmarks.sh index 263e6f69..9c1b1aa8 100755 --- a/run_benchmarks.sh +++ b/run_benchmarks.sh @@ -12,6 +12,7 @@ function killServerOnPort() { echo "No process found running on port $port" fi } + bench1Results=() bench2Results=() bench3Results=() @@ -34,7 +35,7 @@ function runBenchmark() { local graphqlEndpoint="http://localhost:8000/graphql" if [[ "$serviceScript" == *"hasura"* ]]; then - graphqlEndpoint=http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' graphql-engine):8080/v1/graphql + graphqlEndpoint=http://127.0.0.1:8080/v1/graphql fi for bench in "${benchmarks[@]}"; do @@ -72,17 +73,29 @@ function runBenchmark() { rm "results.md" -for service in "apollo_server" "caliban" "netflix_dgs" "gqlgen" "tailcall" "async_graphql" "hasura" "graphql_jit"; do - runBenchmark "graphql/${service}/run.sh" - if [ "$service" == "apollo_server" ]; then +# Main script +if [ $# -eq 0 ]; then + echo "Usage: $0 " + echo "Available services: apollo_server, caliban, netflix_dgs, gqlgen, tailcall, async_graphql, hasura, graphql_jit" + exit 1 +fi + +service="$1" +valid_services=("apollo_server" "caliban" "netflix_dgs" "gqlgen" "tailcall" "async_graphql" "hasura" "graphql_jit") + +if [[ ! " ${valid_services[@]} " =~ " ${service} " ]]; then + echo "Invalid service name. Available services: ${valid_services[*]}" + exit 1 +fi + + + +runBenchmark "graphql/${service}/run.sh" + +if [ "$service" == "apollo_server" ]; then cd graphql/apollo_server/ npm stop cd ../../ - elif [ "$service" == "hasura" ]; then +elif [ "$service" == "hasura" ]; then bash "graphql/hasura/kill.sh" - fi -done - -bash analyze.sh "${bench1Results[@]}" -bash analyze.sh "${bench2Results[@]}" -bash analyze.sh "${bench3Results[@]}" +fi \ No newline at end of file