Skip to content

Commit 7ddd366

Browse files
enisdenjoardatan
andauthored
Hive Gateway (#442)
* add * unused config * use alpha * use radiness * no uws, curl or json-bigint-patch * JIT maybe? * JIT enabled this time * Bump to v22 * Docker * .. * Disable forking * Disable JIT * .. * Bump * Try sth * Hmm * Lets go * Go * Disable Forking * Bump * Try bun * Enable JIT * .. * Less diff * .. * Use stable --------- Co-authored-by: Arda TANRIKULU <[email protected]>
1 parent 04175e4 commit 7ddd366

File tree

7 files changed

+183
-23
lines changed

7 files changed

+183
-23
lines changed

.github/workflows/federation-v1.workflow.yaml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,24 @@ jobs:
2929
directory:
3030
- apollo-server
3131
- apollo-router
32+
- hive-gateway
3233
- cosmo
3334
- mercurius
3435
- wundergraph
35-
- mesh-supergraph
36-
- mesh-supergraph-bun
36+
# - mesh-supergraph
37+
# - mesh-supergraph-bun
3738
# - grafbase
3839
uses: ./.github/workflows/benchmark.template.yaml
3940
with:
4041
gateway: ${{ matrix.directory }}
41-
vu: ${{ github.event_name == 'pull_request' && 100 || 300 }}
42+
vu: 300
4243
time: ${{ github.event_name == 'pull_request' && '30s' || '600s' }}
4344
baseDir: federation-v1
4445
scenarioDir: constant-vus-over-time
4546
scenarioName: constant-vus-over-time
4647
runner: ${{ needs.decide-runner.outputs.runner }}
47-
cpuLimit: ${{ github.event_name == 'pull_request' && '1' || '2' }}
48-
memoryLimit: ${{ github.event_name == 'pull_request' && '2gb' || '4gb' }}
48+
cpuLimit: 2
49+
memoryLimit: 4gb
4950

5051
constant-vus-over-time-report:
5152
needs: constant-vus-over-time
@@ -66,25 +67,26 @@ jobs:
6667
directory:
6768
- apollo-server
6869
- apollo-router
70+
- hive-gateway
6971
- cosmo
7072
- mercurius
7173
- wundergraph
7274
# - mesh
7375
# - mesh-bun
74-
- mesh-supergraph
75-
- mesh-supergraph-bun
76+
# - mesh-supergraph
77+
# - mesh-supergraph-bun
7678
# - grafbase
7779
uses: ./.github/workflows/benchmark.template.yaml
7880
with:
7981
gateway: ${{ matrix.directory }}
80-
vu: ${{ github.event_name == 'pull_request' && 100 || 300 }}
82+
vu: 300
8183
time: ${{ github.event_name == 'pull_request' && '30s' || '600s' }}
8284
baseDir: federation-v1
8385
scenarioDir: constant-vus-over-time
8486
scenarioName: constant-vus-subgraphs-delay
8587
runner: ${{ needs.decide-runner.outputs.runner }}
86-
cpuLimit: ${{ github.event_name == 'pull_request' && '1' || '2' }}
87-
memoryLimit: ${{ github.event_name == 'pull_request' && '2gb' || '4gb' }}
88+
cpuLimit: 2
89+
memoryLimit: 4gb
8890
subgraphDelayRange: "40~150"
8991

9092
constant-vus-subgraphs-delay-report:
@@ -106,25 +108,26 @@ jobs:
106108
directory:
107109
- apollo-server
108110
- apollo-router
111+
- hive-gateway
109112
- cosmo
110113
- mercurius
111114
- wundergraph
112115
# - mesh
113116
# - mesh-bun
114-
- mesh-supergraph
115-
- mesh-supergraph-bun
117+
# - mesh-supergraph
118+
# - mesh-supergraph-bun
116119
# - grafbase
117120
uses: ./.github/workflows/benchmark.template.yaml
118121
with:
119122
gateway: ${{ matrix.directory }}
120-
vu: ${{ github.event_name == 'pull_request' && 100 || 500 }}
123+
vu: 500
121124
time: ${{ github.event_name == 'pull_request' && '30s' || '600s' }}
122125
baseDir: federation-v1
123126
scenarioDir: constant-vus-over-time
124127
scenarioName: constant-vus-subgraphs-delay-resources
125128
runner: ${{ needs.decide-runner.outputs.runner }}
126-
cpuLimit: ${{ github.event_name == 'pull_request' && '2' || '4' }}
127-
memoryLimit: ${{ github.event_name == 'pull_request' && '2gb' || '8gb' }}
129+
cpuLimit: 4
130+
memoryLimit: 8gb
128131
subgraphDelayRange: "40~150"
129132

130133
constant-vus-subgraphs-delay-resources-report:
@@ -146,25 +149,26 @@ jobs:
146149
directory:
147150
- apollo-server
148151
- apollo-router
152+
- hive-gateway
149153
- cosmo
150154
# - mercurius
151155
- wundergraph
152156
# - mesh
153157
# - mesh-bun
154-
- mesh-supergraph
155-
- mesh-supergraph-bun
158+
# - mesh-supergraph
159+
# - mesh-supergraph-bun
156160
# - grafbase
157161
uses: ./.github/workflows/benchmark.template.yaml
158162
with:
159163
gateway: ${{ matrix.directory }}
160-
vu: ${{ github.event_name == 'pull_request' && 500 || 2000 }}
164+
vu: 2000
161165
time: ${{ github.event_name == 'pull_request' && '60s' || '600s' }}
162166
baseDir: federation-v1
163167
scenarioDir: ramping-vus
164168
scenarioName: ramping-vus
165169
runner: ${{ needs.decide-runner.outputs.runner }}
166-
cpuLimit: ${{ github.event_name == 'pull_request' && '2' || '4' }}
167-
memoryLimit: ${{ github.event_name == 'pull_request' && '2gb' || '8gb' }}
170+
cpuLimit: 4
171+
memoryLimit: 8gb
168172

169173
ramping-vus-report:
170174
needs: ramping-vus
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
services:
2+
gateway:
3+
image: ghcr.io/ardatan/hive-gateway:1.3.0
4+
container_name: gateway
5+
networks:
6+
- test
7+
ports:
8+
- "0.0.0.0:4000:4000"
9+
environment:
10+
- NODE_ENV=production
11+
- JIT=1
12+
depends_on:
13+
accounts:
14+
condition: service_healthy
15+
inventory:
16+
condition: service_healthy
17+
products:
18+
condition: service_healthy
19+
reviews:
20+
condition: service_healthy
21+
volumes:
22+
- type: bind
23+
source: federation-v1/gateways/hive-gateway/supergraph.graphql
24+
target: /serve/supergraph.graphql
25+
healthcheck:
26+
test:
27+
[
28+
"CMD",
29+
"/usr/lib/apt/apt-helper",
30+
"download-file",
31+
"http://127.0.0.1:4000/readiness",
32+
"/tmp/health",
33+
]
34+
interval: 3s
35+
timeout: 5s
36+
retries: 10
37+
command: ["supergraph"]
38+
deploy:
39+
resources:
40+
limits:
41+
cpus: ${CPU_LIMIT:-1}
42+
memory: ${MEM_LIMIT:-1gb}
43+
networks:
44+
test:
45+
name: test
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
schema
2+
@link(url: "https://specs.apollo.dev/link/v1.0")
3+
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION)
4+
{
5+
query: Query
6+
}
7+
8+
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
9+
10+
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
11+
12+
directive @join__graph(name: String!, url: String!) on ENUM_VALUE
13+
14+
directive @join__implements(graph: join__Graph!, interface: String!) repeatable on OBJECT | INTERFACE
15+
16+
directive @join__type(graph: join__Graph!, key: join__FieldSet, extension: Boolean! = false, resolvable: Boolean! = true, isInterfaceObject: Boolean! = false) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR
17+
18+
directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION
19+
20+
directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA
21+
22+
scalar join__FieldSet
23+
24+
enum join__Graph {
25+
ACCOUNTS @join__graph(name: "accounts", url: "http://accounts:4001/graphql")
26+
INVENTORY @join__graph(name: "inventory", url: "http://inventory:4002/graphql")
27+
PRODUCTS @join__graph(name: "products", url: "http://products:4003/graphql")
28+
REVIEWS @join__graph(name: "reviews", url: "http://reviews:4004/graphql")
29+
}
30+
31+
scalar link__Import
32+
33+
enum link__Purpose {
34+
"""
35+
`SECURITY` features provide metadata necessary to securely resolve fields.
36+
"""
37+
SECURITY
38+
39+
"""
40+
`EXECUTION` features provide metadata necessary for operation execution.
41+
"""
42+
EXECUTION
43+
}
44+
45+
type Product
46+
@join__type(graph: INVENTORY, key: "upc")
47+
@join__type(graph: PRODUCTS, key: "upc")
48+
@join__type(graph: REVIEWS, key: "upc")
49+
{
50+
upc: String!
51+
weight: Int @join__field(graph: INVENTORY, external: true) @join__field(graph: PRODUCTS)
52+
price: Int @join__field(graph: INVENTORY, external: true) @join__field(graph: PRODUCTS)
53+
inStock: Boolean @join__field(graph: INVENTORY)
54+
shippingEstimate: Int @join__field(graph: INVENTORY, requires: "price weight")
55+
name: String @join__field(graph: PRODUCTS)
56+
reviews: [Review] @join__field(graph: REVIEWS)
57+
}
58+
59+
type Query
60+
@join__type(graph: ACCOUNTS)
61+
@join__type(graph: INVENTORY)
62+
@join__type(graph: PRODUCTS)
63+
@join__type(graph: REVIEWS)
64+
{
65+
me: User @join__field(graph: ACCOUNTS)
66+
user(id: ID!): User @join__field(graph: ACCOUNTS)
67+
users: [User] @join__field(graph: ACCOUNTS)
68+
topProducts(first: Int = 5): [Product] @join__field(graph: PRODUCTS)
69+
}
70+
71+
type Review
72+
@join__type(graph: REVIEWS, key: "id")
73+
{
74+
id: ID!
75+
body: String
76+
product: Product
77+
author: User @join__field(graph: REVIEWS, provides: "username")
78+
}
79+
80+
type User
81+
@join__type(graph: ACCOUNTS, key: "id")
82+
@join__type(graph: REVIEWS, key: "id")
83+
{
84+
id: ID!
85+
name: String @join__field(graph: ACCOUNTS)
86+
username: String @join__field(graph: ACCOUNTS) @join__field(graph: REVIEWS, external: true)
87+
birthday: Int @join__field(graph: ACCOUNTS)
88+
reviews: [Review] @join__field(graph: REVIEWS)
89+
}

federation-v1/scenarios/compose-supergraph.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ async function main() {
6565
} else {
6666
console.log("Got SDL:\n", supergraphSdl);
6767
writeFileSync(__dirname + '/../gateways/apollo-router/supergraph.graphql', supergraphSdl!);
68+
writeFileSync(__dirname + '/../gateways/hive-gateway/supergraph.graphql', supergraphSdl!);
6869
writeFileSync(__dirname + '/../gateways/grafbase/supergraph.graphql', supergraphSdl!);
6970
writeFileSync(__dirname + '/../gateways/apollo-server/supergraph.graphql', supergraphSdl!);
7071
writeFileSync(__dirname + '/../gateways/apollo-server-node16/supergraph.graphql', supergraphSdl!);

federation-v1/scenarios/constant-vus-over-time/benchmark.k6.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { makeGraphQLRequest, handleBenchmarkSummary } from '../k6.shared.js'
1+
import {
2+
makeGraphQLRequest,
3+
handleBenchmarkSummary,
4+
sendGraphQLRequest,
5+
} from "../k6.shared.js";
26

37
const vus = __ENV.BENCH_VUS ? parseInt(__ENV.BENCH_VUS) : 100;
48
const time = __ENV.BENCH_OVER_TIME || "30s";
@@ -8,6 +12,12 @@ export const options = {
812
duration: time,
913
};
1014

15+
export function setup() {
16+
for (let i = 0; i < 20; i++) {
17+
sendGraphQLRequest();
18+
}
19+
}
20+
1121
export default function() {
1222
makeGraphQLRequest()
1323
}

federation-v1/scenarios/k6.shared.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function handleBenchmarkSummary(data, additionalContext = {}) {
9999
return out;
100100
}
101101

102-
export function makeGraphQLRequest() {
102+
export function sendGraphQLRequest() {
103103
const res = http.post(
104104
__ENV.GATEWAY_ENDPOINT || "http://localhost:4000/graphql",
105105
graphqlRequest.payload,
@@ -110,6 +110,11 @@ export function makeGraphQLRequest() {
110110
console.log(`‼️ Failed to run HTTP request:`, res);
111111
}
112112

113+
return res;
114+
}
115+
116+
export function makeGraphQLRequest() {
117+
const res = sendGraphQLRequest();
113118
check(res, {
114119
"response code was 200": (res) => res.status == 200,
115120
"no graphql errors": (resp) => {

federation-v1/scenarios/ramping-vus/benchmark.k6.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { makeGraphQLRequest, handleBenchmarkSummary } from '../k6.shared.js'
1+
import { makeGraphQLRequest, handleBenchmarkSummary, sendGraphQLRequest } from '../k6.shared.js'
22

33
const vus = __ENV.BENCH_VUS ? parseInt(__ENV.BENCH_VUS) : 500;
44
const time = __ENV.BENCH_OVER_TIME || "30s";
@@ -20,6 +20,12 @@ export const options = {
2020
},
2121
};
2222

23+
export function setup() {
24+
for (let i = 0; i < 20; i++) {
25+
sendGraphQLRequest();
26+
}
27+
}
28+
2329
export default function() {
2430
makeGraphQLRequest()
2531
}

0 commit comments

Comments
 (0)