è² è·èšç»ã®åé¡ã¯ãWebãããžã§ã¯ãã®éçºã®åæ段éã§æ±ºå®ããå¿ èŠããããŸãã ãµãŒããŒã®ãã¯ã©ãã·ã¥ãïŒãããŠãããã¯åžžã«æãäžé©åœãªç¬éã«äºæããã«çºçããŸãïŒã¯ãéåžžã«æ·±å»ãªçµæ-é埳ãšç©è³ªã®äž¡æ¹ã§ããµããŠããŸãã æåã¯ããµãŒããŒã®å®¹éãå¢ãããã䜿çšããã¢ã«ãŽãªãºã ãããã°ã©ã ã³ãŒããªã©ãæé©åããããšã«ãããã¯ãŒã¯ããŒãã®å¢å ã«ãããµãŒããŒã®ããã©ãŒãã³ã¹äžè¶³ã®åé¡ã解決ã§ããŸãã ããããé ããæ©ããããããã®å¯Ÿçãäžååã«ãªãç¬éãæ¥ãŸãã
ã¯ã©ã¹ã¿ãªã³ã°ã«é Œããªããã°ãªããŸãããè€æ°ã®ãµãŒããŒãã¯ã©ã¹ã¿ãŒã«çµåãããŸãã ãããã®éã®è² è·ã¯ããã©ã³ã·ã³ã°ãšåŒã°ããäžé£ã®ç¹å¥ãªæ¹æ³ã䜿çšããŠåæ£ãããŸãã é«ãã¯ãŒã¯ããŒãã®åé¡ã解決ããããšã«å ããŠãã¯ã©ã¹ã¿ãªã³ã°ã¯ãµãŒããŒã®çžäºåé·æ§ã確ä¿ããã®ã«ã圹ç«ã¡ãŸãã
ã¯ã©ã¹ã¿ãªã³ã°ã®å¹çã¯ãã¯ã©ã¹ã¿ãŒã®èŠçŽ éã§è² è·ãã©ã®ããã«åæ£ïŒãã©ã³ã¹ïŒããããã«çŽæ¥äŸåããŸãã
è² è·åæ£ã¯ãããŒããŠã§ã¢ããŒã«ãšãœãããŠã§ã¢ããŒã«ã®äž¡æ¹ã䜿çšããŠå®è¡ã§ããŸãã ãã®èšäºã§ã¯ãäž»ãªæ¹æ³ãšã¢ã«ãŽãªãºã ãããã³ãã©ã³ã¹ã«ã€ããŠèª¬æããŸãã
ãã©ã³ã¹ã¬ãã«
ãã©ã³ã·ã³ã°æé ã¯ãOSIã¢ãã«ã®ä»¥äžã®ã¬ãã«ã«å¯Ÿå¿ããã¢ã«ãŽãªãºã ãšæ¹æ³ã®å šç¯å²ã䜿çšããŠå®è¡ãããŸãã
- ãããã¯ãŒã¯;
- 茞é;
- é©çšãããŸãã
ãããã®ã¬ãã«ããã詳现ã«æ€èšããŠãã ããã
ãããã¯ãŒã¯ãã©ã³ã·ã³ã°
ãããã¯ãŒã¯ã¬ãã«ã§ã®åæ£ã«ã¯ã次ã®åé¡ã®è§£æ±ºãå«ãŸããŸããç°ãªãç©çãã·ã³ããµãŒããŒã®1ã€ã®ç¹å®ã®IPã¢ãã¬ã¹ãæ åœããŠããããšã確èªããå¿ èŠããããŸãã ãã®ãããªãã©ã³ã¹ã¯ãããŸããŸãªæ¹æ³ã䜿çšããŠå®çŸã§ããŸãã
- DNSãã©ã³ã·ã³ã°ã ãã¡ã€ã³åããšã«è€æ°ã®IPã¢ãã¬ã¹ãå²ãåœãŠãããŸãã ã¯ã©ã€ã¢ã³ãèŠæ±ã®éä¿¡å ã®ãµãŒããŒã¯éåžžãã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã䜿çšããŠæ±ºå®ãããŸãïŒä»¥äžã§ãã©ã³ã¹æ¹æ³ãšã¢ã«ãŽãªãºã ã«ã€ããŠè©³ãã説æããŸãïŒã
- NLBã¯ã©ã¹ã¿ãŒã®æ§ç¯ã ãã®æ¹æ³ã䜿çšããå ŽåããµãŒããŒã¯å ¥åããŒããšèšç®ããŒãã§æ§æãããã¯ã©ã¹ã¿ãŒã«çµåãããŸãã è² è·åæ£ã¯ãç¹å¥ãªã¢ã«ãŽãªãºã ã䜿çšããŠå®è¡ãããŸãã Microsoftã®ãœãªã¥ãŒã·ã§ã³ã§äœ¿çšãããŸãã
- ãªãã·ã§ã³ã®ã«ãŒã¿ãŒã䜿çšããIPãã©ã³ã·ã³ã°ã
- é åã®åè¡¡å㯠ãã€ã³ã¿ãŒãããã®å°ççã«ç°ãªãå°åã«åãã¢ãã¬ã¹ãæã€åããµãŒãã¹ãé 眮ããããšã«ãã£ãŠå®è¡ãããŸãïŒããã¯ã ãã§ã«èª¬æãããšããŒãã£ã¹ãDNSãã¯ãããžãŒã®æ¹æ³ã§ã ïŒã ããªããªãã©ã³ã¹ã¯ãå€ãã®CDNã§ã䜿çšãããŠããŸãïŒ èå³æ·±ãå®è£ äŸãåç §ïŒã
ãã©ã³ã¹ããŒãã¬ããªã³ã°
ãã®ã¿ã€ãã®ãã©ã³ã·ã³ã°ã¯æãç°¡åã§ããã¯ã©ã€ã¢ã³ãã¯ãã©ã³ãµãŒã«é£çµ¡ãããã©ã³ãµãŒã¯ãªã¯ãšã¹ãããµãŒããŒã®1ã€ã«ãªãã€ã¬ã¯ããããµãŒããŒã¯ãããåŠçããŸãã ãªã¯ãšã¹ããåŠçãããµãŒããŒã®éžæã¯ãããŸããŸãªã¢ã«ãŽãªãºã ã«åŸã£ãŠå®è¡ã§ããŸãïŒä»¥äžã§è©³ãã説æããŸãïŒïŒåçŽãªã©ãŠã³ãããã³æ€çŽ¢ãããŒã«ããæãè² è·ã®å°ãªããµãŒããŒã®éžæãªã©ã
ãã©ã³ã¹ããŒãã¬ãã«ã§ã®ãã©ã³ã·ã³ã°ã¯ããããã¯ãŒã¯ã¬ãã«ã§ã®ãã©ã³ã·ã³ã°ãšåºå¥ããããšãé£ããå ŽåããããŸãã BSDã·ã¹ãã ã®pfãããã¯ãŒã¯ãã£ã«ã¿ãŒã«é¢ãã次ã®ã«ãŒã«ãèæ ®ããŠãã ãããããšãã°ãæ£åŒã«ã¯ç¹å®ã®TCPããŒãã§ã®ãã©ãã£ãã¯ã®åæ£ã«ã€ããŠèª¬æããŠããŸãïŒBSDã·ã¹ãã ã®pfãããã¯ãŒã¯ãã£ã«ã¿ãŒã®äŸïŒã
web_servers = "{10.0.0.10ã10.0.0.11ã10.0.0.13}" $ ext_if proto tcpã§ããŒã80ã«äžèŽrdr-to $ web_serversã©ãŠã³ãããã³ã¹ãã£ãããŒã¢ãã¬ã¹
ç¹å®ã®TCPããŒãã§ãã©ãã£ãã¯ã®ãã©ã³ã¹ãåãããšã§ãã
次ã«ãå¥ã®äŸãèããŸãã
$ lan_netãã$ int_ifãæž¡ããŸã\ route-to {ïŒ$ ext_if1 $ ext_gw1ïŒãïŒ$ ext_if2 $ ext_gw2ïŒ} \ ã©ãŠã³ãããã³
ãã®ã«ãŒã«ã¯ããããã¯ãŒã¯ã¬ãã«ã§ã®çºä¿¡ãã©ãã£ãã¯ã®ãã©ã³ã¹ãåããŸãã ç¹å®ã®ããŒããŸãã¯ç¹å®ã®ãããã³ã«ã瀺ããã®ã§ã¯ãããŸããã
ãã©ã³ã¹èª¿æŽã¬ãã«ã®éãã¯ã次ã®ããã«èª¬æã§ããŸãã ãããã¯ãŒã¯å±€ã«ã¯ããŠãŒã¶ãŒã»ãã·ã§ã³ãçµäºããªããœãªã¥ãŒã·ã§ã³ãå«ãŸããŠããŸãã ãã©ãã£ãã¯ããªãã€ã¬ã¯ãããã ãã§ããããã·ã¢ãŒãã§ã¯æ©èœããŸããã
ãããã¯ãŒã¯ã¬ãã«ã§ã¯ããã©ã³ãµãŒã¯åã«ãã±ãããéä¿¡ãããµãŒããŒã決å®ããŸãã ã¯ã©ã€ã¢ã³ããšã®ã»ãã·ã§ã³ã¯ãµãŒããŒã«ãã£ãŠå®è¡ãããŸãã
ãã©ã³ã¹ããŒãã¬ãã«ã§ã¯ãã¯ã©ã€ã¢ã³ããšã®éä¿¡ã¯ãã©ã³ãµãŒäžã§éãããããã©ã³ãµãŒã¯ãããã·ãšããŠæ©èœããŸãã ããã«ä»£ãã£ãŠãµãŒããŒãšå¯Ÿè©±ããè¿œå ã®ããŒã¿ãšããããŒã§ã¯ã©ã€ã¢ã³ãã«é¢ããæ å ±ãæž¡ããŸãã ãããã£ãŠãããšãã°ã人æ°ã®ããHAProxyãœãããŠã§ã¢ãã©ã³ãµãŒãæ©èœããŸãã
ã¢ããªã±ãŒã·ã§ã³ã¬ãã«ã®ãã©ã³ã¹
ã¢ããªã±ãŒã·ã§ã³ã¬ãã«ã§ãã©ã³ã¹ãåãå Žåããã©ã³ãµãŒã¯ãã¹ããŒããããã·ãã¢ãŒãã§åäœããŸãã ã¯ã©ã€ã¢ã³ãã®ãªã¯ãšã¹ããåæãããªã¯ãšã¹ããããã³ã³ãã³ãã®æ§è³ªã«å¿ããŠãããããç°ãªããµãŒããŒã«ãªãã€ã¬ã¯ãããŸãã ããã¯ãããšãã°ãããã³ããšã³ããšããã¯ãšã³ãã®éã§ãªã¯ãšã¹ããåæ£ãããªã©ãNginx WebãµãŒããŒã®ä»çµã¿ã§ãã Nginxã§ã®ãã©ã³ã¹èª¿æŽã«ã¯ãã¢ããã¹ããªãŒã ã¢ãžã¥ãŒã«ã責任ãè² ããŸãã ããŸããŸãªã¢ã«ãŽãªãºã ã«åºã¥ããNginxãã©ã³ã·ã³ã°ã®æ©èœã®è©³çŽ°ã«ã€ããŠã¯ã ãã¡ããã芧ãã ãã ã
ã¢ããªã±ãŒã·ã§ã³ã¬ãã«ã®ãã©ã³ã·ã³ã°ããŒã«ã®ãã1ã€ã®äŸã¯ãã¯ã©ã€ã¢ã³ããšPostgreSQLããŒã¿ããŒã¹ãµãŒããŒéã®äžéå±€ã§ããpgpoolã§ãã ããã䜿çšãããšãã³ã³ãã³ãã«å¿ããŠããŒã¿ããŒã¹ãµãŒããŒã«ã¯ãšãªãé åžã§ããŸããããšãã°ãèªã¿åãèŠæ±ã¯1ã€ã®ãµãŒããŒã«éä¿¡ãããæžã蟌ã¿èŠæ±ã¯å¥ã®ãµãŒããŒã«éä¿¡ãããŸãã ãã®èšäºã§pgpoolãšããã䜿ã£ãäœæ¥ã®è©³çŽ°ã«ã€ããŠèªãã§ãã ããã
ã¢ã«ãŽãªãºã ãšãã©ã³ã¹æ¹æ³
ããŸããŸãªè² è·åæ£ã¢ã«ãŽãªãºã ãšæ¹æ³ããããŸãã ç¹å®ã®ã¢ã«ãŽãªãºã ãéžæããã«ã¯ããŸãç¹å®ã®ãããžã§ã¯ãã®è©³çŽ°ããã次ã«ç®æšããé²ããå¿ èŠããããŸãã ãããéæããäºå®ã§ãã
ãã©ã³ã·ã³ã°ã䜿çšãããç®æšã®äžã§ã次ã®ç¹ã匷調ããå¿ èŠããããŸãã
- å ¬å¹³æ§ ïŒåãªã¯ãšã¹ãã®åŠçã«ã·ã¹ãã ãªãœãŒã¹ãå²ãåœãŠãããããšãä¿èšŒãã1ã€ã®ãªã¯ãšã¹ããåŠçãããä»ã®ãã¹ãŠã®ãªã¯ãšã¹ããé çªã«åŸ æ©ããç¶æ³ãé²ãããšãå¿ èŠã§ãã
- å¹çæ§ ïŒèŠæ±ãåŠçãããã¹ãŠã®ãµãŒããŒã¯100ïŒ ããžãŒã§ããå¿ èŠããããŸãã ãµãŒããŒã®1ã€ããªã¯ãšã¹ãã®åŠçãåŸ æ©ããŠããã¢ã€ãã«ç¶æ ãèš±å¯ããªãããšããå§ãããŸãïŒå®éã«ã¯ããã®ç®æšãåžžã«éæããããšã¯éããªãäºçŽãããã«è¡ããŸãïŒã
- ã¯ãšãªã®å®è¡æéã®ççž® ïŒèŠæ±ã®åŠçã®éå§ïŒãŸãã¯åŠçã®ããã«ãã¥ãŒã«å ¥ããïŒããå®äºãŸã§ã®æå°æéã確ä¿ããå¿ èŠããããŸãã
- å¿çæéã®ççž® ïŒãŠãŒã¶ãŒèŠæ±ã«å¯Ÿããå¿çæéãæå°éã«æããå¿ èŠããããŸãã
ãŸãããã©ã³ã·ã³ã°ã¢ã«ãŽãªãºã ã«ã¯æ¬¡ã®ç¹æ§ãããããšãéåžžã«æãŸããã§ãã
- äºæž¬å¯èœæ§ ïŒã¢ã«ãŽãªãºã ãã¿ã¹ã¯ã解決ããã®ã«å¹æçã§ããç¶æ³ãšè² è·ãæ確ã«ç解ããå¿ èŠããããŸãã
- ã·ã¹ãã ãªãœãŒã¹ã®åäžãªããŒã ã
- ã¹ã±ãŒã©ããªã㣠ïŒã¢ã«ãŽãªãºã ã¯è² è·ãå¢å ããŠãåäœãç¶ããå¿ èŠããããŸãã
ã©ãŠã³ãããã³
ã©ãŠã³ãããã³ããŸãã¯ã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã¯ã©ãŠã³ãããã³æ€çŽ¢ã§ããæåã®èŠæ±ã1ã€ã®ãµãŒããŒã«éä¿¡ããã次ã«æ¬¡ã®èŠæ±ãå¥ã®ãµãŒããŒã«éä¿¡ãããæåŸã®ãµãŒããŒã«å°éãããŸã§ç¶ããŸãã
ãã®ã¢ã«ãŽãªãºã ã®æãäžè¬çãªå®è£ ã¯ããã¡ãããã©ãŠã³ãããã³DNSãã©ã³ã·ã³ã°æ¹åŒã§ãã ãåç¥ã®ããã«ãDNSãµãŒããŒã«ã¯ãç¹å®ã®ãã¡ã€ã³ã®åãã·ã³ã®ããã¹ãå-IPã¢ãã¬ã¹ãã®ãã¢ãä¿åãããŠããŸãã ãã®ãªã¹ãã¯æ¬¡ã®ããã«ãªããŸãã
example.com xxx.xxx.xxx.2 www.example.com xxx.xxx.xxx.3
ãªã¹ãå ã®åååã«è€æ°ã®IPã¢ãã¬ã¹ãé¢é£ä»ããããšãã§ããŸãã
example.com xxx.xxx.xxx.2 www.example.com xxx.xxx.xxx.3 www.example.com xxx.xxx.xxx.4 www.example.com xxx.xxx.xxx.5 www.example.com xxx.xxx.xxx.6
DNSãµãŒããŒã¯ãããŒãã«å ã®ãã¹ãŠã®ã¬ã³ãŒãã調ã¹ãŠãæ°ããèŠæ±ããšã«æ¬¡ã®IPã¢ãã¬ã¹ãæäŸããŸããããšãã°ãæåã®èŠæ±-xxx.xxx.xxx.2ã2çªç®ã®èŠæ±-xxx.xxxx.xxx.3ãªã©ã ãã®çµæãã¯ã©ã¹ã¿ãŒå ã®ãã¹ãŠã®ãµãŒããŒãåãæ°ã®èŠæ±ãåãåããŸãã
ãã®ã¢ã«ãŽãªãºã ã®çãã®ãªãå©ç¹ã®äžã§ããŸããé«ã¬ãã«ã®ãããã³ã«ããã®ç¬ç«æ§ãšåŒã°ããã¹ãã§ãã ã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã§åäœããã«ã¯ããµãŒããŒãååã§ã¢ã¯ã»ã¹ããããããã³ã«ã䜿çšãããŸãã
ã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã«åºã¥ãåæ£ã¯ããµãŒããŒã®è² è·ã«ãŸã£ããäŸåããŸãããDNSãµãŒããŒããã£ãã·ã¥ãããšãã¯ã©ã€ã¢ã³ãã®æµå ¥ã«å¯ŸåŠããã®ã«åœ¹ç«ã¡ãŸãã
ã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã䜿çšãããšããµãŒããŒéã®éä¿¡ãäžèŠã«ãªããããããŒã«ã«ãã©ã³ã·ã³ã°ãšã°ããŒãã«ãã©ã³ã·ã³ã°ã®äž¡æ¹ã«äœ¿çšã§ããŸãã
æåŸã«ãã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã«åºã¥ããœãªã¥ãŒã·ã§ã³ã¯äœã³ã¹ãã§æ³šç®ã«å€ããŸããããããæ©èœãããã«ã¯ãDNSã«ããã€ãã®ã¬ã³ãŒããè¿œå ããã ãã§ãã
ã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã«ã¯ãå€ãã®é倧ãªæ¬ ç¹ããããŸãã ãã®ã¢ã«ãŽãªãºã ã«ããè² è·åæ£ãäžèšã®å ¬å¹³æ§ãšå¹çã®åºæºãæºããããã«ã¯ãåãµãŒããŒã«åããªãœãŒã¹ã»ãããå¿ èŠã§ãã ãã¹ãŠã®æäœãå®è¡ããå Žåãåãéã®ãªãœãŒã¹ãé¢äžããå¿ èŠããããŸãã å®éã«ã¯ãã»ãšãã©ã®å Žåããããã®æ¡ä»¶ã¯äžå¯èœã§ãã
ãŸããã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã«åŸã£ãŠåæ£ããå Žåãã¯ã©ã¹ã¿ãŒå ã®ãµãŒããŒã®è² è·ã¯ãŸã£ããèæ ®ãããŸããã 次ã®ä»®æ³çãªç¶æ³ãæ³åããŠãã ãããããŒãã®1ã€ã¯100ïŒ ããŒããããä»ã®ããŒãã¯10-15ïŒ ããŒããããŠããã ãã§ãã ã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã¯ãååãšããŠãã®ãããªç¶æ³ã®å¯èœæ§ãèæ ®ããŠããªããããéè² è·ã®ããŒãã¯åŒãç¶ãèŠæ±ãåä¿¡ããŸãã ãã®å Žåãæ£çŸ©ãå¹çæ§ãããã³äºæž¬å¯èœæ§ã«çåã®äœå°ã¯ãããŸããã
äžèšã®ç¶æ³ã«ãããã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã®ç¯å²ã¯éåžžã«éãããŠããŸãã
å éã©ãŠã³ãããã³
ããã¯ãã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã®æ¹è¯ããŒãžã§ã³ã§ãã æ¹åã®æ¬è³ªã¯æ¬¡ã®ãšããã§ããåãµãŒããŒã«ã¯ãããã©ãŒãã³ã¹ãšãã¯ãŒã«å¿ããŠéã¿ä¿æ°ãå²ãåœãŠãããŸãã ããã¯ãè² è·ãããæè»ã«åæ£ããã®ã«åœ¹ç«ã¡ãŸããéã¿ã倧ãããµãŒããŒã¯ãããå€ãã®èŠæ±ãåŠçããŸãã ãã ãããã©ãŒã«ããã¬ã©ã³ã¹ã«é¢ãããã¹ãŠã®åé¡ã解決ã§ããããã§ã¯ãããŸããã è² è·ãèšç»ããã³åæ£ãããšãã«ãããå€ãã®ãã©ã¡ãŒã¿ãŒãèæ ®ã«å ¥ããä»ã®æ¹æ³ã«ãããããå¹ççãªãã©ã³ã·ã³ã°ãæäŸãããŸãã
æå°æ¥ç¶
åã®ã»ã¯ã·ã§ã³ã§ã¯ãã©ãŠã³ãããã³ã¢ã«ãŽãªãºã ã®äž»ãªæ¬ ç¹ããªã¹ãããŸããã ããäžåºŠåŒã³åºããŸããããçŸåšã¢ã¯ãã£ããªæ¥ç¶ã®æ°ã¯èæ ®ãããŠããŸããã
å®çšçãªäŸãèããŠã¿ãŸãããã 2ã€ã®ãµãŒããŒããããŸã-æ¡ä»¶ä»ãã§Aããã³BãšããŠæå®ããŸãããµãŒããŒAã«ã¯ããµãŒããŒBãããå°ãªããŠãŒã¶ãŒãæ¥ç¶ãããŸããåæã«ããµãŒããŒAã¯ããéè² è·ã«ãªããŸãã ããã¯ã©ã®ããã«å¯èœã§ããïŒ çãã¯éåžžã«ç°¡åã§ãããµãŒããŒAãžã®æ¥ç¶ã¯ããµãŒããŒBãžã®æ¥ç¶ã«æ¯ã¹ãŠé·ãæéãµããŒããããŸãã
説æãããŠããåé¡ã¯ãæå°æ¥ç¶ïŒç-leastconnïŒãšããŠç¥ãããã¢ã«ãŽãªãºã ã䜿çšããŠè§£æ±ºã§ããŸãã ãµãŒããŒã§çŸåšãµããŒããããŠããæ¥ç¶ã®æ°ãèæ ®ãããŸãã 次ã®å質åã¯ãã¢ã¯ãã£ããªæ¥ç¶ã®æ°ãæãå°ãªããµãŒããŒã«æž¡ãããŸãã
ãã®ã¢ã«ãŽãªãºã ã«ã¯æ¹è¯ãããããŒãžã§ã³ããããäž»ã«ç°ãªãæè¡çç¹æ§ãšç°ãªãããã©ãŒãã³ã¹ãæã€ãµãŒããŒã§æ§æãããã¯ã©ã¹ã¿ãŒã§ã®äœ¿çšãç®çãšããŠããŸãã ããã¯å éæå°æ¥ç¶ãšåŒã°ããã¢ã¯ãã£ããªæ¥ç¶ã®æ°ã ãã§ãªãããµãŒããŒã®éã¿ä¿æ°ãè² è·ãåæ£ãããšãã«èæ ®ãããŸãã
æå°æ¥ç¶ã¢ã«ãŽãªãºã ã®ãã®ä»ã®æ¹åç¹ã«ã¯ãããŒã«ãªãã£ããŒã¹ã®æå°æ¥ç¶ã¹ã±ãžã¥ãŒãªã³ã°ããã³ã¬ããªã±ãŒã·ã§ã³ã¹ã±ãžã¥ãŒãªã³ã°ã䜿çšããããŒã«ãªãã£ããŒã¹ã®æå°æ¥ç¶ã¹ã±ãžã¥ãŒãªã³ã°ããããŸãã
æåã®ã¡ãœããã¯ããããã·ããã£ãã·ã¥ããããã«ç¹å¥ã«äœæãããŸããã ãã®æ¬è³ªã¯æ¬¡ã®ãšããã§ããã¢ã¯ãã£ããªæ¥ç¶ã®æ°ãæãå°ãªããµãŒããŒã«æ倧æ°ã®èŠæ±ãéä¿¡ãããŸãã åã¯ã©ã€ã¢ã³ããµãŒããŒã«ã¯ãã¯ã©ã€ã¢ã³ãIPã®ã°ã«ãŒããå²ãåœãŠãããŸãã ãããã®IPããã®èŠæ±ã¯ãå®å šã«ããŒããããŠããªãå Žåãããã€ãã£ãããµãŒããŒã«éä¿¡ãããŸãã ãã以å€ã®å ŽåãèŠæ±ã¯å¥ã®ãµãŒããŒã«ãªãã€ã¬ã¯ããããŸãïŒåå以äžã§ããŒãããå¿ èŠããããŸãïŒã
è€è£œã¹ã±ãžã¥ãŒãªã³ã°ã¢ã«ãŽãªãºã ã䜿çšããããŒã«ãªãã£ããŒã¹ã®æå°æ¥ç¶ã¹ã±ãžã¥ãŒãªã³ã°ã§ã¯ãåIPã¢ãã¬ã¹ãŸãã¯IPã¢ãã¬ã¹ã®ã°ã«ãŒãã¯ãåå¥ã®ãµãŒããŒã§ã¯ãªãããµãŒããŒã®ã°ã«ãŒãå šäœã«å²ãåœãŠãããŸãã èŠæ±ã¯ãã°ã«ãŒãããæãè² è·ã®å°ãªããµãŒããŒã«æž¡ãããŸãã ããã€ãã£ããã°ã«ãŒãã®ãã¹ãŠã®ãµãŒããŒãéè² è·ã«ãªããšãæ°ãããµãŒããŒãäºçŽãããŸãã ãã®æ°ãããµãŒããŒã¯ãèŠæ±ã®éä¿¡å ã®IPãµãŒãã¹ã°ã«ââãŒãã«è¿œå ãããŸãã 次ã«ããã®ã°ã«ãŒãããæãããžãŒãªãµãŒããŒãåé€ãããŸã-ããã«ãããéå°ãªè€è£œãåé¿ãããŸãã
å®å ããã·ã¥ã¹ã±ãžã¥ãŒãªã³ã°ãšãœãŒã¹ããã·ã¥ã¹ã±ãžã¥ãŒãªã³ã°
Destination Hash Schedulingã¢ã«ãŽãªãºã ã¯ããã£ãã·ã¥ãããã·ã®ã¯ã©ã¹ã¿ãŒã§åäœããããã«äœæãããŸããããä»ã®å Žåã«ãã䜿çšãããŸãã ãã®ã¢ã«ãŽãªãºã ã§ã¯ããªã¯ãšã¹ããåŠçãããµãŒããŒã¯ãåä¿¡è ã®IPã¢ãã¬ã¹ã«ãã£ãŠéçããŒãã«ããéžæãããŸãã
ãœãŒã¹ããã·ã¥ã¹ã±ãžã¥ãŒãªã³ã°ã¢ã«ãŽãªãºã ã¯åã®ã¢ã«ãŽãªãºã ãšåãååã«åºã¥ããŠãããèŠæ±ãåŠçãããµãŒããŒã®ã¿ãéä¿¡è ã®IPã¢ãã¬ã¹ã«ãã£ãŠããŒãã«ããéžæãããŸãã
ã¹ãã£ãããŒã»ãã·ã§ã³
ã¹ãã£ãããŒã»ãã·ã§ã³ã¯ãçä¿¡èŠæ±ãåæ£ããããã®ã¢ã«ãŽãªãºã ã§ãæ¥ç¶ã¯ã°ã«ãŒãå ã®åããµãŒããŒã«è»¢éãããŸãã ããšãã°ãNginx WebãµãŒããŒã§äœ¿çšãããŸãã IPããã·ã¥æ¹åŒã䜿çšããŠãç¹å®ã®ãµãŒããŒã«ãŠãŒã¶ãŒã»ãã·ã§ã³ãå²ãåœãŠãããšãã§ããŸãïŒè©³çŽ°ã«ã€ããŠã¯ã å ¬åŒããã¥ã¡ã³ããåç §ããŠãã ããïŒã ãã®æ¹æ³ã䜿çšãããšãèŠæ±ã¯ã¯ã©ã€ã¢ã³ãã®IPã¢ãã¬ã¹ã«åºã¥ããŠãµãŒããŒã«é ä¿¡ãããŸãã ããã¥ã¡ã³ãã«èšèŒãããŠããããã«ïŒäžèšã®ãªã³ã¯ãåç §ïŒãããã®æ¹æ³ã«ãããåãã¯ã©ã€ã¢ã³ãããã®èŠæ±ãåããµãŒããŒã«éä¿¡ãããŸããã ç¹å®ã®ã¢ãã¬ã¹ã«å²ãåœãŠããããµãŒããŒãå©çšã§ããªãå Žåããªã¯ãšã¹ãã¯å¥ã®ãµãŒããŒã«ãªãã€ã¬ã¯ããããŸãã æ§æãã¡ã€ã«ã®ãã©ã°ã¡ã³ãã®äŸïŒ
ã¢ããã¹ããªãŒã ããã¯ãšã³ã{ ip_hash; ãµãŒããŒbackend1.example.com; ãµãŒããŒbackend2.example.com; ãµãŒããŒbackend3.example.com; ãµãŒããŒbackend4.example.com; }
åãµãŒããŒã®Nginxã®ããŒãžã§ã³1.2.2以éã§ã¯ãéã¿ãæå®ã§ããŸãã
ãã®æ¹æ³ã®äœ¿çšã«ã¯ãããã€ãã®åé¡ã䌎ããŸãã ã¯ã©ã€ã¢ã³ããåçIPã䜿çšããŠããå Žåãã»ãã·ã§ã³ãã€ã³ãã£ã³ã°ã®åé¡ãçºçããå¯èœæ§ããããŸãã å€æ°ã®èŠæ±ã1ã€ã®ãããã·ãµãŒããŒãééããç¶æ³ã§ã¯ããã©ã³ã¹ãå¹æçãã€å ¬å¹³ãšã¯èšãåããŸããã ãã ãã説æãããŠããåé¡ã¯ãCookieã䜿çšããŠè§£æ±ºã§ããŸãã Nginxã®åçšããŒãžã§ã³ã«ã¯ãCookieã䜿çšããŠãã©ã³ã¹ãåãç¹å¥ãªã¹ãã£ãããŒã¢ãžã¥ãŒã«ããããŸãã 圌ã¯ç¡æã®é¡äŒŒç©ãæã£ãŠããŸã-äŸãã°nginx-sticky-module ã
HAProxyã§sticky-sessionsã¡ãœããã䜿çšã§ããŸããããã«ã€ããŠã®è©³çŽ°ã¯ãããšãã°ããã«ãããŸãã
ãããã«
ãã®èšäºã¯ãæ¬è³ªçã«è² è·åæ£ã®æŠèŠã§ãã ãã®ãããã¯ã«ã€ããŠã¯ãä»åŸã®åºçç©ã§åŒãç¶ãè°è«ããŸãã 質åãã³ã¡ã³ããè¿œå ãããå Žå-ã³ã¡ã³ããžããããã ãŸããããŸããŸãªãããžã§ã¯ãã®è² è·åæ£ã®æ§æã®éèŠãªå®äŸãå ±æããŠããã ãããšãããããã§ãã
äœããã®çç±ã§ããã«ã³ã¡ã³ããæçš¿ã§ããªãèªè ã¯ãç§ãã¡ã®ããã°ã«åå ããŠãã ãã ã