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

IntrospectionQuery is causing huge memory consumption after the latest updates #959

Closed
flymedllva opened this issue Jul 24, 2024 · 13 comments · Fixed by #986
Closed

IntrospectionQuery is causing huge memory consumption after the latest updates #959

flymedllva opened this issue Jul 24, 2024 · 13 comments · Fixed by #986
Labels
bug Something isn't working internally-reviewed The issue has been reviewed internally.

Comments

@flymedllva
Copy link
Contributor

Component(s)

router

Component version

0119c2d

wgc version

0.58.5

controlplane version

router version

0119c2d

What happened?

Description

After one of the recent Cosmo updates, there is an abnormal increase in memory consumption when calling IntrospectionQuery (e.g. in the Playground refresh button).

Our schema (config.json), from which we get this result, weighs 13.7M. On older versions of cosmo we didn't have this problem.

Occurs after executing err = t.loader.LoadGraphQLResponseData(ctx, response, t.resolvable) in resolve.go (wundergraph/graphql-go-tools/v2@v2.0.0-rc.63)

Steps to Reproduce

  • Prepare a huge scheme
  • Prepare a config from that schematic
  • Run the cosmo with this config
  • Press the refresh button in Playground

Expected Result

Consume the normal amount of memory for this request)

Actual Result

Brutal memory consumption)

Screen.Recording.2024-07-24.at.17.51.02.mov

Environment information

Environment

OS: (e.g., "Ubuntu 20.04") macOS / Linux
Package Manager: npm
Compiler(if manually compiled): go version go1.22.3 darwin/arm64

Router configuration

version: "1"

# General router options
graph:
  name: "production"
  token: ""

log_level: "info"
listen_addr: "localhost:3002"
playground_enabled: true
introspection_enabled: true
json_log: true
shutdown_delay: 15s
grace_period: 20s
poll_interval: 10s
health_check_path: "/health"
readiness_check_path: "/health/ready"
liveness_check_path: "/health/live"
router_config_path: "config.json"

cors:
  allow_origins: ["*"]
  allow_methods:
    - HEAD
    - GET
    - POST
  allow_headers:
    - Origin
    - Content-Length
    - Content-Type
  allow_credentials: true
  max_age_minutes: 5m

# Config for custom modules   
# See "https://cosmo-docs.wundergraph.com/router/custom-modules" for more information   
modules:
  myModule:
    # Arbitrary values, unmarshalled by the module
    value: 1

Router execution config

No response

Log output

No response

Additional context

No response

@flymedllva flymedllva added the bug Something isn't working label Jul 24, 2024
Copy link

WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible.
The roadmap is driven by our customers and we have to prioritize issues that are important to them.
You can influence the priority by becoming a customer. Please contact us here.

@jensneuse
Copy link
Member

Does the same behavior happen when you make a introspection query from e.g. curl while disabling brotli? We've got a suspicion that the brotli Middleware is responsible, which gets usually activated by browsers.

@flymedllva
Copy link
Contributor Author

flymedllva commented Jul 24, 2024

OK, 50MB – router@0.95.1
Memory running out, 10GB+ – router@0.95.2

Video of work using router@0.95.2
https://github.com/user-attachments/assets/ab57f1c7-f7ea-4a73-b801-e0cc927ec53e

I haven't figured out how to disable brotli on this version, hint? I couldn't find it in the doc. I can cut it in the code if you tell me where)

@flymedllva
Copy link
Contributor Author

@flymedllva
Copy link
Contributor Author

8d7f20a in cosmo increased memory consumption in this scenario

@flymedllva
Copy link
Contributor Author

Just in case. That PR #968 didn't solve the problem

Since it seems to be consuming memory in graphql-go-tools/v2

@StarpTech
Copy link
Contributor

Hi @flymedllva please retry the latest release. We did couple of optimizations. We will take a deeper look if it is still reproducible. Thank you.

@StarpTech StarpTech added the internally-reviewed The issue has been reviewed internally. label Jul 30, 2024
@flymedllva
Copy link
Contributor Author

flymedllva commented Jul 30, 2024

Hi @StarpTech, I tried router@0.99.1, the result is the same

Please note my recent posts

Screen.Recording.2024-07-30.at.16.56.59.mov

@StarpTech
Copy link
Contributor

Hi, thanks for the test. Could you attach your router config here or send me via dustin@wundergraph.com? Thank you!

@YassineElbouchaibi
Copy link
Contributor

Same on my side, 4gb has always be enough memory but since a few releases introspection has been failing and pods restarting:
image
The spikes timestamps match with introspection queries.

@StarpTech
Copy link
Contributor

@flymedllva please send me your router config. https://cosmo-docs.wundergraph.com/cli/router/fetch

@flymedllva
Copy link
Contributor Author

Hi @StarpTech, sent it to your email dustin@wundergraph.com

@flymedllva
Copy link
Contributor Author

flymedllva commented Jul 31, 2024

@jensneuse @StarpTech

I tried #986, no introspection problems on it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working internally-reviewed The issue has been reviewed internally.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants