mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-11 06:39:08 -07:00
Limit number of concurrent connections
Go's net/http library has no limits in place for number of concurrent requests currently being processed. This can result in an enormous number of goroutines being created and the read/write buffer pools growing unbounded resulting in OOM situations.
This commit is contained in:
@@ -117,10 +117,14 @@ func Serve(cfg *config.Config, tkr *tracker.Tracker) {
|
||||
}
|
||||
|
||||
glog.V(0).Info("Starting on ", cfg.Addr)
|
||||
if cfg.HttpListenLimit != 0 {
|
||||
glog.V(0).Info("Limiting connections to ", cfg.HttpListenLimit)
|
||||
}
|
||||
|
||||
grace := &graceful.Server{
|
||||
Timeout: cfg.RequestTimeout.Duration,
|
||||
ConnState: srv.connState,
|
||||
ListenLimit: cfg.HttpListenLimit,
|
||||
Server: &http.Server{
|
||||
Addr: cfg.Addr,
|
||||
Handler: newRouter(srv),
|
||||
|
||||
Reference in New Issue
Block a user