ããã«ã¡ã¯ãSergey Elantsevã§ããYandex.Cloudã§ãããã¯ãŒã¯ããŒããã©ã³ãµãŒãéçºããŠããŸã ã 以åã¯ãYandexããŒã¿ã«ã®L7ãã©ã³ãµãŒã®éçºãçããŠããŸãããååã¯ãç§ãäœãããããšããã©ã³ãµãŒãæã«å ¥ãããšåè«ãèšã£ãŠããŸãã Habrã®èªè ã«ãã¯ã©ãŠããã©ãããã©ãŒã ã§ã®è² è·ã®ç®¡çæ¹æ³ããã®ç®æšãéæããããã®çæ³çãªããŒã«ã®èŠæ¹ããã®ããŒã«ã®æ§ç¯ã«åããŠã©ã®ããã«åããŠãããã説æããŸãã
æåã«ãããã€ãã®çšèªã玹ä»ããŸãã
- VIPïŒä»®æ³IPïŒ-ãã©ã³ãµãŒIPã¢ãã¬ã¹
- ãµãŒããŒãããã¯ãšã³ããã€ã³ã¹ã¿ã³ã¹-ã¢ããªã±ãŒã·ã§ã³ãå®è¡ãããŠããä»®æ³ãã·ã³
- RIPïŒå®IPïŒ-ãµãŒããŒIPã¢ãã¬ã¹
- ãã«ã¹ãã§ãã¯-ãµãŒããŒã®å¯çšæ§ãã§ãã¯
- ã¢ãªãŸãå·ã¢ãã€ã©ããªãã£ãŒãŸãŒã³-ããŒã¿ã»ã³ã¿ãŒã®åé¢ã€ã³ãã©ã¹ãã©ã¯ãã£
- å°å-ç°ãªãAZã®é£å
ããŒããã©ã³ãµãŒã¯ã3ã€ã®äž»ãªã¿ã¹ã¯ã解決ããŸããã€ãŸãããã©ã³ã·ã³ã°èªäœãå®è¡ãããµãŒãã¹ã®ãã©ãŒã«ããã¬ã©ã³ã¹ãåäžãããã¹ã±ãŒãªã³ã°ãç°¡çŽ åããŸãã èªåãã©ãã£ãã¯å¶åŸ¡ã«ããããã©ãŒã«ããã¬ã©ã³ã¹ã確ä¿ãããŸãããã©ã³ãµãŒã¯ã¢ããªã±ãŒã·ã§ã³ã®ç¶æ ãç£èŠãã皌åç¶æ ãã¹ãã«å€±æããã€ã³ã¹ã¿ã³ã¹ããã©ã³ã·ã³ã°ããé€å€ããŸãã ã€ã³ã¹ã¿ã³ã¹éã§è² è·ãåäžã«åæ£ããã€ã³ã¹ã¿ã³ã¹ã®ãªã¹ãããã®å Žã§æŽæ°ããããšã«ãããã¹ã±ãŒãªã³ã°ãä¿èšŒãããŸãã ãã©ã³ã·ã³ã°ãååã«åäžã§ãªãå Žåãã€ã³ã¹ã¿ã³ã¹ã®äžéšã¯ãäœæ¥å®¹éã®å¶éãè¶ ããè² è·ãååŸãããµãŒãã¹ã®ä¿¡é Œæ§ãäœäžããŸãã
ããŒããã©ã³ãµã¯ãå€ãã®å Žåãå®è¡ããOSIã¢ãã«ã®ãããã³ã«ã¬ãã«ã«ãã£ãŠåé¡ãããŸãã Cloud Balancerã¯ã4çªç®ã®ã¬ãã«ã§ããL4ã«å¯Ÿå¿ããTCPã¬ãã«ã§åäœããŸãã
ã¯ã©ãŠããã©ã³ãµãŒã¢ãŒããã¯ãã£ã®ã¬ãã¥ãŒã«ç§»ããŸãããã 詳现ã¬ãã«ãåŸã ã«äžããŠãããŸãã ãã©ã³ãµãŒã³ã³ããŒãã³ãã3ã€ã®ã¯ã©ã¹ã«åå²ããŸãã config planeã¯ã©ã¹ã¯ããŠãŒã¶ãŒãšã®å¯Ÿè©±ãæ åœããã·ã¹ãã ã®ã¿ãŒã²ããç¶æ ãä¿åããŸãã ã³ã³ãããŒã«ãã¬ãŒã³ã¯ãã·ã¹ãã ã®çŸåšã®ç¶æ ãä¿åããã¯ã©ã€ã¢ã³ãããã€ã³ã¹ã¿ã³ã¹ãžã®ãã©ãã£ãã¯ã®é ä¿¡ãçŽæ¥æ åœããããŒã¿ãã¬ãŒã³ã¯ã©ã¹ããã·ã¹ãã ã管çããŸãã
ããŒã¿ãã¬ãŒã³
ãã©ãã£ãã¯ã¯ãããŒããŒã«ãŒã¿ãŒãšåŒã°ããé«äŸ¡ãªããã€ã¹ã§çºçããŸãã ãã©ãŒã«ããã¬ã©ã³ã¹ãåäžãããããã«ããã®ãããªããã€ã¹ã®ããã€ãã¯1ã€ã®ããŒã¿ã»ã³ã¿ãŒã§åæã«åäœããŸãã ããã«ããã©ãã£ãã¯ã¯ãã©ã³ãµãŒã«å°éãããã©ã³ãµãŒã¯ã¯ã©ã€ã¢ã³ãçšã®BGPãä»ããŠãã¹ãŠã®AZã«ãšããŒãã£ã¹ãIPã¢ãã¬ã¹ãéç¥ããŸãã
ãã©ãã£ãã¯ã¯ECMPãä»ããŠéä¿¡ãããŸã-ããã¯ãå®å ãžã®åæ§ã«é©åãªã«ãŒããããã€ãããïŒãã®å Žåãå®å ã¯å®å IPã¢ãã¬ã¹ã«ãªããŸãïŒããã±ããããããã®ããããã«éä¿¡ã§ããã«ãŒãã£ã³ã°æŠç¥ã§ãã ãŸãã次ã®ã¹ããŒã ã«åŸã£ãŠãè€æ°ã®ã¢ã¯ã»ã¹ãŸãŒã³ã§ã®äœæ¥ããµããŒãããŸããåãŸãŒã³ã®ã¢ãã¬ã¹ãã¢ããŠã³ã¹ãããã©ãã£ãã¯ã¯æãè¿ããã®ã«åé¡ããããã§ã«ãããè¶ ããŠã¯ãªããŸããã ããã«æçš¿ã§ã¯ããã©ãã£ãã¯ã«äœãèµ·ãããããã詳ãã調ã¹ãŸãã
æ§æãã¬ãŒã³
æ§æãã¬ãŒã³ã®éèŠãªã³ã³ããŒãã³ãã¯ãã€ã³ã¹ã¿ã³ã¹ã®æ§æã®äœæãåé€ãå€æŽããã«ã¹ãã§ãã¯çµæã®ååŸãªã©ããã©ã³ãµãŒã䜿çšããåºæ¬æäœãå®è¡ããAPIã§ãã gRPCããããã£ãŠãRESTãgRPCã«ãå€æãããgRPCã®ã¿ã䜿çšããŸãã èŠæ±ã«ãããYandex.Cloudã¯ãŒã«ãŒã®å ±éããŒã«ã§å®è¡ãããäžé£ã®éåæiçã¿ã¹ã¯ãäœæãããŸãã ã¿ã¹ã¯ã¯ããã€ã§ãäžæåæ¢ããŠããåèµ·åã§ããããã«èšè¿°ãããŠããŸãã ããã«ãããã¹ã±ãŒã©ããªãã£ãåçŸæ§ãããã³ãã®ã³ã°æäœãæäŸãããŸãã
ãã®çµæãAPIããã®ã¿ã¹ã¯ã¯ãGoã§èšè¿°ããããã©ã³ãµãŒãµãŒãã¹ã³ã³ãããŒã©ãŒã«ãªã¯ãšã¹ããéä¿¡ããŸãã 圌ã¯ãã©ã³ãµãŒã®è¿œå ãšåé€ãããã¯ãšã³ããšèšå®ã®æ§æã®å€æŽãã§ããŸãã
ãµãŒãã¹ã¯ããã®ç¶æ ãYandexããŒã¿ããŒã¹ã«ä¿åããŸããããã¯ãããã«äœ¿çšã§ããåæ£ç®¡çããŒã¿ããŒã¹ã§ãã Yandex.Cloudã§ã¯ãæ¢ã«è¿°ã¹ãããã«ãããã°ããŒãã®æŠå¿µãæå¹ã«ãªã£ãŠããŸãããµãŒãã¹ãèªåã§äœ¿çšããã°ã顧客ãåãã§äœ¿çšã§ããŸãã Yandex Databaseã¯ããã®ãããªæŠå¿µã®å®è£ äŸã§ãã ãã¹ãŠã®ããŒã¿ãYDBã«ä¿åããŸããããŒã¿ããŒã¹ã®ä¿å®ãšã¹ã±ãŒãªã³ã°ã«ã€ããŠèããå¿ èŠã¯ãããŸããããããã®åé¡ã¯è§£æ±ºãããããŒã¿ããŒã¹ããµãŒãã¹ãšããŠäœ¿çšããŸãã
ãã©ã³ãµãŒã³ã³ãããŒã©ãŒã«æ»ããŸãã ãã®ã¿ã¹ã¯ã¯ããã©ã³ãµãŒã«é¢ããæ å ±ãä¿åããä»®æ³ãã·ã³ã®æºåç¶æ³ã確èªããã¿ã¹ã¯ããã«ã¹ãã§ãã¯ã³ã³ãããŒã©ãŒã«éä¿¡ããããšã§ãã
ãã«ã¹ãã§ãã¯ã³ã³ãããŒã©ãŒ
ã€ã³ã¹ãã¯ã·ã§ã³ã«ãŒã«ã®å€æŽèŠæ±ãåä¿¡ããYDBã«ä¿åããã¿ã¹ã¯ããã«ã¹ãã§ãã¯ããŒãã«é åžããŠçµæãéèšããŸããçµæã¯ããŒââã¿ããŒã¹ã«ä¿åãããããŒããã©ã³ãµãŒã³ã³ãããŒã©ãŒã«éä¿¡ãããŸãã 圌ã¯ãããŒã¿ãã¬ãŒã³å ã®ã¯ã©ã¹ã¿ãŒã®æ§æãloadbalancer-nodeã«å€æŽããèŠæ±ãéä¿¡ããŸããããã«ã€ããŠã¯ã以äžã§èª¬æããŸãã
ãã«ã¹ãã§ãã¯ã«ã€ããŠè©³ãã説æããŸãããã ãããã¯ããã€ãã®ã¯ã©ã¹ã«åããããšãã§ããŸãã ãã§ãã¯ã«ã¯ããŸããŸãªæååºæºããããŸãã TCPãã§ãã¯ã§ã¯ãäžå®æéå ã«æ¥ç¶ãæ£åžžã«ç¢ºç«ããå¿ èŠããããŸãã HTTPãã§ãã¯ã«ã¯ãæ¥ç¶ã®æåãšã¹ããŒã¿ã¹ã³ãŒã200ã®å¿çã®äž¡æ¹ãå¿ èŠã§ãã
ãŸãããã§ãã¯ã¯ã¢ã¯ã·ã§ã³ã®ã¯ã©ã¹ãç°ãªããŸã-ãããã¯ã¢ã¯ãã£ããšããã·ãã§ãã ããã·ããã§ãã¯ã¯ãç¹å¥ãªã¢ã¯ã·ã§ã³ãå®è¡ããã«ãã©ãã£ãã¯ã«äœãèµ·ããããåã«ç£èŠããŸãã ããã¯ãé«ã¬ãã«ã®ãããã³ã«ã®ããžãã¯ã«äŸåãããããL4ã§ã¯ããŸãæ©èœããŸãããL4ã§ã¯ãæäœã«ããã£ãæéãšæ¥ç¶ãè¯å¥œãäžè¯ãã«é¢ããæ å ±ã¯ãããŸããã ã¢ã¯ãã£ããã§ãã¯ã§ã¯ããã©ã³ãµãŒãåãµãŒããŒã€ã³ã¹ã¿ã³ã¹ã«ãªã¯ãšã¹ããéä¿¡ããå¿ èŠããããŸãã
ã»ãšãã©ã®ããŒããã©ã³ãµãŒã¯ãç¬èªã«æŽ»æ§ãã§ãã¯ãå®è¡ããŸãã Cloudã§ã¯ãã¹ã±ãŒã©ããªãã£ãé«ããããã«ã·ã¹ãã ã®ãããã®éšåãåé¢ããããšã«ããŸããã ãã®ã¢ãããŒãã«ããããµãŒãã¹ã«å¯Ÿãããã«ã¹ãã§ãã¯ãªã¯ãšã¹ãã®æ°ãç¶æããªããããã©ã³ãµãŒã®æ°ãå¢ããããšãã§ããŸãã ãã§ãã¯ã¯ããã¹ãã¿ãŒã²ããã®åå²ãšè€è£œã«äœ¿çšãããåå¥ã®ãã«ã¹ãã§ãã¯ããŒãã«ãã£ãŠå®è¡ãããŸãã 倱æããå¯èœæ§ãããããã1ã€ã®ãã¹ããããã§ãã¯ãè¡ãããšã¯ã§ããŸããã ãã®åŸã圌ããã§ãã¯ããã€ã³ã¹ã¿ã³ã¹ã®ã¹ããŒã¿ã¹ã¯ååŸããŸããã å°ãªããšã3ã€ã®ãã«ã¹ãã§ãã¯ããŒãããä»»æã®ã€ã³ã¹ã¿ã³ã¹ã®ãã§ãã¯ãå®è¡ããŸãã äžè²«ããããã·ã¥ã¢ã«ãŽãªãºã ã䜿çšããŠããŒãéã§åå²ãããã§ãã¯ã®ç®æšã
ãã©ã³ã¹ãšãã«ã¹ãã§ãã¯ã®åé¢ã¯ãåé¡ãåŒãèµ·ããå¯èœæ§ããããŸãã ãã«ã¹ãã§ãã¯ããŒããã€ã³ã¹ã¿ã³ã¹ã«ãªã¯ãšã¹ããè¡ãããã©ã³ãµãŒïŒçŸåšãã©ãã£ãã¯ãåŠçããŠããªãïŒããã€ãã¹ãããšãå¥åŠãªç¶æ³ãçºçããŸãããªãœãŒã¹ã¯çããŠããããã«èŠããŸããããã©ãã£ãã¯ã¯å°éããŸããã ãã®æ¹æ³ã§ãã®åé¡ã解決ããŸãããã©ã³ãµãŒãä»ããŠãã«ã¹ãã§ãã¯ãã©ãã£ãã¯ãéå§ããããšãä¿èšŒãããŠããŸãã èšãæãããšãã¯ã©ã€ã¢ã³ããšãã«ã¹ãã§ãã¯ããã®ãã©ãã£ãã¯ã§ãã±ããã移åããããã®ã¹ããŒã ã¯ãããã«ç°ãªããŸããã©ã¡ãã®å Žåãããã±ããã¯ãã©ã³ãµãŒã«éãããã¿ãŒã²ããã®ãªãœãŒã¹ã«é ä¿¡ãããŸãã
éãã¯ãã¯ã©ã€ã¢ã³ããVIPãèŠæ±ãããã«ã¹ãã§ãã¯ãåã ã®RIPãåç §ããããšã§ãã ããã§èå³æ·±ãåé¡ãçºçããŸãããŠãŒã¶ãŒã«ã°ã¬ãŒã®IPãããã¯ãŒã¯ã§ãªãœãŒã¹ãäœæããæ©äŒãæäŸããŸãã ãã©ã³ãµãŒã®ããã«ãµãŒãã¹ãé ãã2人ã®ç°ãªãã¯ã©ãŠãææè ããããšæ³åããŠãã ããã ãããã®ããããã¯ã10.0.0.1 / 24ãµããããã«åãã¢ãã¬ã¹ãæã€ãªãœãŒã¹ãæã£ãŠããŸãã äœããã®æ¹æ³ã§ããããåºå¥ã§ããå¿ èŠããããŸããããã§ã¯ãYandex.Cloudä»®æ³ãããã¯ãŒã¯ã®ããã€ã¹ã«é£ã³èŸŒãå¿ èŠããããŸãã 詳现ã«ã€ããŠã¯ã aboutïŒã¯ã©ãŠãã€ãã³ãã®ãããªãåç §ããŠãã ããããããã¯ãŒã¯ãå€å±€åããããµããããIDã§åºå¥ã§ãããã³ãã«ãããããšãéèŠã§ãã
ãã«ã¹ãã§ãã¯ããŒãã¯ãããããæºIPv6ã¢ãã¬ã¹ã䜿çšããŠãã©ã³ãµãŒã«ã¢ã¯ã»ã¹ããŸãã æºã¢ãã¬ã¹ã¯ãIPv4ã¢ãã¬ã¹ãšãŠãŒã¶ãŒãµããããIDãä¿è·ãããŠããIPv6ã¢ãã¬ã¹ã§ãã ãã©ãã£ãã¯ã¯ãã©ã³ãµãŒã«å°éãããããããªãœãŒã¹ã®IPv4ã¢ãã¬ã¹ãæœåºããIPv6ãIPv4ã«çœ®ãæãããŠãŒã¶ãŒã®ãããã¯ãŒã¯ã«ãã±ãããéä¿¡ããŸãã
éæ¹åã®ãã©ãã£ãã¯ãåæ§ã§ãããã©ã³ãµãŒã¯ãå®å ããã«ã¹ãã§ãã«ãŒããã®ã°ã¬ãŒãããã¯ãŒã¯ã§ããããšãèªèããIPv4ãIPv6ã«å€æããŸãã
VPP-ããŒã¿ãã¬ãŒã³ã®äžå¿
ãã©ã³ãµãŒã¯ããããã¯ãŒã¯ãã±ããã®ãã±ããåŠçã®ããã®ã·ã¹ã³ã®ãã¬ãŒã ã¯ãŒã¯ã§ããVector Packet ProcessingïŒVPPïŒã®ãã¯ãããžãŒã«å®è£ ãããŠããŸãã ãã®å Žåããã¬ãŒã ã¯ãŒã¯ã¯ããããã¯ãŒã¯ããã€ã¹ã®ãŠãŒã¶ãŒç©ºé管çã®ã©ã€ãã©ãªã§ããData Plane Development KitïŒDPDKïŒã®äžã§å®è¡ãããŸãã ããã«ãããé«ããã±ããåŠçããã©ãŒãã³ã¹ãæäŸãããŸããã«ãŒãã«ã®äžæãã¯ããã«å°ãªããªããã«ãŒãã«ç©ºéãšãŠãŒã¶ãŒç©ºéã®éã§ã³ã³ããã¹ããåãæ¿ãããŸããã
VPPã¯ããã«é²ãã§ãããã±ãŒãžããããã«çµåããããšã§ã·ã¹ãã ã®ããã©ãŒãã³ã¹ãããã«çµã蟌ã¿ãŸãã çç£æ§ã®åäžã¯ãææ°ã®ããã»ããµã®ãã£ãã·ã¥ã®ç©æ¥µçãªäœ¿çšã«ãããã®ã§ãã äž¡æ¹ã®ããŒã¿ãã£ãã·ã¥ã䜿çšããïŒãã±ããã¯ããã¯ãã«ãã«ãã£ãŠåŠçãããããŒã¿ã¯äºãã«è¿æ¥ããŠããŸãïŒãåœä»€ãã£ãã·ã¥ïŒVPPã§ã¯ããã±ããåŠçã¯ããŒãã«1ã€ã®ã¿ã¹ã¯ãå®è¡ããæ©èœãå«ãã°ã©ãã«åŸããŸãã
ããšãã°ãVPPã§ã®IPãã±ããã®åŠçã¯æ¬¡ã®é åºã§é²ã¿ãŸããæåã«ã解æããŒãã§ãã±ããããããŒã解æããã次ã«ããŒãã«éä¿¡ãããŸããããŒãã¯ã«ãŒãã£ã³ã°ããŒãã«ã«åŸã£ãŠãã±ãããããã«è»¢éããŸãã
ã¡ãã£ãšããŒãã³ã¢ã VPPã®äœæè ã¯ããã»ããµãã£ãã·ã¥ã®äœ¿çšã«ã€ããŠåŠ¥åããŸããããããã£ãŠãäžè¬çãªããã±ãŒãžãã¯ãã«åŠçã³ãŒãã«ã¯æåã®ãã¯ãã«åãå«ãŸããŸããããã¥ãŒã«4ã€ã®ãã±ãããããããªã©ã®ç¶æ³ãåŠçããããã®åŸ2ã€ãåãã§ããåŠçãµã€ã¯ã«ããã- 1ã€ã å€ãã®å Žåã次ã®å埩ã§ããŒã¿ãžã®ã¢ã¯ã»ã¹ãé«éåããããã«ããŒã¿ããã£ãã·ã¥ã«ããŒãããããªãã§ããåœä»€ã䜿çšãããŸãã
n_left_from = frame->n_vectors; while (n_left_from > 0) { vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); // ... while (n_left_from >= 4 && n_left_to_next >= 2) { // processing multiple packets at once u32 next0 = SAMPLE_NEXT_INTERFACE_OUTPUT; u32 next1 = SAMPLE_NEXT_INTERFACE_OUTPUT; // ... /* Prefetch next iteration. */ { vlib_buffer_t *p2, *p3; p2 = vlib_get_buffer (vm, from[2]); p3 = vlib_get_buffer (vm, from[3]); vlib_prefetch_buffer_header (p2, LOAD); vlib_prefetch_buffer_header (p3, LOAD); CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE); CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE); } // actually process data /* verify speculative enqueues, maybe switch current next frame */ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, n_left_to_next, bi0, bi1, next0, next1); } while (n_left_from > 0 && n_left_to_next > 0) { // processing packets by one } // processed batch vlib_put_next_frame (vm, node, next_index, n_left_to_next); }
ãã®ããããã«ã¹ãã§ãã¯ã¯IPv6ãVPPã«å€æããããã«ããIPv4ã«å€æãããŸãã ããã¯ãã¢ã«ãŽãªãºã NATãšåŒã°ããã°ã©ãããŒãã«ãã£ãŠè¡ãããŸãã éæ¹åãã©ãã£ãã¯ïŒããã³IPv6ããIPv4ãžã®å€æïŒã«ã¯ãã¢ã«ãŽãªãºã NATã®åãããŒãããããŸãã
ãã©ã³ãµã¯ã©ã€ã¢ã³ãããã®çŽæ¥ãã©ãã£ãã¯ã¯ãã°ã©ãã®ããŒããééããã°ã©ãèªäœããã©ã³ã·ã³ã°ãå®è¡ããŸãã
æåã®ããŒãã¯ã¹ãã£ãããŒã»ãã·ã§ã³ã§ãã 確ç«ãããã»ãã·ã§ã³ã®5ã¿ãã«ããã·ã¥ãä¿åããŸãã 5ã¿ãã«ã«ã¯ãæ å ±ã®éä¿¡å ã®ã¯ã©ã€ã¢ã³ãã®ã¢ãã¬ã¹ãšããŒãããã©ãã£ãã¯ã®åä¿¡ã«äœ¿çšå¯èœãªãªãœãŒã¹ã®ã¢ãã¬ã¹ãšããŒããããã³ãããã¯ãŒã¯ãããã³ã«ãå«ãŸããŸãã
5ã¿ãã«ããã·ã¥ã¯ãåŸç¶ã®äžè²«æ§ã®ããããã·ã¥ããŒãã§ã®èšç®ãæžããããã©ã³ãµãŒã®èåŸã«ãããªãœãŒã¹ã®ãªã¹ãã®å€æŽãããé©åã«åŠçããã®ã«åœ¹ç«ã¡ãŸãã ãã±ãããã»ãã·ã§ã³ã®ãªããã©ã³ãµãŒã«å°çãããšããã±ããã¯äžè²«ããããã·ã¥ããŒãã«éä¿¡ãããŸãã ããã¯ãäžè²«ããããã·ã¥ã䜿çšããŠãã©ã³ã·ã³ã°ãçºçããå Žæã§ããå©çšå¯èœãªãã©ã€ãããªãœãŒã¹ã®ãªã¹ããããªãœãŒã¹ãéžæããŸãã ãã®åŸããã±ããã¯NATããŒãã«éä¿¡ãããŸããNATããŒãã¯å®éã«å®å ã¢ãã¬ã¹ã眮ãæãããã§ãã¯ãµã ãåèšç®ããŸãã ã芧ã®ããã«ãVPPã®ã«ãŒã«ã«åŸããŸã-ããã»ããµãã£ãã·ã¥ã®å¹çãé«ããããã«ãåæ§ã®ã°ã«ãŒãåãããåæ§ã®èšç®ã«äŒŒãŠããŸãã
äžè²«ããããã·ã¥
ãªãç§ãã¡ã¯ãããéžãã ã®ã§ããïŒ ãŸããåã®ã¿ã¹ã¯ãã€ãŸããªã¹ããããªãœãŒã¹ãéžæããããšãæ€èšããŠãã ããã
äžè²«æ§ã®ãªãããã·ã¥ã§ã¯ãçä¿¡ãã±ããããã®ããã·ã¥ãèšç®ããããã®ããã·ã¥ããªãœãŒã¹ã®æ°ã§å²ã£ãäœãã«ãã£ãŠãªãœãŒã¹ããªã¹ãããéžæãããŸãã ãªã¹ããå€æŽãããªãéãããã®ãããªã¹ããŒã ã¯ããŸãæ©èœããŸããåžžã«åãã€ã³ã¹ã¿ã³ã¹ã«åã5ã¿ãã«ã®ãã±ãããéä¿¡ããŸãã ããšãã°ãäžéšã®ãªãœãŒã¹ããã«ã¹ãã§ãã¯ãžã®å¿çãåæ¢ããå Žåãããã·ã¥ã®ããªãã®éšåã§éžæãå€æŽãããŸãã TCPæ¥ç¶ã¯ã¯ã©ã€ã¢ã³ãã§åæãããŸãã以åã«ã€ã³ã¹ã¿ã³ã¹Aã«éããããã±ããã¯ããã®ãã±ããã®ã»ãã·ã§ã³ã«æ £ããŠããªãã€ã³ã¹ã¿ã³ã¹Bã«èœã¡ãå¯èœæ§ããããŸãã
äžè²«æ§ã®ããããã·ã¥ã¯ã説æãããŠããåé¡ã解決ããŸãã ãã®æŠå¿µã説æããæãç°¡åãªæ¹æ³ã¯æ¬¡ã®ãšããã§ãããªãœãŒã¹ãããã·ã¥ïŒIPïŒããŒããªã©ïŒã§å²ãåœãŠããªã³ã°ããããšããŸãã ãªãœãŒã¹ã®éžæã¯ããã±ããã®ããã·ã¥ã«ãã£ãŠæ±ºå®ãããè§åºŠã«ãããã€ãŒã«ã®å転ã§ãã
ããã«ããããªãœãŒã¹ã®æ§æãå€æŽããéã®ãã©ãã£ãã¯ã®ååé ãæå°éã«æããããŸãã ãªãœãŒã¹ãåé€ãããšããªãœãŒã¹ãé 眮ãããäžè²«æ§ã®ããããã·ã¥ãªã³ã°ã®éšåã®ã¿ã«åœ±é¿ããŸãã ãªãœãŒã¹ãè¿œå ãããšãã£ã¹ããªãã¥ãŒã·ã§ã³ãå€æŽãããŸããããã§ã«ç¢ºç«ãããŠããã»ãã·ã§ã³ãæ°ãããªãœãŒã¹ã«åãæ¿ããªãããã«ããã¹ãã£ãããŒã»ãã·ã§ã³ããŒãããããŸãã
ãã©ã³ãµãŒãšãªãœãŒã¹éã®çŽæ¥ãã©ãã£ãã¯ã§äœãèµ·ãããã調ã¹ãŸããã 次ã«ãéãã©ãã£ãã¯ã«å¯ŸåŠããŸãããã æ€èšŒãã©ãã£ãã¯ãšåããã¿ãŒã³ã«åŸããŸããã¢ã«ãŽãªãºã NATã䜿çšããŸããã€ãŸããã¯ã©ã€ã¢ã³ããã©ãã£ãã¯ã®å Žåã¯ãªããŒã¹NAT 44ã䜿çšãããã«ã¹ãã§ãã¯ãã©ãã£ãã¯ã®å Žåã¯NAT 46ã䜿çšããŸãã ç§ãã¡ã¯ç¬èªã®ã¹ããŒã ãé å®ããŠããŸãããã«ã¹ãã§ãã¯ãã©ãã£ãã¯ãšå®éã®ãŠãŒã¶ãŒãã©ãã£ãã¯ãçµ±åããŸãã
ããŒããã©ã³ãµãŒããŒããšã³ã³ããŒãã³ãã®ã¢ã»ã³ããª
VPPã®ãã©ã³ãµãŒãšãªãœãŒã¹ã®æ§æã¯ãããŒã«ã«ãµãŒãã¹-loadbalancer-nodeã«ãã£ãŠå ±åãããŸãã 圌ã¯ãããŒããã©ã³ãµãŒã³ã³ãããŒã©ãŒããã®ã€ãã³ãã®ãããŒã«ãµãã¹ã¯ã©ã€ãããVPPã®çŸåšã®ç¶æ ãšã³ã³ãããŒã©ãŒããåä¿¡ããã¿ãŒã²ããç¶æ ãšã®å·®ãæ§ç¯ããããšãã§ããŸãã éããããã·ã¹ãã ãååŸããŸããAPIããã®ã€ãã³ãããã©ã³ãµãŒã³ã³ãããŒã©ãŒã«éããããã©ã³ãµãŒã³ã³ãããŒã©ãŒããã«ã¹ãã§ãã¯ã³ã³ãããŒã©ãŒã¿ã¹ã¯ãèšå®ããŠããªãœãŒã¹ã®ã掻æ§ãããã§ãã¯ããŸãã 次ã«ãhealthcheck-nodeã«ã¿ã¹ã¯ãèšå®ããŠçµæãéèšãããã®åŸããããããã©ã³ãµãŒã³ã³ãããŒã©ãŒã«éãè¿ããŸãã loadbalancer-nodeã¯ã³ã³ãããŒã©ãŒããã®ã€ãã³ãããµãã¹ã¯ã©ã€ãããVPPã®ç¶æ ãå€æŽããŸãã ãã®ãããªã·ã¹ãã ã§ã¯ãåãµãŒãã¹ã¯ãé£æ¥ãããµãŒãã¹ã«ã€ããŠå¿ èŠãªãã®ã®ã¿ãç¥ã£ãŠããŸãã æ¥ç¶ã®æ°ã¯éãããŠãããããããŸããŸãªã»ã°ã¡ã³ããç¬èªã«æŽ»çšããŠã¹ã±ãŒãªã³ã°ããæ©äŒããããŸãã
åé¿ããã質å
ã³ã³ãããŒã«ãã¬ãŒã³ã®ãã¹ãŠã®ãµãŒãã¹ã¯Goã§èšè¿°ãããŠãããåªããã¹ã±ãŒãªã³ã°æ©èœãšä¿¡é Œæ§æ©èœãåããŠããŸãã Goã«ã¯ãåæ£ã·ã¹ãã ãæ§ç¯ããããã®å€ãã®ãªãŒãã³ãœãŒã¹ã©ã€ãã©ãªããããŸãã ç§ãã¡ã¯ç©æ¥µçã«GRPCã䜿çšãããã¹ãŠã®ã³ã³ããŒãã³ãã«ã¯ãµãŒãã¹ãã£ã¹ã«ããªãŒã®ãªãŒãã³ãœãŒã¹å®è£ ãå«ãŸããŠããŸãããµãŒãã¹ã¯äºãã®ããã©ãŒãã³ã¹ãç£èŠããæ§æãåçã«å€æŽã§ããGRPCãã©ã³ã·ã³ã°ãšçµã³ä»ããŸãã ã¡ããªãã¯ã«ã€ããŠã¯ããªãŒãã³ãœãŒã¹ãœãªã¥ãŒã·ã§ã³ã䜿çšããŸãã ããŒã¿ãã¬ãŒã³ã§ã¯ããŸãšããªããã©ãŒãã³ã¹ãšå€§éã®ãªãœãŒã¹ã確ä¿ãããŠããŸããéã®ãããã¯ãŒã¯ã«ãŒãã§ã¯ãªããVPPã®ããã©ãŒãã³ã¹ã«äŸåã§ããã¹ã¿ã³ããçµã¿ç«ãŠãããšã¯éåžžã«å°é£ã§ããããšãããããŸããã
åé¡ãšè§£æ±ºç
ããŸããããªãã£ãã®ã¯äœã§ããïŒ Goã§ã¯ãã¡ã¢ãªç®¡çã¯èªåã§ãããã¡ã¢ãªãªãŒã¯ã¯ãŸã ãããŸãã ãããã«å¯ŸåŠããæãç°¡åãªæ¹æ³ã¯ããŽã«ãŒãã³ãèµ·åããããããå®äºããããšãå¿ããªãããšã§ãã çµè«ïŒGoããã°ã©ã ã®ã¡ã¢ãªæ¶è²»ãç£èŠããŸãã å€ãã®å Žåãè¯ãææšã¯ãŽã«ãŒãã³ã®éã§ãã ãã®ã¹ããŒãªãŒã«ã¯ãã©ã¹ããããŸããGoã§ã¯ãå®è¡æãã¡ã¢ãªæ¶è²»ãèµ·åããããŽã«ãŒãã³ã®æ°ãããã³ä»ã®å€ãã®ãã©ã¡ãŒã¿ãŒã§ããŒã¿ãç°¡åã«ååŸã§ããŸãã
ããã«ãGoã¯æ©èœãã¹ãã«æé©ãªéžæè¢ã§ã¯ãªãå ŽåããããŸãã ãããã¯éåžžã«åé·ã§ãããæšæºã®ãCIããã±ãŒãžã§ãã¹ãŠãå®è¡ãããã¢ãããŒãã¯ããŸãé©ããŠããŸããã å®éã®ãšãããæ©èœãã¹ãã¯ãªãœãŒã¹ã«å¯ŸããŠããå€ãã®è² è·ãããããããå®éã®ã¿ã€ã ã¢ãŠããçºçããŸãã ãã®ããããŠããããã¹ãã§CPUãããžãŒã§ããããããã¹ãã倱æããå ŽåããããŸãã çµè«ïŒå¯èœã§ããã°ãåäœãã¹ããšã¯å¥ã«ãéãããã¹ããå®è¡ããŸãã
ãã€ã¯ããµãŒãã¹ã€ãã³ãã¢ãŒããã¯ãã£ã¯ãã¢ããªã¹ãããè€éã§ããæ°åã®ç°ãªããã·ã³ã§ãã°ãååŸããã®ã¯ãããŸã䟿å©ã§ã¯ãããŸããã çµè«ïŒãã€ã¯ããµãŒãã¹ãå®è¡ããŠããå Žåã¯ãããã«ãã¬ãŒã¹ãæ€èšããŠãã ããã
ç§ãã¡ã®èšç»
å éšãã©ã³ãµãŒã§ããIPv6-balancerãèµ·åããKubernetesã¹ã¯ãªãããµããŒããè¿œå ãããµãŒãã¹ã®ã·ã£ãŒããç¶è¡ãïŒçŸåšã¯healthcheck-nodeãšhealthcheck-ctrlã®ã¿ãã·ã§ãŒãã£ã³ã°ãããŠããŸãïŒãæ°ãããã«ã¹ãã§ãã¯ãè¿œå ããã¹ããŒããã§ãã¯éçŽãå®è£ ããŸãã ãµãŒãã¹ãããã«ç¬ç«ãããå¯èœæ§ãæ€èšããŠããŸããã€ãŸãããµãŒãã¹ã¯äºãã«çŽæ¥éä¿¡ããã®ã§ã¯ãªããã¡ãã»ãŒãžãã¥ãŒã䜿çšããŠéä¿¡ããŸãã SQSäºæã®Yandex Message QueueãµãŒãã¹ãæè¿ã¯ã©ãŠãã«ç»å ŽããŸããã
æè¿ãYandex Load Balancerãå ¬éãããŸããã ãµãŒãã¹ã®ããã¥ã¡ã³ãã調ã¹ãããªãã«ãšã£ãŠäŸ¿å©ãªæ¹æ³ã§ãã©ã³ãµãŒã管çãããããžã§ã¯ãã®èé害æ§ãé«ããŠãã ããïŒ