what does it means "heavy load"? if not in "heavy load", it can work ? On the other hand, do you want the tcp connections or the http req numbers? >From the go package, it appears that getting the basic tcp connections in http.server is impossible.
在 2019年2月12日星期二 UTC+8下午10:37:52,jose.albe...@gmail.com写道: > > I was trying to get current HTTP connections in HTTP.Server. Internally > transport tracks it under connPerHostCount. However, I don't see a way of > getting this value. > > I tried this: > > type HTTPRequestMetrics struct { > activeConnections int64 > next http.Handler > } > > > func HTTPRequestMetricsHandler(h http.Handler) *HTTPRequestMetrics { > return &HTTPRequestMetrics{next: h} > } > > > func (h *HTTPRequestMetrics) ServeHTTP(w http.ResponseWriter, r *http. > Request) { > atomic.AddInt64(&h.activeConnections, 1) > defer atomic.AddInt64(&h.activeConnections, -1) > > > h.next.ServeHTTP(w, r) > } > > > But looks like defer never gets called when under heavy load (and clients > see connection reset by peer) > > Does anyone know a way of getting current open connections? > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.