Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ECS Fargate spotを活用した負荷試験ツールを3年間運用してわかったこと

ECS Fargate spotを活用した負荷試験ツールを3年間運用してわかったこと

2022.11.30 Kubernetes/Fargateの導入・活用事例-カカクコム×CROOZ×ナビタイム-【TECHHILLS】

https://techplay.jp/event/877265

NAVITIME JAPAN

November 29, 2022
Tweet

More Decks by NAVITIME JAPAN

Other Decks in Technology

Transcript

  1. ࣄۀྖҬ - B to C ϝσΟΞࣄۀ ૯߹φϏαʔϏε ϚʔέςΟϯάࢧԉ τϥϕϧࣄۀ ཱྀߦαʔϏε

    ؍ޫϚʔέςΟϯάࢧԉ υϥΠϒࣄۀ ࣗಈं޲͚αʔϏε πʔϦϯάࣄۀ ࣗసं/ΦʔτόΠ޲͚αʔϏε ๏ਓ/࣏ࣗମ޲͚αʔϏε όεɾ΢ΥʔΩϯ άࣄۀ όεɾ݈߁αʔϏε ΩϟϦΞڠۀࣄۀ ϏδωεφϏλΠϜࣄۀ େܕं޲͚ ಈଶ؅ཧ
  2. ࣄۀྖҬ - B to B Maasࣄۀ MaasΞϓϦ޲͚ APIఏڙ ίϯςϯππʔϦζϜͷاըɾӡӦ ஍Ҭ࿈ܞࣄۀ

    ࣏ࣗମ޲͚αʔϏε։ൃࢧԉ ؍ޫ٬༠க౳ͷίϯαϧςΟϯά CASEࣄۀ ࣗಈं޲͚αʔϏεͷ։ൃࢧԉ ަ௨σʔλࣄۀ ަ௨ɾ؍ޫσʔλͷఏڙɾ෼ੳ ϩέʔγϣϯϚʔ έςΟϯάࣄۀ ళฮσʔλ؅ཧΫϥ΢υαʔϏε ళฮϚʔέςΟϯάࢧԉ ιϦϡʔγϣϯࣄۀ ެڞަ௨ࣄۀ ަ௨ࣄۀऀ޲͚ιϦϡʔγϣϯ ๏ਓ޲͚API,SDK, πʔϧ౳ͷఏڙ
  3. ׆༻͍ͯ͠Δίϯςφؔ࿈ٕज़ɾσϓϩΠख๏ɾ՝୊ ECS on fargate ECS on ec2 EKS on self

    managed nodes ECS on fargate Λ3೥ؒར༻ͯ͠Ͳ͏͔ͩͬͨʁ ຊ೔ɺ͓࿩͢Δ͜ͱ
  4. શମߏ੒ slave ECS Service: Master ECS Service: Slave slave slave

    master Access log ܭଌର৅ Service Discovery
  5. Locust - masterͷ໾ׂ slave ECS Service: Master ECS Service: Slave

    slave slave master Access log ܭଌର৅ Service Discovery ࢼݧ݁Ռ֬ೝ༻ WebϖʔδΛϦΞϧλΠϜʹՄࢹԽ slave ͔Β౷ܭ৘ใΛऩू masterͷ໾ׂ
  6. slave ECS Service: Master ECS Service: Slave slave slave master

    Access log ܭଌର৅ Service Discovery ܭଌର৅αʔόʔʹ࣮ࡍʹϦΫΤετΛૹ৴͢Δ slaveͷ໾ׂ Locust - slaveͷ໾ׂ
  7. slave ECS Service: Master ECS Service: Slave slave slave master

    Access log ܭଌର৅ Service Discovery ᶄ Locust ͷ֤slaveίϯςφ͸ෛՙࢼݧͰར ༻͢ΔϦΫΤετϦετΛs3͔Βऔಘ ॲཧͷྲྀΕ
  8. slave ECS Service: Master ECS Service: Slave slave slave master

    Access log ܭଌର৅ Service Discovery ॲཧͷྲྀΕ ᶄ Locust ͷ֤slaveίϯςφ͸ܭଌର৅αʔ όʔʹϦΫΤετΛૹ৴ɻ Ϩεϙϯε݁Ռ͸ϦΞϧλΠϜʹMasterʹૹ ৴͞ΕΔ
  9. slave ECS Service: Master ECS Service: Slave slave slave master

    Access log ܭଌର৅ Service Discovery PythonͰ࣮૷Ͱ͖ΔͷͰ֦ுੑ͕ߴ͍ S3͔ΒࣄલʹςετϦΫΤετΛऔಘ ϦΫΤετΛվ᜵ /v1Λ /v2ʹมߋ ϦΫΤετϔομʔΛ௥Ճ ϦΫΤετૹ৴ִؒΛௐ੔ ྫ
  10. ECS fargate ΁ͷσϓϩΠ 1. ઃఆϑΝΠϧΛ࡞੒ ͠ɺGitʹPush ECSClusterName: locust VpcId: vpc-xxxxxxxx

    ECSSecurityGroupId: sg-xxxxxxx ECSTaskExecutionRole: arn:aws:iam::333333333:role/EC2_allow_locust ECSSubnetId1: subnet-22222222222 ECSSubnetId2: subnet-44444444444 ECSSubnetId3: subnet-11111111111 ECSImageName: hoge:1.2.2 TargetUrl: https://hoge.jp TargetService: xxx-truckapp-stg ApacheLogUrl: s3://hoge/archive/latest/latest/*.gz RequestUrlPattern: /v1/[0-9]{8}/(route) RequestUrlExcludePattern: '' RequestUrlReplace: '' MasquaradeUseragent: false RequestToEveryPath: false SetScaleInAlarm: false AddNLBToLocustMaster: false LocustMaster: ECSTaskCPUUnit: 512 ECSTaskMemory: 1024 LocustOpts: --loglevel=ERROR --csv=output MasterNamespace: hoge.jp PrivateNamespaceId: ns-xxxxx LocustSlave: ECSTaskCPUUnit: 256 ECSTaskMemory: 512 ECSTaskDesiredCount: 1 LocustOpts: --loglevel=ERROR ྫ ෛՙࢼݧΛߦ͏։ൃऀ
  11. ECS fargate ΁ͷσϓϩΠ 2. Jenkins δϣϒΛ ࢖ͬͯ ECS Fargate ͷ

    ServiceΛσϓϩΠ ෛՙࢼݧΛߦ͏։ൃऀ αʔϏεA ༻؀ڥ αʔϏεB ༻؀ڥ αʔϏεC ༻؀ڥ
  12. ECS FargateΛ࠾༻ͨ͠ܦҢ Lambda > ECS Fargate > ECS on ec2

    ͷॱͰΞʔΩςΫ νϟΛݕ౼ ֶशίετ͕ൺֱత௿͍ (ECS on ec2 ɺEKSͱൺ΂ͯ)
  13. NAVITIME ৐׵NAVITIME ΧʔφϏλΠϜ ࣗసंNAVITIME Japan Travel by NAVITIME τϥοΫΧʔφϏ πʔϦϯάαϙʔλʔ

    Ͱӡ༻͍ͯ͠ΔϓϩμΫτͷྫ ECS on ec2 ECS on ec2͸ࣾ಺ͰҰ൪ଟ͘ར༻͞Ε͍ͯΔ ALKOO by NAVITIME
  14. CodeDeploy ͸࢖͍ͬͯ·ͤΜ ཧ༝ ECS Service ͱ AutoscalingGroupͷ࿈ಈઃఆΛߦ͏ඞཁ͕ ͋ͬͨҝ CanaryϦϦʔε ݱࡏ͸Capacity

    Providerػೳ͕ఏڙ͞Ε͍ͯΔҝɺCodeDeployͰ΋ ཁ݅͸ຬͨͤΔ͔΋͠Ε·ͤΜ (ະݕূ)
  15. Argo events Argo workflow Trigger ᶄ ϦϙδτϦߋ৽ ᶃ Webhook ϦΫΤετ

    ఆظfetch Blue Service Green Service Argo rollous ᶅ Sync (Deploy) શจݕࡧAPI ͷσϓϩΠ - શମ૾
  16. EKS on self managed nodesͱൺֱͯ͠ EKS ͸ΫϥελόʔδϣϯΞοϓ࡞ۀʹ͕͔͔࣌ؒΔ EKS (k8s)ͷֶशίετ͸ߴ͍ (

    ݁ߏߴ͍… ) EKS (k8s)͸֦ுੑ͕ߴ͘ɺ͍ΖΜͳϢʔεέʔεͰར༻ Ͱ͖Δ