ããã«ã¡ã¯ããããã¯ã¹ã»ã©ãã®Iã§ãã
ããæããµã¨ããµã¼ãã¼ã¬ã¹ãã³ã³ãããã¤ã³ã¹ã¿ã³ã¹ã¨ããç°ãªãã³ã³ãã¥ã¼ãã£ã³ã°ãµã¼ãã¹ã®ã¢ã¼ããã¯ãã£ããã£ããã¨æ¯è¼ãããã¨ããªãã£ããªãã¨æ°ä»ãã¾ããããããæ©ã«æ´çããä»å¾ã®åèã«ã§ããã°ã¨èããããã°è¨äºã¨ãã¦ã¾ã¨ãã¦ã¿ã¾ããã
調ã¹ãçµæããããã®ã¢ã¼ããã¯ãã£ãåç´ã«æ¯è¼ããã®ã¯é£ããã¨æãã¾ããããç解ãæ·±ããããã«ãããã©ã¼ãã³ã¹ãã³ã¹ããæ§ç¯ã®ãããããã¹ã±ã¼ã©ããªãã£ãéç¨ã®æéã¨ãã£ã観ç¹ãããåºãå©ç¨ããã¦ããAWSã«ããããµã¼ãã¼ã¬ã¹ãã³ã³ãããã¤ã³ã¹ã¿ã³ã¹ã®ã¡ãªããã»ãã¡ãªãããæ´çãã¦ã¿ã¾ããã以ä¸ã«è§£èª¬ãã¾ãã
ã¾ãã調æ»ãé²ããä¸ã§ããã£ãã®ã¯ããã¡ãªããã«å¯¾ãã¦ã¯ã解決çã¨ãªãæè¡ãåå¨ãã¦ããã¨ããç¹ã§ããä»å¾ã®æè¡ã®é²å±ãAWSã®ã¢ãããã¼ãã«ãã£ã¦ããã®çµæãå¤ããå¯è½æ§ããããã¨æãã¾ãã®ã§ãããã¾ã§ç¾æç¹ã§ã®ã¾ã¨ãã¨ãã¦åèã«ãã¦ããã ããã°å¹¸ãã§ãã
ããã¾ã¨ã¾ã£ã¦ããAWSããã¥ã¡ã³ããããã¾ããã®ã§ãæåã«ãç´¹ä»ããã¦ããã ãã¾ãã
1. ãµã¼ãã¼ã¬ã¹ï¼ä¾ï¼AWS Lambdaï¼
ãµã¼ãã¼ã¬ã¹ã¢ã¼ããã¯ãã£ã§ã¯ãã¤ã³ãã©ç®¡çãAWSã«ä»»ããã¢ããªã±ã¼ã·ã§ã³ã³ã¼ãã«éä¸ã§ããè¨è¨ã§ãã代表çãªä¾ã§ããAWS Lambdaã§è¨è¿°ãã¾ãã
ã¡ãªãã
- ããã©ã¼ãã³ã¹
 ãªã¯ã¨ã¹ãã«å¿ãã¦èªåã§ã¹ã±ã¼ãªã³ã°ããå¦çè½åãåçã«èª¿æ´ãã¾ããçæéã®é«è² è·ãçæéã®ãªã¯ã¨ã¹ãã«æé©ã§ããLambdaã®ã¹ã±ã¼ãªã³ã°ã¯10ç§ãã¨ã«æ大1000ã®å®è¡ç°å¢ã追å ããã¾ãããåæå®è¡æ°ã®ããã©ã«ãä¸éã¯1000ã§ãããã®ããããªã¯ã¨ã¹ããéä¸ãã¦ãèªåçã«å¯¾å¿ã§ãã¾ãããä¸éã«ã¯æ³¨æãå¿ è¦ã§ãã - æ§ç¯ã®å®¹æã
 ãµã¼ãã¼ã®è¨å®ãã¤ã³ãã©ç®¡çãä¸è¦ã§ãã³ã¼ãã®ã¿ã管çãã¾ãããããã¤ã¯èªååããã¦ãããAWSãµã¼ãã¹ï¼API GatewayãDynamoDBãªã©ï¼ã¨ç°¡åã«çµ±åã§ãã¾ãããLambdaé¢æ°èªä½ã«ã¯è¨å®ãå¿ è¦ã§ããè¦ä»¶ã«å¿ãã¦ãã®è¨å®ã調æ´ã§ãã¾ãã - ã³ã¹ãå¹ç
 使ç¨ããåã ã課éãããå¾é課éå¶ã§ãããµã¼ãã¼ãã¢ã¤ãã«ç¶æ ã®ã¨ãã«ã¯ã³ã¹ããçºçãã¾ãããã¹ã±ã¼ãªã³ã°ãèªåã§è¡ãããç¹ã«ä½ãã©ãã£ãã¯æã«å¤§å¹ ãªã³ã¹ãåæ¸ãå¯è½ã§ããã³ã¼ã«ãã¹ã¿ã¼ãã®åé¡ãããã¾ããProvisioned Concurrencyï¼PCï¼ã使ç¨ããã¨åé¿ã§ãã代ããã«ã追å ã³ã¹ããçºçãã¾ãã
