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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃 [Question]: Does Fiber handle each request in different goroutines? #2988

Closed
3 tasks done
your-diary opened this issue Apr 26, 2024 · 2 comments
Closed
3 tasks done

Comments

@your-diary
Copy link

Question Description

This is a very fundamental question, but surprisingly, I couldn't find any answer by googling and searching for Stack Overflow.

There is a similar question on Stack Overflow but no one answers it.

  • Does Fiber handle each request in different goroutines?

  • Does Fiber create a new goroutine every time a new request comes? Or does Fiber use something like a goroutine pool?

  • What is the maximum number of concurrent goroutines? Is there a limit (imposed by Fiber or fasthttp) in the first place?

  • Are the answers of the questions above specific to Fiber? Or are they derived from fasthttp?

Code Snippet (optional)

No response

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have checked for existing issues that describe my questions prior to opening this one.
  • I understand that improperly formatted questions may be closed without explanation.
@ReneWerner87
Copy link
Member

Fiber, built on top of the fasthttp package, does indeed handle each request in a separate goroutine by default. This means that when a new request arrives, Fiber spawns a new goroutine to handle it. However, Fiber utilizes an efficient goroutine pool to manage these goroutines, ensuring that the overhead of goroutine creation is minimized.

Regarding the maximum number of concurrent goroutines, it's influenced by various factors including system resources and configuration settings. Neither Fiber nor fasthttp imposes a specific limit on the number of concurrent goroutines. Instead, it relies on the underlying Go runtime to manage goroutines efficiently.

These characteristics are specific to Fiber and are derived from its underlying fasthttp package, which is known for its lightweight and high-performance nature in handling HTTP requests in Go applications.

@your-diary
Copy link
Author

@ReneWerner87
Thank you very much! I understand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants