Answer the question
In order to leave comments, you need to log in
Why are net/http requests not processed or how to increase the listen queue?
Good afternoon.
I take a simple script
package main
import (
"fmt"
"strconv"
"net/http"
)
var cnt = 0
func handler(w http.ResponseWriter, r *http.Request) {
cnt = cnt + 1
fmt.Fprintf(w, "cnt: " + strconv.Itoa(cnt))
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8100", nil)
}
curl http://127.0.0.1:8100/
ab -c 50 -n 5000 http://127.0.0.1:8100/
curl http://127.0.0.1:8100/
ab -c 200 -n 100000 http://127.0.0.1:8000/
and cnt returns correctly (100002) I Answer the question
In order to leave comments, you need to log in
Because the race condition.
Use ```atomic.AddUint64(&cnt, 1)```
And yes - you need to look at pending requests by stat ab.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question