Â
ãã¡ãªãã
- ããã©ã¼ãã³ã¹ã®å¶ç´
 Lambdaã®å®è¡ã«ã¯æ大15åã¨ããå¶ç´ããããããé·æéå¦çã大è¦æ¨¡ãªãããå¦çã«ã¯åãã¦ãã¾ãããã³ã¼ããåå²ãã¦Step Functionsãç¨ãã¦åé¿ã§ããå¯è½æ§ã¯ããããã§ããæ§æãè¤éã«ãªãç¹ã¯å¦ããªããã¨æãã¾ãã - ã³ã¼ã«ãã¹ã¿ã¼ãåé¡
 é¢æ°ãä¸æåæ¢ããå ´åãæ°ãããªã¯ã¨ã¹ããåãä»ããéã«ã³ã¼ã«ãã¹ã¿ã¼ããçºçãã100ããªç§ãã1ç§ç¨åº¦ã®é 延ãçãããã¨ãããã¾ãããã®é 延ãéè¦ãªã¢ããªã±ã¼ã·ã§ã³ã«å½±é¿ãã¾ãããProvisioned Concurrencyï¼PCï¼ã使ç¨ãããã¨ã§ãã®é 延ãåæ¸ã§ãã¾ããç¹°ãè¿ãã«ã¯ãªãã¾ããProvisioned Concurrencyï¼PCï¼ã«ã¯ã³ã¹ãããããã¾ãã - ã«ã¹ã¿ãã¤ãºæ§ã®å¶é
 AWS Lambdaã¯ããã¼ã¸ããµã¼ãã¹ã®ãããã¤ã³ãã©ç®¡çãä¸è¦ãªç¹ã大ããªå©ç¹ã§ãããç¹å®ã®è¦ä»¶ã«å¿ããã¤ã³ãã©è¨å®ãã«ã¹ã¿ãã¤ãºã¯é£ããã±ã¼ã¹ãããã¨æãã¾ããã¤ã³ãã©ã®ç´°ããªèª¿æ´ãå¿ è¦ãªå ´åã¯ä»ã®ã¢ã¼ããã¯ãã£ãæ¤è¨ããå¿ è¦ãããã¾ããã¾ãlambdaã§ãã³ã³ããã¤ã¡ã¼ã¸ããµãã¼ããã¦ãããããªã®ã§ããã®ç¹ã«ã¤ãã¦ã¯ãªã³ã¯ãå ±æãã¾ãã
