wundergraph / cosmo

The open-source solution to building, maintaining, and collaborating on GraphQL Federation at Scale. The alternative to Apollo Studio and GraphOS.
https://cosmo-docs.wundergraph.com/
Apache License 2.0
745 stars 106 forks source link

feat: add apq back in #1346

Closed df-wg closed 2 weeks ago

df-wg commented 2 weeks ago

Motivation and Context

APQ was implemented in #1330, and then reverted in #1340 because of severe memory implications. After looking into it, it became clear that this is due to our initial L2 cache size for the persisted operations, which was reserving more memory than had been allocated. Looking into ristretto/cache, it's clear that this is somewhat of a recurring issue (where memory doesn't fit neatly into the bounds that were allocated for it). In an effort to resolve it for the moment, this PR assumes that the L2 Cache will be used to preserve the most commonly used persisted operations, and users would rather know that their router won't have an unbounded cache.

After running the k6 bench simulation a number of times, the resulting graph looks like: Screenshot 2024-11-07 at 9 25 04 PM

which makes it clear that it shouldn't have a memory implication at this point.

In the future, we should reexamine how we can create a large cache that won't overflow the memory allocated

Checklist