提问人:Ильсур Ибрагимов 提问时间:11/8/2023 更新时间:11/8/2023 访问量:10
如何解决 Golang 的 nginx 问题问题?
How to fix nginx problem problem with Golang?
问:
我在 NGINX 上有带有简单 JSON 请求和反向代理的 Go 服务器。当我尝试计算 rps 时,当我向 Go 服务器发送请求时一切正常,但 NGINX 返回许多 502 错误。可能是什么问题?
操作系统 - 带有 M2 8083 端口的 MacOS - GO
8082 端口 - NGINX
对 GO 的请求
嘿 -h2 -n 20000 -c 100 http://localhost:8083/album
Total: 1.8949 secs
Status code distribution:
[200] 20000 responses
问题:
对 NGINX
hey -h2 -n 20000 -c 100 http://localhost:8082/album 的请求
Total: 30.8949 secs
Status code distribution:
[200] 16346 responses
[502] 3653 responses
worker_processes auto;
events {
worker_connections 2048;
}
server {
listen 8082;
server_name localhost;
proxy_connect_timeout 15;
proxy_send_timeout 15;
proxy_read_timeout 15;
location / {
proxy_pass http://localhost:8083;
}
}
andreichupin@kr2wd63p3q ~ % curl -v http://localhost:8082/album
* Trying 127.0.0.1:8082...
* Connected to localhost (127.0.0.1) port 8082 (#0)
> GET /album HTTP/1.1
> Host: localhost:8082
> User-Agent: curl/8.1.2
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.25.3
< Date: Tue, 07 Nov 2023 20:39:05 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 231
< Connection: keep-alive
<
* Connection #0 to host localhost left intact
[{"id":"1","title":"Blue Train","artist":"John Coltrane","price":56.99},{"id":"2","title":"Jeru","artist":"Gerry Mulligan","price":17.99},{"id":"3","title":"Sarah Vaughan and Clifford Brown","artist":"Sarah Vaughan","price":39.99}]
想要了解这种行为的原因。
答: 暂无答案
评论