Â
2. ã³ã³ããï¼ä¾ï¼Amazon ECS, Amazon EKSï¼
ã³ã³ããã¢ã¼ããã¯ãã£ã¯ãã¢ããªã±ã¼ã·ã§ã³ãç¬ç«ããããã±ã¼ã¸ã¨ãã¦å®è¡ãã軽éã§å¹ççãªãªã½ã¼ã¹ç®¡çãå¯è½ã«ããä»çµã¿ã§ãã代表çãªECS/EKSã¯ãEC2ã¤ã³ã¹ã¿ã³ã¹ãã¼ã¹ã§ã®éç¨ãå¯è½ã§ãããAWS Fargateã¯ãµã¼ãã¼ã¬ã¹åºç¤ã¨ãªããã³ã³ããã®ã¤ã³ãã©ç®¡çãä¸è¦ãªãããã¦ã¼ã¶ã¼ããªã½ã¼ã¹ç®¡çãã解æ¾ããã¾ãã
ã¡ãªãã
- æ§ç¯ã®æè»æ§
 ã³ã³ããã¯OSãã©ã¤ãã©ãªãã¢ããªã±ã¼ã·ã§ã³ãä¸ã¤ã®åä½ã«ã¾ã¨ãã¦å®è¡ã§ãããããä¾åé¢ä¿ã®éãã«ããç°å¢ã®ãºã¬ã解æ¶ã§ãã¾ããECSãEKSã使ã£ã¦ãè¤æ°ã®ã³ã³ããããªã¼ã±ã¹ãã¬ã¼ã·ã§ã³ï¼ã·ã¹ãã ãèªåçã«èª¿æ´ï¼ããåçã«ç®¡çã§ãã¾ããaws.amazon.com - ããã©ã¼ãã³ã¹Â Â
 ã³ã³ããã¯ãªã½ã¼ã¹å¹çãé«ããã¢ããªã±ã¼ã·ã§ã³ãè¿ éã«ã¹ã±ã¼ã«ããããã¨ãã§ãã¾ããFargateã使ç¨ããå ´åã¯ãã¤ã³ãã©ç®¡çãä¸è¦ã§ãèªåã§ã¹ã±ã¼ãªã³ã°ãè¡ããã¾ããããã«ãããéç¨è² æ ã軽æ¸ãããè² è·åæ£ããããã¤ã®é«éåãå¯è½ã§ãã - ã¹ã±ã¼ãªã³ã°
 AWS Fargateã¯ãã³ã³ããã®ã¤ã³ãã©ãå®å ¨ã«èªååãããµã¼ãã¬ã¹ã®ããã«åä½ãã¾ããä¸æ¹ã§ãEC2ãã¼ã¹ã®ECSãEKSã¯ã¤ã³ã¹ã¿ã³ã¹ã®ã¹ã±ã¼ãªã³ã°ãå¿ è¦ã§ããããªã¼ã±ã¹ãã¬ã¼ã·ã§ã³ãã¼ã«ï¼ä¾: Kubernetesï¼ãæ´»ç¨ãã¦èªåã¹ã±ã¼ãªã³ã°ãè¡ããã¨ãå¯è½ã§ãã
ãã¡ãªãã
- æ§ç¯ã®è¤éã
 AWSã«ãããã³ã³ããæè¡ã¯æè»ã§ãããããã«è¤éãªé¢ãããã®ãã¨æãã¾ããä¾ãã°ãECSã¯ã·ã³ãã«ã§æ¯è¼çç°¡åã«å§ãããã¾ãããKubernetesï¼EKSï¼ãå©ç¨ããå ´åã¯ããªã¼ã±ã¹ãã¬ã¼ã·ã§ã³ã®è¨å®ã管çãé«åº¦ã§ãå°éçãªç¥èãæ±ãããã¾ãããã ããKubernetesã®ç§»æ¤æ§ãæè»æ§ãæ´»ç¨ãããã¨ã§ãè¤éãªãã«ãã¯ã©ã¦ãç°å¢ã大è¦æ¨¡ãªã·ã¹ãã ã§ã対å¿ã§ããå©ç¹ãããã¾ããFargateã使ç¨ãããã¨ã§ã¤ã³ãã©ç®¡çãç°¡ç´ åãããä¸æ¹ãEC2ãã¼ã¹ã®ã³ã³ããã¯ãµã¼ãã¼ç®¡çãå¿ è¦ã§ãã - ã³ã¹ãã®è¤éã
 å°è¦æ¨¡ãªç°å¢ã§ã¯Fargateãåªããã³ã¹ãå¹çãçºæ®ãã¾ããã大è¦æ¨¡ãªéç¨ã§ã¯EC2ã¤ã³ã¹ã¿ã³ã¹ã®æ¹ãã³ã¹ãå¹çãé«ããªãå¯è½æ§ããããã¨æãã¾ããä½ãEC2ã¯ã¤ã³ãã©ç®¡çã®ã³ã¹ããçºçãããããæé©ãªé¸æã¯éç¨è¦æ¨¡ãå©ç¨ç¶æ³ã«ããç°ãªãã¾ãã
