Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

GraphQL Endpoint is Very Slow #1297

Closed
wc-matteo opened this issue Sep 19, 2019 · 9 comments
Closed

GraphQL Endpoint is Very Slow #1297

wc-matteo opened this issue Sep 19, 2019 · 9 comments
Labels
bug Something isn't working optimization Codebase / buildchain improvements

Comments

@wc-matteo
Copy link

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

@benhaynes benhaynes added bug Something isn't working optimization Codebase / buildchain improvements labels Sep 19, 2019
@DevSnap
Copy link

DevSnap commented Sep 23, 2019

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.

@benhaynes benhaynes changed the title graphql endpoint really really slow GraphQL Endpoint is Very Slow Sep 23, 2019
@hemratna
Copy link
Contributor

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

@benhaynes
Copy link
Member

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.

@DevSnap
Copy link

DevSnap commented Sep 25, 2019

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

@benhaynes
Copy link
Member

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: #21
Ref: #22
Ref: #381

@DevSnap
Copy link

DevSnap commented Sep 25, 2019

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.

@hemratna
Copy link
Contributor

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

@Bedotech
Copy link
Contributor

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!

@binal-7span
Copy link
Contributor

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

I agree with this. Closing this on the reference of #1354

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working optimization Codebase / buildchain improvements
Projects
None yet
Development

No branches or pull requests

6 participants