請求超時問題排查
微服務調用一個阻塞連接,需要2到3分鐘,但是每次到60秒時,後臺出現504 getway timeout問題,初步懷疑是ribbon的超時導致的,檢查發現不是,排除;再次懷疑nginx默認的60秒超時導致,發現配置了proxy-read-timeout、proxy-connection-timeout等參數依然無效,在這裏還以爲是nginx配置的不對,做了很多實驗,花了不少時間,依然無效,頁面仍然包504。
查看nginx錯誤日誌,報一下錯誤:
2020/05/28 10:38:50 [info] 27861#0: *19551718 epoll_wait() reported that client prematurely closed connection,
so upstream connection is closed too while sending request to upstream, client: xx.xx.xx.xx, server: xx.xx.xx.xx,
request: "POST /xxxm?wId=00000172-5924-9980-0019-c87063eaafe0&orgId=05ec79d926dc41d59d324eaa2807bdd4 HTTP/1.1",
upstream: "http://127.0.0.1:xx/xxxx?wId=00000172-5924-9980-0019-c87063eaafe0&orgId=05ec79d926dc41d59d324eaa2807bdd4",
host: "www.xxxx.com", referrer: "https://www.xxxx.com/"
2020/05/28 10:38:50 [info] 27862#0: *19551720 epoll_wait() reported that client prematurely closed connection,
so upstream connection is closed too while sending request to upstream, client: xx.xx.xx.xx, server: xx.xx.xx.xx,
request: "POST /xxxx HTTP/1.1", upstream: "http://127.0.0.1:xxx/aimxxxx",
host: "www.xxxx.com"
網上查詢都說是nginx超時,或者後端微服務超時,和我上面實驗的內容大同小異。
一系列搜索無效後,認真看看上面的日誌,突然靈光一閃,日誌報的是client prematurely closed connection啊,客戶端關閉了連接啊,我查後端的有什麼用呢,這時候猜測可能是阿里雲的負載均衡做了超時設置,果然發現阿里雲的負載均衡域名默認超時是60秒,果斷改掉,重新試了下,嗯???怎麼還不行,崩潰。重啓下負載均衡slb試試,終於好了。。。。