3. ã¤ã³ã¹ã¿ã³ã¹ï¼ä¾ï¼Amazon EC2ï¼
ã¤ã³ã¹ã¿ã³ã¹ã®ä»£è¡¨çãªãµã¼ãã¹ã§ããEC2ã¯ãã¯ã©ã¦ãä¸ã§ä»®æ³ãµã¼ãã¼ããããã¸ã§ãã³ã°ããæè»ã«ã«ã¹ã¿ãã¤ãºã§ããã¢ã¼ããã¯ãã£ã§ããã¤ã³ãã©å ¨ä½ã®è¨å®ãã¹ã±ã¼ãªã³ã°ãã¦ã¼ã¶ã¼ã®ç®¡çä¸ã«ããã¾ãã
ã¡ãªãã
- ããã©ã¼ãã³ã¹
 EC2ã¤ã³ã¹ã¿ã³ã¹ã¯ãé«ãããã©ã¼ãã³ã¹ãæä¾ãã¾ããç¹ã«ã«ã¹ã¿ã æ§æï¼CPUãã¡ã¢ãªãGPUãªã©ï¼ãé«è² è·ã®ã¯ã¼ã¯ãã¼ãã«å¯¾å¿ã§ããç¹æ®ãªãã¼ãºã«å¿ãããªã½ã¼ã¹ã®é¸æãå¯è½ã§ããæ©æ¢°å¦ç¿ã大è¦æ¨¡ãªãã¼ã¿å¦çã«ã¯æé©ã§ãã - ã«ã¹ã¿ãã¤ãºæ§
 OSãã½ããã¦ã§ã¢ããããã¯ã¼ã¯è¨å®ãèªç±ã«ã«ã¹ã¿ãã¤ãºã§ãã¾ãããªã³ãã¬ãã¹ã®ãããªã¤ã³ãã©éç¨ãå¯è½ã§ãé常ã«é«ãèªç±åº¦ãæ±ããããç°å¢ã«é©ãã¦ãã¾ãã - ã¹ãã¼ããã«ãªã¢ããªã±ã¼ã·ã§ã³ã«æé©
 é·æéã«ããããã¼ã¿ãã»ãã·ã§ã³ãä¿æããã¹ãã¼ããã«ãªã¢ããªã±ã¼ã·ã§ã³ã«é©ãã¦ãããã¤ã³ãã©ã®é·æçãªãã¥ã¼ãã³ã°ãå¯è½ã§ãã - 移è¡å®¹ææ§
 æ¢åã®ãªã³ãã¬ãã¹ç°å¢ã§åä½ããOSä¸ã®ã¢ããªã±ã¼ã·ã§ã³ãã¯ã©ã¦ãã«ç§»è¡ããå ´åãEC2ã¤ã³ã¹ã¿ã³ã¹ã¯æã移è¡ã容æãªé¸æè¢ã¨ãªãå¯è½æ§ãããã¾ããåãOSãé¸æã§ããã°æ¢åã®ã¢ããªã±ã¼ã·ã§ã³ãå¤§å¹ ã«æ¹ä¿®ãããã¨ãªãã¯ã©ã¦ãã«ç§»è¡ã§ãã¾ãã
