🤗 [Question]: Does Fiber handle each request in different goroutines?
your-diary opened this issue · comments
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.
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.
@ReneWerner87
Thank you very much! I understand.