Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into k6_migration
Browse files Browse the repository at this point in the history
  • Loading branch information
beelchester committed Jul 21, 2024
2 parents 706703b + 9e86dee commit de25bba
Show file tree
Hide file tree
Showing 19 changed files with 265 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,32 @@ Get started with the benchmarks:
| Query | Server | Requests/sec | Latency (ms) | Relative |
|-------:|--------:|--------------:|--------------:|---------:|
| 1 | `{ posts { id userId title user { id name email }}}` |
|| [Tailcall] | `30,004.80` | `3.32` | `111.96x` |
|| [async-graphql] | `1,862.55` | `53.71` | `6.95x` |
|| [Caliban] | `1,535.48` | `65.27` | `5.73x` |
|| [Hasura] | `1,474.01` | `67.57` | `5.50x` |
|| [GraphQL JIT] | `1,325.51` | `75.13` | `4.95x` |
|| [Gqlgen] | `763.01` | `130.02` | `2.85x` |
|| [Netflix DGS] | `362.91` | `160.04` | `1.35x` |
|| [Apollo GraphQL] | `268.00` | `367.08` | `1.00x` |
|| [Tailcall] | `29,665.80` | `3.36` | `425.07x` |
|| [async-graphql] | `1,851.17` | `54.68` | `26.52x` |
|| [Caliban] | `1,576.28` | `63.08` | `22.59x` |
|| [GraphQL JIT] | `1,365.61` | `72.93` | `19.57x` |
|| [Gqlgen] | `775.69` | `127.90` | `11.11x` |
|| [Netflix DGS] | `363.35` | `176.43` | `5.21x` |
|| [Apollo GraphQL] | `274.89` | `357.34` | `3.94x` |
|| [Hasura] | `69.79` | `547.07` | `1.00x` |
| 2 | `{ posts { title }}` |
|| [Tailcall] | `61,811.50` | `1.61` | `44.69x` |
|| [async-graphql] | `9,412.32` | `10.76` | `6.81x` |
|| [Caliban] | `9,057.38` | `11.39` | `6.55x` |
|| [Hasura] | `2,437.90` | `40.99` | `1.76x` |
|| [Gqlgen] | `2,176.64` | `47.66` | `1.57x` |
|| [Apollo GraphQL] | `1,750.92` | `57.02` | `1.27x` |
|| [Netflix DGS] | `1,598.51` | `69.51` | `1.16x` |
|| [GraphQL JIT] | `1,383.03` | `72.19` | `1.00x` |
|| [Tailcall] | `58,926.60` | `1.69` | `67.13x` |
|| [async-graphql] | `9,316.32` | `10.76` | `10.61x` |
|| [Caliban] | `9,125.46` | `11.31` | `10.40x` |
|| [Gqlgen] | `2,208.06` | `46.75` | `2.52x` |
|| [Apollo GraphQL] | `1,781.77` | `56.05` | `2.03x` |
|| [Netflix DGS] | `1,609.56` | `68.96` | `1.83x` |
|| [GraphQL JIT] | `1,400.50` | `71.31` | `1.60x` |
|| [Hasura] | `877.86` | `113.67` | `1.00x` |
| 3 | `{ greet }` |
|| [Caliban] | `68,200.20` | `1.07` | `26.86x` |
|| [Tailcall] | `63,728.50` | `1.58` | `25.10x` |
|| [async-graphql] | `51,025.70` | `1.98` | `20.09x` |
|| [Gqlgen] | `47,338.30` | `5.10` | `18.64x` |
|| [Netflix DGS] | `8,138.82` | `15.05` | `3.20x` |
|| [Apollo GraphQL] | `7,989.19` | `12.73` | `3.15x` |
|| [GraphQL JIT] | `5,136.79` | `19.44` | `2.02x` |
|| [Hasura] | `2,539.46` | `39.31` | `1.00x` |
|| [Caliban] | `68,097.90` | `1.10` | `25.87x` |
|| [Tailcall] | `60,001.70` | `1.67` | `22.79x` |
|| [Gqlgen] | `48,414.40` | `5.11` | `18.39x` |
|| [async-graphql] | `47,752.20` | `2.19` | `18.14x` |
|| [Netflix DGS] | `8,383.83` | `14.93` | `3.18x` |
|| [Apollo GraphQL] | `8,190.26` | `12.39` | `3.11x` |
|| [GraphQL JIT] | `5,175.24` | `19.29` | `1.97x` |
|| [Hasura] | `2,632.45` | `37.92` | `1.00x` |

<!-- PERFORMANCE_RESULTS_END -->

Expand Down
28 changes: 14 additions & 14 deletions graphql/async_graphql/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions graphql/caliban/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ 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.6",
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.30.6" % Provided,
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.30.7",
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.30.7" % Provided,
"org.apache.httpcomponents.client5" % "httpclient5" % "5.3.1",
"dev.zio" %% "zio" % "2.1.6"
)
Expand Down
63 changes: 61 additions & 2 deletions graphql/hasura/handler.js
Original file line number Diff line number Diff line change
@@ -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}`);
});
17 changes: 17 additions & 0 deletions graphql/hasura/metadata/actions.graphql
Original file line number Diff line number Diff line change
@@ -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!
}
6 changes: 5 additions & 1 deletion graphql/hasura/metadata/actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
15 changes: 1 addition & 14 deletions graphql/hasura/metadata/databases/databases.yaml
Original file line number Diff line number Diff line change
@@ -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"
[]

This file was deleted.

11 changes: 0 additions & 11 deletions graphql/hasura/metadata/databases/default/tables/public_users.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions graphql/hasura/metadata/databases/default/tables/tables.yaml

This file was deleted.

Loading

1 comment on commit de25bba

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query Server Requests/sec Latency (ms) Relative
1 { posts { id userId title user { id name email }}}
[Tailcall] -nan -nan -nanx
[Netflix DGS] -nan -nan -nanx
[Hasura] -nan -nan -nanx
[GraphQL JIT] -nan -nan -nanx
[Gqlgen] -nan -nan -nanx
[Caliban] -nan -nan -nanx
[async-graphql] -nan -nan -nanx
[Apollo GraphQL] -nan -nan -nanx
2 { posts { title }}
[Tailcall] -nan -nan -nanx
[Netflix DGS] -nan -nan -nanx
[Hasura] -nan -nan -nanx
[GraphQL JIT] -nan -nan -nanx
[Gqlgen] -nan -nan -nanx
[Caliban] -nan -nan -nanx
[async-graphql] -nan -nan -nanx
[Apollo GraphQL] -nan -nan -nanx
3 { greet }
[Tailcall] -nan -nan -nanx
[Netflix DGS] -nan -nan -nanx
[Hasura] -nan -nan -nanx
[GraphQL JIT] -nan -nan -nanx
[Gqlgen] -nan -nan -nanx
[Caliban] -nan -nan -nanx
[async-graphql] -nan -nan -nanx
[Apollo GraphQL] -nan -nan -nanx

Please sign in to comment.