ãã¡ãªãã
- æ§ç¯ã»éç¨ã®ã³ã¹ã
 EC2ã¤ã³ã¹ã¿ã³ã¹ã®ç®¡çã¯ãã¦ã¼ã¶ã¼ãã¤ã³ãã©å ¨ä½ã管çããå¿ è¦ããããOSã®ã¡ã³ããã³ã¹ãã»ãã¥ãªãã£ç®¡çãã¹ã±ã¼ãªã³ã°è¨è¨ãªã©ãæ±ãããããããéç¨è² æ ã大ãããªãã¾ãã - ã¹ã±ã¼ã©ããªãã£
 EC2ã¤ã³ã¹ã¿ã³ã¹ã®ã¹ã±ã¼ãªã³ã°ã«ã¯ã³ã³ããã¨æ¯ã¹ãã¨ã¹ã±ã¼ã«ã®å³ææ§ã¯ä½ããªããã¡ã§ãããããã¯ã·ã¹ãã ã®è¦ä»¶æ¬¡ç¬¬ã§åé¡ã«ãªããªãã±ã¼ã¹ãããã¾ãã - æéã³ã¹ã
 EC2ã¤ã³ã¹ã¿ã³ã¹ã¯ç¨¼åæéãã¼ã¹ã§èª²éããããããã¢ã¤ãã«ç¶æ ã§ãã³ã¹ããçºçãã¾ããé·æéã®å©ç¨ããªã¶ã¼ããã¤ã³ã¹ã¿ã³ã¹ã®æ´»ç¨ã§ã³ã¹ããæé©åã§ãã¾ãããçæçãªéç¨ãé »ç¹ã«è² è·ãå¤åããã·ã¹ãã ã«ã¯ä¸åãã§ãã
