gRPCãµã¼ããAWSã®NLBã§ãã¼ããã©ã³ã¹ããå ´åã®tips
â» ãã®è¨äºã«æ¸ãã¦ããã®ã¯ããã¹ããªæ¹æ³ãã§ã¯ãªãã§ããæéã«å¶ç´ãããä¸ã§ã¨ãããããããã£ã¦åé¡è§£æ±ºãããä»ã®ã¨ããã¯è¯ãããã¨ããè¨äºã§ãã
gRPCãµã¼ãã®ãã¼ããã©ã³ã¹ãè¡ãæ¹æ³ã«ã¤ãã¦ã¯è²ã ãªæ¹æ³ããã£ã¦ãããããã ãã æ¸ããã¨ã¯ããªãããªã³ã¯å ãåç §ããããã
ã¾ã¼è¦ã¯
- ã¯ã©ã¤ã¢ã³ãå´ã§ãã
- Proxyæãã§ããã¤ã«ãããã
- L4ã§ãã¼ããã©ã³ã¹
- L7ã§ãã¼ããã©ã³ã¹
ã®ã©ãããé¸ã¶ãã¨ã«ãªãããµã¼ãã¹ãã³ã³ãããã¼ã¹ã§åãã¦ãããªããEnvoyã¨ãã®SideCarã«ããããã®ãä¸çªã»ã³ã¹ããæ°ããã¦ããã
ã§ãã¡ãã£ã¨ãã®ããã ãã«å®ç°å¢ãã³ã³ããåããããã«ããããããProxyãµã¼ããå¥ã«éç¨ããããªãã¦ãªãããããã¦AWSã®L7ãã¼ããã©ã³ãµã§ããALBã¯ããã¯ã¨ã³ãã®HTTP/2éä¿¡ã«å¯¾å¿ãã¦ããªãã¯ã½ã§ãããã©ãããããè²ã èããæ«ã«NLBã使ã£ã¦L4ã§ãã¼ããã©ã³ã¹ãããã¨ã«ããã
ãã®æ¹æ³ã«ã¯åé¡ããã£ã¦ãè¦ã¯L4ã ã¨ã¡ãã»ã¼ã¸åä½ã§ãªãã³ãã¯ã·ã§ã³åä½ã§ãããã¼ããã©ã³ã¹ããªãã®ã§ãããã¾ããã¼ããã©ã³ã¹ã§ãã¦ããªããæãã«ãªã£ã¦ãã¾ããã¾ãããã¯å¦¥åãããã
ã§ããã£ã¦ãã£ãã¨ãããéçºç°å¢ã§åé¡ãèµ·ãã£ãã
ä¸è¨ãªã³ã¯å ã«ããããã«ãNLBã¯åæã«timeoutãã¦ã³ãã¯ã·ã§ã³ãåããæ大3600ç§ãããããèµ·ããã¨ã¯ã©ã¤ã¢ã³ãå´ãéä¿¡ãããã¨ããæç¹ã§ãµã¼ãå´ããRSTãéãã¤ããããgRPCçã«ã¯UNAVAILABLEã¨ã©ã¼ãçºçãããå°ã£ããã¨ã«ãããçºçããã¨ã³ãã¯ã·ã§ã³ãè ã£ããããªç¶æ ã«ãªã£ã¦ãã¾ããgRPCãµã¼ããä¸åº¦åèµ·åããªãã¨ç´ããªããå°ã£ããªãå°ã£ããªã
ã ã£ããããããkeepaliveããã«é½åº¦æ¥ç¶ãããããããããªããï¼ã¨æã£ã¦è²ã 試ããããgRPCã¯ã©ã¤ã¢ã³ãã®ã³ãã¯ã·ã§ã³ç®¡çã¯å é¨çã«Channelã¨å¼ã°ããä½ãã«ãã£ã¦è¡ããã¦ãããRubyã¬ãã«ã§ãªãã¸ã§ã¯ããç ´æ£ãã¦ãTCPã³ãã¯ã·ã§ã³ãéãã¦ã¯ãããªããããã¦æ示çã«éããã¤ã³ã¿ãã§ã¼ã¹ããªããå°ã£ããªãå°ã£ããªãã©ãããgRPCã§ã¯ã¦ã¼ã¶å´ã§TCPã³ãã¯ã·ã§ã³ã®ç¶æ ãå¶å¾¡ãããããããªãããããå ¨ã¦ã¯ä¿ºãã¡ (Channel) ã«ä»»ããããåãã¯æãåºããªãããããææ³ãããã
ãããªãkeepaliveã®ä¸ã§heartbeatãã¡ããã¨æã¤ããã«è¨å®ããããã¨æã£ã¦ã¯ã©ã¤ã¢ã³ãå´ããµã¼ãå´ã®è¨å®å¤ãããããããã£ã¦ããheartbeatéã£ã¦ãæå ¨ç¶ãªãã俺ã¯tsharkã¨ã«ããã£ãããªãã ãããï¼è¨å®ãåæ ãããªãããå°ã£ããªãå°ã£ããªããããªãã¨ãã£ã¦ãã¨ãªãªã¼ã¹ã«éã«åãããã
ã©ã¼ã調ã¹ãã¨ãã¯ã©ã¤ã¢ã³ãå´ã«ãè¨å®èªä½ã¯ã§ãããæå³ãªããªãã·ã§ã³ããã£ããããããã ãããã§è²ã ããã£ã¦ãããã¡ãããµã¼ãå´ããä¸å®æéã§ã³ãã¯ã·ã§ã³ãåããã¨ãããªãã·ã§ã³ã¯ã¡ããã¨åããã¨ãããã£ãã
grpc.max_connection_age_ms
ããã ã
ãããè¨å®ããã¨ãä¸å®æé以ä¸æ¥ç¶ã®ç¶ãã¦ããã³ãã¯ã·ã§ã³ï¼ã¹ããªã¼ã ï¼ï¼ã«ã¯HTTP/2ã®GOAWAYãã¬ã¼ã ãéåºãããããã«ãªãããªããã¯ã©ã¤ã¢ã³ãå´ã§ã¯åææã«GOAWAYã¨ã©ã¼ãçºçããããã«ãªã£ãã
ã¡ãªã¿ã«gRPCã®å ¬å¼ãªä»æ§ã¨ãã¦ãããµã¼ãå´ããæ示çã«ã³ãã¯ã·ã§ã³åãéã«ã¯GOAWAYãéããã¨ãããã¨ã«ãªã£ã¦ããããããã
grpc/PROTOCOL-HTTP2.md at master · grpc/grpc · GitHub
ãªã®ã§ããã®è¨å®ãå ¥ãããã¨ã«ãã£ã¦
ã3600ç§ã§åæã«NLBãã³ãã¯ã·ã§ã³ãåããã¯ã©ã¤ã¢ã³ãå´ã¯UNAVAILABLEã¨ã©ã¼ãåãåãã以éãã³ãã¯ã·ã§ã³ãè ã£ããããªç¶æ ã«ãªãã
ãã
ãä¸å®æéçµéã§æ示çã«GOAWAYãã¬ã¼ã ãéãããã¯ã©ã¤ã¢ã³ãå´ã¯GOAWAYã¨ã©ã¼ãåãåãã
ã«å¤ãã£ããã¨ã«ãªããå¾®å¦ãªéãã®ããã«è¦ããããäºæ ããã³ããªã³ã°ã§ãã¦ããã ãå¾è ã®æ¹ãã ãã¶ãã·ã§ããã
ã§ããã®ã¾ã¾ã ã¨æ°è¦ãªã¯ã¨ã¹ããéãéã«GOAWAYã¨ã©ã¼ãçºçãã¦ãã¾ããã¨ãããï¼æ示çã«GOAWAYéãè¨å®ã«ãããã ããå½ããåã ãã©ï¼ãã«ãã¼ããããã«ã¯ã©ã¤ã¢ã³ãå´ã§GOAWAYã®æã ããªãã©ã¤ãè¡ãããã«ãã¦è§£æ±ºãã¾ãããã¡ããã¡ããã
ããã¡ãªã¿ã«ã¯ã©ã¤ã¢ã³ãå´ã®è¨èªã¯Rubyã§ããã