Session description
Parsing a GraphQL query generally has negligible cost. But what happens your front page query has millions of QPS, 10s of thousands of fields, and there are hundreds of versions of the query? At Meta, we've found that parsing becomes a significant bottle neck under these constraints.
In this talk, we dive into server-side optimizations we built to handle persisted documents beyond simple LRU caches. We will cover:
- Lazy fragment parsing. We delay parsing a fragment until the executor encounters a spread that matches the fragment's type, using offset maps to jump through the document text.
- Traffic based caching. We cache pre-parsed structures taking into consideration CPU savings and memory cost.
- Fragment inlining to reduce overhead in the CollectFields step.
Attendees leave with deep understanding of performance considerations of GraphQL execution engines. I hope other GraphQL server implementations can consider adopting similar strategies to better serve a larger variety of traffic patterns.