Skip to content

net/http: Keep-Alive is not used #50777

Closed
@waldreiter

Description

@waldreiter

What version of Go are you using (go version)?

go1.17.6 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

A go server that responses with some text larger than 2 kB:

package main

import (
	"fmt"
	"log"
	"net/http"
	"strings"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
		fmt.Fprint(w, strings.Repeat("@", 2049))
	})

	log.Fatal(http.ListenAndServe(":8080", nil))
}

ApacheBench calls it many times:

ab -c 8 -n 100000 -s 3 -k http://127.0.0.1:8080/

What did you expect to see?

ApacheBench should run successfully.

What did you see instead?

This is ApacheBench, Version 2.3 <$Revision: 1879490 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 10000 requests
apr_pollset_poll: The timeout specified has expired (70007)
Total of 16366 requests completed

Some observations

  • If fewer requests are done, then it works. But ApacheBench shows that they are not Keep-Alive requests.
  • If the response lenth is 1 byte shorter, so the response is only 2048 bytes long, then the requests are all successful. ApacheBench shows that Keep-Alive requests is used on all of them.
  • I did run ApacheBench against another web server, Actix Web, without that problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions