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?