çµè«
æé©ãªã¢ã¼ããã¯ãã£ã®é¸å®ã¯ãã·ã¹ãã ã®è¦ä»¶ãã¹ã±ã¼ã©ããªãã£ãéç¨ä½å¶ã移è¡ã®å®¹æããªã©ãèæ ®ãã¦æ±ºå®ããå¿ è¦ããããAWSã«ã¯æ§ã ãªãµã¼ãã¹ããªãã·ã§ã³ãããã¾ãã
ãã®çºã並åã§æ¯è¼ãã¦æ¯ã¹ãã®ã¯é£ããã¨æãã¾ããããããã¾ã§ç§å人ã®è¦è§£ã¨ãã¦æå¾ã«ç¹å¾´ãçºãã¦è¨è¿°ãããã¾ãã
- çæéã»è»½éãªå¦çããéçºå¹çãã³ã¹ãå¹çãéè¦ãããå ´åã¯ããµã¼ãã¼ã¬ã¹ï¼Lambdaï¼ãæé©ãã¨æãã¾ããç¹ã«APIãã¤ãã³ãé§ååã®ã·ã¹ãã ã«é©ãã¦ãããã¤ã³ãã©ç®¡çãä¸è¦ãªãããéç¨ã³ã¹ããä½æ¸ã§ãã¾ãã
- ä¸è¦æ¨¡ã®ã¹ã±ã¼ã«ã¢ã¦ãã¢ããªã±ã¼ã·ã§ã³ã«ã¯ãã³ã³ãã(ECSã»EKS)ãé©ãã¦ããã¨æãã¾ããAWS Fargateã使ãã°ããµã¼ãã¼ã¬ã¹ã®ãããªã¤ã³ãã©æ§ç¯ã»ç®¡çã®æéãçããªãããã³ã³ããã®å©ç¹ãæ´»ãããæ§ç¯ã»éç¨ãå¯è½ã§ããã¾ãé£æ度ã¯é«ããã§ããEKSãé¸æããå ´åã¯ç§»æ¤æ§ã®é«ããé åã ã¨æãã¾ãã
- é«è² è·å¦çãã¹ãã¼ããã«ãªã¢ããªã±ã¼ã·ã§ã³ãç¹ã«OSã«ã¦æè»ãªã«ã¹ã¿ãã¤ãºãç¹å®ã®ãªã½ã¼ã¹è¦ä»¶ãããå ´åã¯ãã¤ã³ã¹ã¿ã³ã¹ï¼EC2ï¼ãé¸æããã®ãæé©ã§ããã¤ã³ãã©å ¨ä½ãèªç±ã«è¨è¨ã§ããå¾æ¥ã®ä»®æ³ãã·ã³éç¨ã«æ £ãã¦ããå ´åã¯ç®¡çã容æã§ãã
- | ãµã¼ãã¼ã¬ã¹(Lambda) | ã³ã³ãã(ECSã»EKS) | ã¤ã³ã¹ã¿ã³ã¹ (EC2) |
---|---|---|---|
ããã©ã¼ãã³ã¹ | çæéã»è»½éã¿ã¹ã¯ã«æé© | ã³ã³ãã軽éããã±ã¼ã¸ã§ã¹ã±ã¼ãªã³ã°ãé«éã§å¹çç | åä½ã§ã¯ä¸çªé«æ§è½ã»é«è² è·ã¿ã¹ã¯ã«æé©ãã¹ã±ã¼ãªã³ã°ãå¯è½ã ããã¯ã¼ã¯ãã¼ãã«ãã£ã¦ã¯èµ·åã«æéããããå¯è½æ§ãã |
æ§ç¯ã»ç®¡çã®ç¹å¾´ | ã³ã¼ãã®ã¿ã§ãæ§ç¯å¯è½ |
ECSãEKSãEC2ãFargateçã®é¸æã«ããå¤ãããæè»ããAWSã³ã³ãããµã¼ãã¹ã®é åã ã¨æããããã®ç¹ãããè¤éããçã |
ã¤ã³ãã©å ¨ä½ã®æ§ç¯ã»ç®¡çãå¿ è¦ |
ã«ã¹ã¿ãã¤ãºæ§ | ä½ã | ä¸ç¨åº¦ã»ç°å¢ã®çµ±ä¸ã容æ | ãµã¼ãåä½ã§è¦ãå ´åã¯é常ã«é«ã |
主ãªã¦ã¼ã¹ã±ã¼ã¹ | APIãããã¯ã¨ã³ãå¦çãã¤ãã³ãé§å | APIããã¤ã¯ããµã¼ãã¹ãCI/CD | é«è² è·ã¢ããªãæ©æ¢°å¦ç¿ |
æ¬å½ã¯ã³ã¹ãã®æ¯è¼ãªã©ãå ¥ãããã£ãã®ã§ãããé£ããã®ã§æ念ãã¾ãããã
æå¾ã«
ç§ãã¡ã¯ãAWSä¸ã§å¹ççãã¤ã¹ã±ã¼ã©ãã«ãªã·ã¹ãã ãæ§ç¯ããæ§ã ãªã¦ã¼ã¹ã±ã¼ã¹ã«å¯¾å¿ãã¦ãã¾ããæé©ãªã¢ã¼ããã¯ãã£é¸å®ã®ãã¦ãã¦ãæ´»ãããè¦ä»¶ã«å¿ããã½ãªã¥ã¼ã·ã§ã³ãæä¾ããã ãã§ãªãããã¼ã å ã§ãææ°ã®æè¡ãé§ä½¿ããéçºç°å¢ãæä¾ãã¦ãã¾ãã
ãããã¯ã©ã¦ãæè¡ã«èå³ããããç§ãã¡ã¨ä¸ç·ã«ã¯ã©ã¦ãã½ãªã¥ã¼ã·ã§ã³ãåµãããæ¹ãããã°ããã²æ¡ç¨ãã¼ã¸ãã確èªãã ãããããªãã®ã¹ãã«ãæ´»ããã¦ãç§ãã¡ã¨ã¨ãã«æ°ããææ¦ããã¾ãããã
ç³å£ æ ä»ã·ã¹ãã éçºä¸é¨ ãããã¯ã¹ã»ã©ã
Â