-
Notifications
You must be signed in to change notification settings - Fork 257
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
Significantly higher memory usage in gateway 2.0.5 and 2.1.0-alpha #2085
Comments
Some more numbers from the same setup/investigation:
|
There is probably 2 things to be remarked on those numbers:
The 1st point is obviously the most problematic given the number involved. The reason this happen is due to:
In doing point 3, and due to point 2, the code ended up adding all value types to all (reconstructed) subgraphs. Which is fine from a correction POV (the resulting subgraph just have some unreachable types in many cases), but in the case of point 1, this could all subgraph being quite big and with lots of subgraph ends up consuming lots of memory. Anyway, pushed a fix in #2089 that does some reachability checks on types to avoid this problem and this makes the memory consumption for fed1 supergraphs to be roughly the same than when recomposing into fed2 supergraphs. The 2nd point mentioned above is the fact that fed2 in general use memory than fed1. That part is really more due to the fact that fed1 and fed2 query planner are very different. In particular, as said above, fed2 does re-create the original subgraph to some extent and those end up consuming a fair amount of memory when there is lots of subgraphs. Nonetheless, to be honest, I hadn't looked at memory consumption at all with the fed2 query planner, and look a bit closer for this issue, I did noticed a few simple opportunity to reduce consumption so include those in the PR (on #2089). Fwiw, my own measurement on a test relatively similar to the one above give me:
which both shows that the crazy fed1-supergraph case is fixed and some gains with the patch compared to current |
Fed1 supergraph lacks information on value types regarding which subgraphs defines them. We use to brute-force add all value types to all extract subgraphs, on the idea that if some extracted subgraphs have a few unused types, it's useless but has no functional impact. Unfortunately, in some special cases (lots of subgraphs and value types), those useless types can lead to a significant increase in memory consumptions. This patch instead look at type reachability within subgraphs to avoid including those useless value types, and thus lower the memory consumptions. Note that fed2 supergraphs are not affected by this problem has they have all the information needed to only extract types in the proper subgraphs. Fixes apollographql#2085
Reported by a customer using a large Fed1 supergraph (shared in Slack).
This is just on startup before taking any requests, so it's not caused by large query plans.
The text was updated successfully, but these errors were encountered: