{"id":157691,"date":"2020-09-11T05:49:34","date_gmt":"2020-09-10T21:49:34","guid":{"rendered":"http:\/\/4563.org\/?p=157691"},"modified":"2020-09-11T05:49:34","modified_gmt":"2020-09-10T21:49:34","slug":"nginx-%e8%bd%ac%e5%8f%91-grpc-%e6%b1%82%e5%8a%a9","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=157691","title":{"rendered":"Nginx \u8f6c\u53d1 grpc \u6c42\u52a9"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Nginx \u8f6c\u53d1 grpc \u6c42\u52a9               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : vanis <\/span>  <span><i><\/i> 5<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u8fd0\u884c\u73af\u5883 OS\uff1aubuntu 18.04 nginx:1.17.10 grpcio:1.31<\/p>\n<p>\u95ee\u9898\u63cf\u8ff0\uff1a \u7528 nginx \u505a\u4e86 grpc \u670d\u52a1\u7684\u8f6c\u53d1 \/\u8d1f\u8f7d\u5747\u8861\uff0cclient \u5e76\u53d1\u8c03\u7528\u65f6\u968f\u673a\u51fa\u73b0 status = StatusCode.UNAVAILABLE details = &#8220;GOAWAY received&#8221; \u540c\u6837\u5e76\u53d1\u8bf7\u6c42\u6570\u91cf\uff0c\u76f4\u63a5\u8c03\u7528 grpc \u670d\u52a1\u5668\u5730\u5740\uff0c\u4e0d\u901a\u8fc7 nginx \u8f6c\u53d1\u5219\u4e0d\u4f1a\u51fa\u73b0\u95ee\u9898\uff0c\u5e94\u8be5\u4e0d\u662f\u670d\u52a1\u7aef\u8bbe\u7f6e\u7684\u95ee\u9898\u3002<\/p>\n<p>nginx \u914d\u7f6e\uff1a<\/p>\n<p>upstream grpcservers { server xxx.xxx.xxx.1:50051; server xxx.xxx.xxx.2:50051; }<\/p>\n<p>server{ listen 8080 http2;<\/p>\n<pre><code>location \/foo. { grpc_pass grpc:\/\/grpcservers; } <\/code><\/pre>\n<p>}<\/p>\n<p>\u8bf7\u6559\u5404\u4f4d\u5927\u4f6c\u6709\u4f55\u5efa\u8bae\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>9<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3363990\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : joesonw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             client maxRetry                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3363991\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : vanis <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5927\u4f6c\u80fd\u5c55\u5f00\u8bf4\u4e0b\u4e48?\u67e5\u4e86\u4e0b nginx \u7684\u6587\u6863\uff0c\u53ea\u53d1\u73b0\u4e86 grpc_next_upstream_tries \u8fd9\u4e2a\u9009\u9879\u8ddf retry \u6709\u5173\uff0c\u8bbe\u7f6e\u4e86\u4e0b\u6ca1\u53cd\u5e94\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3363992\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : rimutuyuan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e4b\u524d\u6211\u4eec nginx + grpc \u538b\u6d4b\u65f6\u4e5f\u51fa\u73b0\u8fc7\u5f88\u591a\u89e3\u51b3\u4e0d\u4e86\u7684\u8fde\u63a5\u5931\u8d25\u95ee\u9898\uff0c\u8bbe\u7f6e max request timeout \u5404\u79cd\u76f8\u5173\u7684\u53c2\u6570\u90fd\u5c1d\u8bd5\u8fc7<\/p>\n<p>\u540e\u6765\u6362\u4e86 envoy                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3363993\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : JmmBite <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u66f4\u6539\u7aef\u53e3\u56de\u6536\u7b56\u7565\uff1atcp_tw_recycle<\/p>\n<p>https:\/\/juejin.im\/post\/6844903809534148622                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3363994\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : godgrp <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             location \u4e0d\u80fd\u7528 \/foo , \u4f60\u53ef\u4ee5\u53bb\u770b\u4e0b grpc \u7684\u8bf7\u6c42\u8def\u5f84\u662f\u4ec0\u4e48\uff0c\u53ef\u4ee5\u53d1\u73b0\u4ed6\u7684\u8bf7\u6c42\u8def\u5f84\u7c7b\u4f3c\u662f \u201c\/\u4f60\u7684\u670d\u52a1 package \u540d \/&#8230;\u201d,\u4e00\u79cd\u4f60\u6309\u4f60\u7684\u670d\u52a1\u540d\u53bb\u8f6c\u53d1\uff0c\u53e6\u4e00\u79cd\u4f7f\u7528 nginx \u7684\u56db\u5c42\u8f6c\u53d1                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3363995\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : puncsky <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             envoy +1                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3363996\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : vanis <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @godgrp <br \/>\u611f\u8c22\u7ec6\u5fc3\uff0c\/foo.\u662f\u670d\u52a1\u5305\u7684\u901a\u914d\u7b26\u3002\u3002\u3002\u4e5f\u8bd5\u8fc7\u76f4\u63a5\u7528 \/Package.module\/foo \u7684\u8be6\u7ec6\u8def\u5f84\uff0c\u6ca1\u89e3\u51b3\u95ee\u9898\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3363997\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : vanis <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @JmmBite <br \/>\u611f\u8c22\u6307\u51fa\uff0c\u770b\u4e86\u4e0b\u89e3\u51b3\u65b9\u6848\u3002\u8981\u52a8\u670d\u52a1\u5668\u8bbe\u7f6e\uff0c\u611f\u89c9\u4ee3\u4ef7\u592a\u5927\u4e86\u3002\u3002\u3002<br \/>\u53cd\u6b63\u5e94\u7528\u573a\u666f\u662f\u96c6\u7fa4\u8ba1\u7b97\u7684\u4efb\u52a1\u5206\u914d\uff0c\u4e0d\u5982\u5728\u5ba2\u6237\u7aef\u591a\u5199\u70b9\u4ee3\u7801\u5b9e\u73b0\u8f6e\u8be2\u7b97\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3363998\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : vanis <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @rimutuyuan <br \/>\u611f\u8c22\u7ecf\u9a8c\u5206\u4eab\uff0c\u8c8c\u4f3c\u53ea\u80fd\u5f03\u5751\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Nginx \u8f6c\u53d1 grpc \u6c42\u52a9 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/157691"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=157691"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/157691\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=157691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=157691"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=157691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}