V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
thomaswang
V2EX  ›  问与答

使用 go http client(code 如下), 压测一台服务器上的 http server, qps 是 1.2w, 隔三差五的就返回 read: connection reset by peer

  •  
  •   thomaswang · 2019-10-22 11:24:00 +08:00 · 1213 次点击
    这是一个创建于 1645 天前的主题,其中的信息可能已经有所发展或是发生改变。

    http server 这台机器(这个上面的 HTTP server 业务耗时很短的), 连接数也不多, 如下图, 我该如何排查, 找到问题,解决问题呢, 求解答

    func HttpPost(url string, http_body string) {
    	payload := strings.NewReader( http_body)
    	client := &http.Client{}
    	req, _ := http.NewRequest("POST", url, payload)
    
    	req.Header.Add("Content-Type", "text/plain")
    	req.Header.Add("User-Agent", "PostmanRuntime/7.17.1")
    	req.Header.Add("Accept", "*/*")
    	req.Header.Add("Cache-Control", "no-cache")
    	req.Header.Add("Postman-Token", "f54288e2-8fd5-4478-8138-746e16017f5e,79731914-e661-45f7-83ad-6c53a131ba10")
    	req.Header.Add("Host", "localhost:8080")
    	req.Header.Add("Accept-Encoding", "gzip, deflate")
    	req.Header.Add("Content-Length", "10")
    	req.Header.Add("Connection", "keep-alive")
    	req.Header.Add("cache-control", "no-cache")
    
    	res, err := client.Do(req)
    	if err == nil {
    		defer res.Body.Close()
    		body, err1 := ioutil.ReadAll(res.Body)
    		if err1 != nil {
    			init_config.FileLogs.Error("err1: ", http_body, string(body), err1.Error())
    		} else {
    		}
    	} else {
    		init_config.FileLogs.Error("err: ", http_body, err.Error()) // 这一行记录到的 read: connection reset by peer
    	}
    }
    

    目标服务器

    [root@xx log]# netstat -anp | wc -l
    3596
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3297 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 12:17 · PVG 20:17 · LAX 05:17 · JFK 08:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.