Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Commit de25bba

Browse files
committed
Merge remote-tracking branch 'upstream/main' into k6_migration
2 parents 706703b + 9e86dee commit de25bba

File tree

19 files changed

+265
-222
lines changed

19 files changed

+265
-222
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dockerfile": "Dockerfile",
1111
"context": ".."
1212
},
13-
"runArgs": ["-v", "/var/run/docker.sock:/var/run/docker.sock"],
13+
"runArgs": ["-v", "/var/run/docker.sock:/var/run/docker.sock", "--network=host"],
1414
"forwardPorts": [8000, 3000],
1515
"postCreateCommand": "bash ./setup.sh"
1616
}

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,32 @@ Get started with the benchmarks:
5858
| Query | Server | Requests/sec | Latency (ms) | Relative |
5959
|-------:|--------:|--------------:|--------------:|---------:|
6060
| 1 | `{ posts { id userId title user { id name email }}}` |
61-
|| [Tailcall] | `30,004.80` | `3.32` | `111.96x` |
62-
|| [async-graphql] | `1,862.55` | `53.71` | `6.95x` |
63-
|| [Caliban] | `1,535.48` | `65.27` | `5.73x` |
64-
|| [Hasura] | `1,474.01` | `67.57` | `5.50x` |
65-
|| [GraphQL JIT] | `1,325.51` | `75.13` | `4.95x` |
66-
|| [Gqlgen] | `763.01` | `130.02` | `2.85x` |
67-
|| [Netflix DGS] | `362.91` | `160.04` | `1.35x` |
68-
|| [Apollo GraphQL] | `268.00` | `367.08` | `1.00x` |
61+
|| [Tailcall] | `29,665.80` | `3.36` | `425.07x` |
62+
|| [async-graphql] | `1,851.17` | `54.68` | `26.52x` |
63+
|| [Caliban] | `1,576.28` | `63.08` | `22.59x` |
64+
|| [GraphQL JIT] | `1,365.61` | `72.93` | `19.57x` |
65+
|| [Gqlgen] | `775.69` | `127.90` | `11.11x` |
66+
|| [Netflix DGS] | `363.35` | `176.43` | `5.21x` |
67+
|| [Apollo GraphQL] | `274.89` | `357.34` | `3.94x` |
68+
|| [Hasura] | `69.79` | `547.07` | `1.00x` |
6969
| 2 | `{ posts { title }}` |
70-
|| [Tailcall] | `61,811.50` | `1.61` | `44.69x` |
71-
|| [async-graphql] | `9,412.32` | `10.76` | `6.81x` |
72-
|| [Caliban] | `9,057.38` | `11.39` | `6.55x` |
73-
|| [Hasura] | `2,437.90` | `40.99` | `1.76x` |
74-
|| [Gqlgen] | `2,176.64` | `47.66` | `1.57x` |
75-
|| [Apollo GraphQL] | `1,750.92` | `57.02` | `1.27x` |
76-
|| [Netflix DGS] | `1,598.51` | `69.51` | `1.16x` |
77-
|| [GraphQL JIT] | `1,383.03` | `72.19` | `1.00x` |
70+
|| [Tailcall] | `58,926.60` | `1.69` | `67.13x` |
71+
|| [async-graphql] | `9,316.32` | `10.76` | `10.61x` |
72+
|| [Caliban] | `9,125.46` | `11.31` | `10.40x` |
73+
|| [Gqlgen] | `2,208.06` | `46.75` | `2.52x` |
74+
|| [Apollo GraphQL] | `1,781.77` | `56.05` | `2.03x` |
75+
|| [Netflix DGS] | `1,609.56` | `68.96` | `1.83x` |
76+
|| [GraphQL JIT] | `1,400.50` | `71.31` | `1.60x` |
77+
|| [Hasura] | `877.86` | `113.67` | `1.00x` |
7878
| 3 | `{ greet }` |
79-
|| [Caliban] | `68,200.20` | `1.07` | `26.86x` |
80-
|| [Tailcall] | `63,728.50` | `1.58` | `25.10x` |
81-
|| [async-graphql] | `51,025.70` | `1.98` | `20.09x` |
82-
|| [Gqlgen] | `47,338.30` | `5.10` | `18.64x` |
83-
|| [Netflix DGS] | `8,138.82` | `15.05` | `3.20x` |
84-
|| [Apollo GraphQL] | `7,989.19` | `12.73` | `3.15x` |
85-
|| [GraphQL JIT] | `5,136.79` | `19.44` | `2.02x` |
86-
|| [Hasura] | `2,539.46` | `39.31` | `1.00x` |
79+
|| [Caliban] | `68,097.90` | `1.10` | `25.87x` |
80+
|| [Tailcall] | `60,001.70` | `1.67` | `22.79x` |
81+
|| [Gqlgen] | `48,414.40` | `5.11` | `18.39x` |
82+
|| [async-graphql] | `47,752.20` | `2.19` | `18.14x` |
83+
|| [Netflix DGS] | `8,383.83` | `14.93` | `3.18x` |
84+
|| [Apollo GraphQL] | `8,190.26` | `12.39` | `3.11x` |
85+
|| [GraphQL JIT] | `5,175.24` | `19.29` | `1.97x` |
86+
|| [Hasura] | `2,632.45` | `37.92` | `1.00x` |
8787

