V8-archive: GraphQL Endpoint is Very Slow

Created on 19 Sep 2019  路  9Comments  路  Source: directus/v8-archive

Tested both on your demo api and on a dedicated vps freshly installed with the latest version (no docker). For a simple query (no joins, filters, etc.), the time is always >1s.

Is this a known issue?

image

bug optimization

Most helpful comment

The schema shouldn't change often once in production mode (I still think we should have a system flag for when the schema is "locked"), I feel like the API should cache that and just fetch data.

We should definitely look into what info we can fetch once and cache to speed things up.

All 9 comments

I have the same problem.

With queries on the same collection, on top-level fields:

  • REST endpoint takes about 300ms (in the worst case less than 1 second)
  • GraphQL endpoint takes 5-7 seconds.

Unfortunately I have no technical information to enter.
In the logs folder there is nothing related. Can I activate a more verbose log?

Tested on custom docker implementation on aws ec2.

Directus generate GraphQL schema on each request. To generate schema we need to traverse all the relationship.

To make it faster, I am suggesting to use Cache on server-side as well as client-side.

For the server-side caching, Please take a look at https://docs.directus.io/advanced/api/configuration.html#config-file-options

The schema shouldn't change often once in production mode (I still think we should have a system flag for when the schema is "locked"), I feel like the API should cache that and just fetch data.

We should definitely look into what info we can fetch once and cache to speed things up.

Why not trigger the graphql schema generation when there is a change to the structure?

Well we aren't always aware of a schema change, since Directus uses "database mirroring" admins can technically work directly in the database (not always through the API). So we would have to occasionally check the schema for changes.

But this is essentially what I mean by "locking" the schema with a flag so we know when it's safe to cache the schema.

Ref: https://github.com/directus/api/issues/21
Ref: https://github.com/directus/api/issues/22
Ref: https://github.com/directus/api/issues/381

You're right!

Otherwise i tried to enable the caching option, but unexpectedly the cache only works for that exact graphql request, just change it slightly and those 7/8 seconds are back.

@benhaynes We can add the GraphQL schema caching once we have schema flag.

Maybe i find a bug that prevents a collection to be cached in the same request, don't cache the whole schema but make GraphQL schema generation faster: !1354

Please try it and let me know if is ok!

We can add the GraphQL schema caching once we have schema flag.

I agree with this. Closing this on the reference of https://github.com/directus/api/pull/1354

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cdwmhcc picture cdwmhcc  路  3Comments

Varulv1997 picture Varulv1997  路  3Comments

ondronix picture ondronix  路  3Comments

24js picture 24js  路  3Comments

cdwmhcc picture cdwmhcc  路  3Comments