-
I'm running a service that has 100-200/s requests at idle and 700-1000/s requests at peak(usually the peak will last for 10~30 min). Now I'm running into memory issues.Here are what I could found: Lines 642 to 651 in 6b09f3f Then *http.Server will create a new goroutines that running *conn.serve . Eventually, At these three lines, it will allocate buffer and read the request for each connection(I don't know how to reference other repo's code preview like the last one, so I use a link): server.go
The question is, how to optimize the memory between these behaivor? More specifily:
Here's
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
This is how standard library http.Server works - this is nothing inherently Echo specific. You definitely find better answers when you google for http.Server concurrency. Echo/Gin and similar std based "framework" role here is only to do request routing and run middlewares and eventually execute handler function. This is post from another thread that details how it works #2205 (comment) but I assume that you know that already, having checked the profiler/debugger And about #1942 If I recall correctly this is about how sockets behave (linger and are reused etc) and not how http.Server handles the connections. If you run Echo with your own http.Server instance you will not use func main() {
e := echo.New()
s := http.Server{
Addr: ":8080",
Handler: e,
}
if err := s.ListenAndServe(); errors.Is(err, http.ErrServerClosed) {
log.Fatal(err)
}
} |
Beta Was this translation helpful? Give feedback.
This is how standard library http.Server works - this is nothing inherently Echo specific. You definitely find better answers when you google for http.Server concurrency. Echo/Gin and similar std based "framework" role here is only to do request routing and run middlewares and eventually execute handler function.
This is post from another thread that details how it works #2205 (comment) but I assume that you know that already, having checked the profiler/debugger
And about #1942 If I recall correctly this is about how sockets behave (linger and are reused etc) and not how http.Server handles the connections.
Keep-alive
header is both server and client-side decision. If client wants to hav…