8888
<!-- PERFORMANCE_RESULTS_END -->
8989

graphql/async_graphql/Cargo.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

graphql/caliban/build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ lazy val root = (project in file("."))
1010
run / javaOptions ++= Seq("-Xms4G", "-Xmx4G"),
1111
libraryDependencies ++= Seq(
1212
"com.github.ghostdogpr" %% "caliban-quick" % "2.8.1",
13-
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.30.6",
14-
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.30.6" % Provided,
13+
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-core" % "2.30.7",
14+
"com.github.plokhotnyuk.jsoniter-scala" %% "jsoniter-scala-macros" % "2.30.7" % Provided,
1515
"org.apache.httpcomponents.client5" % "httpclient5" % "5.3.1",
1616
"dev.zio" %% "zio" % "2.1.6"
1717
)

graphql/hasura/handler.js

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,72 @@
1-
const express = require('express');
1+
const express = require("express");
2+
const axios = require("axios");
3+
const DataLoader = require("dataloader");
4+
const { Agent } = require("http");
5+
6+
// Create a new axios instance with connection pooling.
7+
const httpAgent = new Agent({ keepAlive: true });
8+
const axiosInstance = axios.create({
9+
httpAgent,
10+
});
11+
212
const app = express();
313
const port = 4000;
414

515
app.use(express.json());
616

17+
async function batchUsers(usersIds) {
18+
const requests = usersIds.map(async (id) => {
19+
const response = await axiosInstance.get(
20+
`http://jsonplaceholder.typicode.com/users/${id}`,
21+
{
22+
proxy: {
23+
protocol: "http",
24+
host: "127.0.0.1",
25+
port: 3000,
26+
},
27+
},
28+
);
29+
return response.data;
30+
});
31+
return await Promise.all(requests);
32+
}
33+
34+
// Route to greet
735
app.post('/greet', (req, res) => {
836
res.json('Hello World!');
937
});
1038

39+
// Route to fetch posts
40+
app.post('/posts', async (req, res) => {
41+
try {
42+
const response = await axiosInstance.get('http://jsonplaceholder.typicode.com/posts', {
43+
proxy: {
44+
protocol: "http",
45+
host: "127.0.0.1",
46+
port: 3000,
47+
},
48+
});
49+
let posts = response.data;
50+
51+
if (req.body.request_query.includes("user")) {
52+
const userLoader = new DataLoader(batchUsers, {
53+
batchScheduleFn: (callback) => setTimeout(callback, 1),
54+
});
55+
posts = await Promise.all(posts.map(async (post) => {
56+
const user = await userLoader.load(post.userId);
57+
return {
58+
...post,
59+
user,
60+
};
61+
}))
62+
}
63+
64+
res.json(posts);
65+
} catch (error) {
66+
res.json(error);
67+
}
68+
});
69+
1170
app.listen(port, () => {
12-
console.log(`Greet action handler running on port ${port}`);
71+
console.log(`Handler server running on port ${port}`);
1372
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
type Query {
22
greet: String!
3+
posts: [Post!]!
4+
}
5+
6+
type Post {
7+
id: ID!
8+
userId: ID!
9+
title: String!
10+
body: String!
11+
user: User
12+
}
13+
14+
type User {
15+
id: ID!
16+
name: String!
17+
email: String!
18+
phone: String!
19+
website: String!
320
}

graphql/hasura/metadata/actions.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ actions:
22
- name: greet
33
definition:
44
kind: synchronous
5-
handler: '{{HASURA_GRAPHQL_ACTION_HANDLER_URL}}'
5+
handler: '{{HASURA_GRAPHQL_ACTION_HANDLER_URL}}/greet'
6+
- name: posts
7+
definition:
8+
kind: synchronous
9+
handler: '{{HASURA_GRAPHQL_ACTION_HANDLER_URL}}/posts'
Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1 @@
1-
- name: default
2-
kind: postgres
3-
configuration:
4-
connection_info:
5-
use_prepared_statements: true
6-
database_url:
7-
from_env: HASURA_GRAPHQL_DATABASE_URL
8-
isolation_level: read-committed
9-
pool_settings:
10-
connection_lifetime: 600
11-
retries: 1
12-
idle_timeout: 180
13-
max_connections: 50
14-
tables: "!include default/tables/tables.yaml"
1+
[]

graphql/hasura/metadata/databases/default/tables/public_posts.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

graphql/hasura/metadata/databases/default/tables/public_users.yaml

Lines changed: 0 additions & 11 deletions
This file was deleted.

graphql/hasura/metadata/databases/default/tables/tables.yaml

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)