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

Fastify under-pressure how to find out which routes are reasons #1027

Open
meotimdihia opened this issue May 7, 2024 · 4 comments
Open

Fastify under-pressure how to find out which routes are reasons #1027

meotimdihia opened this issue May 7, 2024 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@meotimdihia
Copy link

meotimdihia commented May 7, 2024

Do we have a way to find out which routes are the problem?

fastify.register(underPressure, {
  maxEventLoopDelay: 1000,
  exposeStatusRoute: true,
  pressureHandler: (req, rep, type, value) => {
      if (type === underPressure.TYPE_HEAP_USED_BYTES) {
        fastify.log.warn(`too many heap bytes used: ${value}`)
      } else if (type === underPressure.TYPE_RSS_BYTES) {
        fastify.log.warn(`too many rss bytes used: ${value}`)
      } else if (type == underPressure.TYPE_EVENT_LOOP_DELAY) {
        fastify.log.warn(`reached max even loop delay: ${value}`)
        fastify.Sentry.captureMessage('reached max even loop delay');
      }

      rep.send('out of memory') // if you omit this line, the request will be handled normally
    }
  })

image

Please give me a tip/guide. I don't know how to do it.

@meotimdihia meotimdihia added the help wanted Extra attention is needed label May 7, 2024
@mcollina
Copy link
Member

mcollina commented May 7, 2024

req should have all the information regarding the route. I'm a bit concerned about that Infinity, can you add a full reproduction?

@meotimdihia
Copy link
Author

@mcollina thanks. This project's source code is big, I need to find out the reason first. I'll add a demo if I can reproduce it.

@meotimdihia
Copy link
Author

@mcollina I still can't fix this problem. My server just used 33% CPU and 50% memory.

Do we have any way to utilize 100% CPU?

@mcollina
Copy link
Member

I'm sorry but I don't understand the question. The full point of under-pressure is to prevent the server from overloading, keeping it responsive at all times.

The fact that your server "go" at 33% of CPU can mean all sorts of things. Usually you are exahusting some other limited resources, such as a connection pool or an OS buffer, or file descriptor limit.

If you remove under-pressure, could you get it to go 100%.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants