graphql-hive / graphql-hive/graphql-modules

Degraded performance with Apollo Server and v1

Open
#1,724 11 comments 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.3k
Forks
113
Avg merge
3h 36m
Merged PRs (30d)
1

Description

**Describe the bug**

Apollo Server with GraphQL Modules `v1` appears to be twice as slow as it was with `v0`.

**To Reproduce**

I've created a [simple repo](https://github.com/dackland/gql-modules-performance-testing) with three basic servers to demonstrate the performance differences. A load testing script performs as many requests as possible within 10 seconds.

| Server | Median Request Duration | Request Count |
| :---------------: | :---------------------: | :-----------: |
| Apollo Standalone | 236ms | 42 |
| Apollo + GQL Modules v0 | 229ms | 43 |
| Apollo + GQL Modules v1 | 460ms | 22 |

Each server uses the same schema, resolver, and JSON dataset. See the repo for more details and instructions. The test uses a larger dataset (3MB), but we observed a similar 100% latency increase even with smaller payloads.

**Expected behavior**

Using Apollo Server with GraphQL Modules `v1` is similar or better performance to `v0`.

**Environment:**

- OS: macOS
- graphql-modules: `1.4.2`
- NodeJS: `16.3.0`

**Additional context**

Using `createApolloExecutor` (as implemented [here](https://github.com/Urigo/graphql-modules/blob/master/packages/graphql-modules/tests/third-parties.spec.ts#L214-L219)) instead of `createSchemaForApollo` seems to address the performance problem. However, using the custom executor broke field usage and resolver tracing in Apollo Studio.

I noticed [your benchmarks](https://github.com/Urigo/graphql-modules/blob/master/benchmark/basic.case.ts) for Apollo Server are all using `createApolloExecutor`, so it isn't capturing the slowdown that seems to happen when using `createSchemaForApollo`.

The [docs](https://www.graphql-modules.com/docs/get-started) recommend `createSchemaForApollo` for Apollo Server, but the [API Reference](https://www.graphql-modules.com/docs/api) calls both `createSchemaForApollo` and `createApolloExecutor` experimental.

Is there a recommended way of using `v1` with Apollo Server that is performant and works with Apollo Studio? Thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.