Skip to content

Include a caching document provider implementation by default #4107

@bbakerman

Description

@bbakerman

Caching the parsing and validation of a document can save significant latency.

For very large operations, and tools like Relay produce very large operations, the parse and validate latency can be upwards of 15-20ms (p99)

By caching this step you can amortize the cost over many requests and hence cut nearly all of this latency out.

The graphql.execution.preparsed.PreparsedDocumentProvider is the interface that allows you to build a caching document mechanism but out of the box graphql-java does not provide a working implementation

I propose that we

  • Create a public class CachingDocumentProvider implements PreparsedDocumentProvider
  • That is used Caffeine as the cache
  • Provide a GraphQLUnusualConfiguration mechanism to to tune the cache
    • time base
    • size based
    • etc
  • Ship with this TURN on by default (in 2 versions)
  • Shade in https://github.com/ben-manes/caffeine as the cache implementation

The implication here is that https://github.com/ben-manes/caffeine would become a dependency (shaded) and we have mostly aimed for low to zero dependencies but I think the juice is worth the squeeze here. All operations will run faster with a cache in place.

I dont know right now of the implications for library frameworks such as Spring GraphQL. Do they have one themselves, is it always on? Hence this issue to stand as a discussion mechanism

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stalekeep-openTells Stale Bot to keep PRs and issues open

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions