使用nginx设置微服务超时

时间:2016-11-02 17:37:46

标签: nginx

我在传递请求时有一个微服务有一定的性能要求。如果超过两秒钟,它必须以特定响应失败。设置nginx.conf文件以支持此功能的最佳方法是什么?

1 个答案:

答案 0 :(得分:1)

所以看起来答案就是这个问题,你必须拥有与原始微服务调用相同的超时响应终点。

server {
   listen       9000;
   server_name  localhost;

   location /microservice {
       proxy_pass http://127.0.0.1:8080;
       proxy_intercept_errors on;
       proxy_read_timeout 2s;
       error_page 504 =200 @timeout;
   }

   location @timeout {
      proxy_pass http://127.0.0.1:8081;
   }
相关问题