Performance issues upgrading from v3 to v4

I recently upgraded Apollo Server from v3 to v4 and noticed significant performance issues

The performance issues were most apparent when running on a low-powered machine. At one point it was taking 12seconds to return a query. The graph shown above is after I upgraded the machine but it still shows a 2x degradation.

The query that I tested on has 1000’s of fields that are returned and was the same for both my v3 and v4 tests.

Here is a snippet of my apollo server code

// Setup the Apollo Server once (different from Apollov3)
const apolloServer = new ApolloServer({
	...(import.meta.env.VITE_USE_MOCKS && {
		schema: addMocksToSchema({
			schema: makeExecutableSchema({ typeDefs, resolvers }),
			mocks,
			preserveResolvers: false
		})
	}),
	...{
		cache: new InMemoryLRUCache({
			// ~100MiB
			maxSize: Math.pow(2, 20) * 100,
			// 5 minutes (in milliseconds)
			ttl: 300_000
		}),

		introspection: true,
		typeDefs,
		resolvers,
		// TODO: look at making this more secure
		csrfPrevention: false
	}
});

await apolloServer.start();

Are there some setup options that would help with performance? Or am I doing it all wrong?

Hey @obgibson, thanks for the report. Any chance you have something you can share with me so I can reproduce locally?

I only have one good guess for now (but it’s a pretty good one), so let’s start there:
Did you also upgrade graphql (or any other dependencies) as well during the upgrade process? There is a known performance issue in graphql@16 which is my initial suspicion.

IF you were on v3 + v15 and switched to v4 + v16, would you mind testing v3 + v15 → v3 + v16 and seeing if you get similar results in performance drop? I’d like to make best attempts at isolating this problem first.

If you weren’t on v15 before and had no other notable changes besides v3 → v4 we’ll probably need to get a bit more sophisticated to really dig in to this - either a way for me to reproduce, or a flame chart that I can explore.

Thanks!

Thanks for getting back to me Trevor. I have been on grapphql@16 for a few months now. I will try pinning back to 15 and let you know if I see a difference.