duanchai0028 2016-10-10 09:08
浏览 144

Golang HTTPS无法处理大数据包

I'm stress testing a simple HTTPS Golang web server which looks like this:

func main() {
    srv := &http.Server{
        Addr:         ":" + port,
        ReadTimeout:  5 * time.Second,
        WriteTimeout: 10 * time.Second,
    }

    mux := http.NewServeMux()
    mux.HandleFunc("/bigpacket", bigpacket)
    srv.Handler = mux

    log.Fatalln(srv.ListenAndServeTLS(certPath+"cert.pem", certPath+"key.pem"))
}

// Sends 1MB file
func bigpacket(w http.ResponseWriter, r *http.Request) {
    http.ServeFile(w, r, "./bigpacket")
}

So it's just a very basic server, which returns a 1MB file on the url: /bigpacket. The test I'm running does 1000 requests per second (so about 1GB per second is send over the connection) for 30 seconds.

When testing this, only about 30% of the requests are successful! However, when I switch to HTTP (by using log.Fatalln(srv.ListenAndServe())) all requests are successful.. (100%) Could these results be correct? Has HTTPS that much overhead over HTTP?

These are the errors I get:

read tcp 10.132.0.4:36248->10.132.0.3:8080: read: connection reset by peer
unexpected EOF
Get https://10.132.0.3:8080/bigpacket: unexpected EOF
read tcp 10.132.0.4:34573->10.132.0.3:8080: read: connection reset by peer
Get https://10.132.0.3:8080/bigpacket: read tcp 10.132.0.4:34573->10.132.0.3:8080: read: connection reset by peer
Get https://10.132.0.3:8080/bigpacket: write tcp 10.132.0.4:38955->10.132.0.3:8080: write: broken pipe
Get https://10.132.0.3:8080/bigpacket: http2: no cached connection was available
Get https://10.132.0.3:8080/bigpacket: read tcp 10.132.0.4:59658->10.132.0.3:8080: read: connection reset by peer
read tcp 10.132.0.4:59658->10.132.0.3:8080: read: connection reset by peer
Get https://10.132.0.3:8080/bigpacket: write tcp 10.132.0.4:57612->10.132.0.3:8080: write: connection reset by peer
read tcp 10.132.0.4:48971->10.132.0.3:8080: read: connection reset by peer
Get https://10.132.0.3:8080/bigpacket: write tcp 10.132.0.4:42138->10.132.0.3:8080: write: connection reset by peer
Get https://10.132.0.3:8080/bigpacket: write tcp 10.132.0.4:33734->10.132.0.3:8080: write: broken pipe
read tcp 10.132.0.4:55605->10.132.0.3:8080: read: connection reset by peer
read tcp 10.132.0.4:34132->10.132.0.3:8080: read: connection reset by peer
read tcp 10.132.0.4:59141->10.132.0.3:8080: read: connection reset by peer
Get https://10.132.0.3:8080/bigpacket: read tcp 10.132.0.4:59141-
  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料