nginx http超时重试幂等问题

nginx做反向代理时,作为负载均衡器,对执行失败的任务默认会调度到其他节点执行。

默认设置:proxy_next_upstream error timeout #发生网络错误以及超时,才会在其他服务器重试

proxy_next_upstream error timeout http_500 #500时重试

proxy_next_upstream error timeout http_502 #502时重试

proxy_next_upstream error timeout http_503 #503时重试

需要特别注意的时,put,get类幂等方法重试是没有问题的。对于post方法是非幂等请求,默认针对post方法是不会重试的。比如创建订单请求,前端的超时,后端如果重试,可能会出现创建多个订单情况。如果非要开启post方法的重试(线上一般不会开启),加上non_idempotent参数。

 proxy_next_upstream error timeout http_500 non_idempotent;#500重试,包括post,lock,path方法
 

猜你喜欢

转载自blog.csdn.net/wangtingting_100/article/details/89842557