Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip validation on automated persisted query cache hits #1566

Closed
jakepusateri opened this issue Aug 24, 2018 · 3 comments
Closed

Skip validation on automated persisted query cache hits #1566

jakepusateri opened this issue Aug 24, 2018 · 3 comments
Labels
⛲️ feature New addition or enhancement to existing solutions

Comments

@jakepusateri
Copy link

For larger queries, validation takes significant time (50-80ms). With automatic persisted queries in 2.0, we should be able to do this step only on write to cache, and skip it if persistedQueryHit is true.

Would you be open to a PR for this?

@ghost ghost added the ⛲️ feature New addition or enhancement to existing solutions label Aug 24, 2018
@jakepusateri
Copy link
Author

I implemented a proof of concept of this in our server by adding a simple in-memory lru cache of parsed query objects keyed by the md5 hash of the query. The queries were added to the cache after they passed validation. This cut cpu usage in half and reduced query times of complex queries by 40%. I'm planning on making a PR later this week.

@martijnwalraven
Copy link
Contributor

@jakepusateri Those are great results! Note that we're working on a refactoring of apollo-server-core that will land soon: https://github.com/apollographql/apollo-server/tree/abernix/re-new-request-pipeline

So it probably make sense to wait until that has been merged to open a PR.

@abernix
Copy link
Member

abernix commented Jul 3, 2019

While we didn't directly link it to the APQ implementation, I did implement a parse/validated cache store in #2111 which, as you're certainly aware from your above experimentation, substantially reduced the time spent in those phases!

I'll close this since I think we've got the spirit of your request implemented, even if it wasn't to the exact letter of your request. 😄 Hope you're able to try it out!

@abernix abernix closed this as completed Jul 3, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
⛲️ feature New addition or enhancement to existing solutions
Projects
None yet
Development

No branches or pull requests

3 participants