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

kuroko2の近況とクックパッドのバッチ周りの概況

 kuroko2の近況とクックパッドのバッチ周りの概況

Eisuke Oishi

June 07, 2017
Tweet

More Decks by Eisuke Oishi

Other Decks in Technology

Transcript

  1. LVSPLPͱ͸ • web-based job scheduler / workflow engine. • ࢀߟࢿྉ

    • repository: https://github.com/cookpad/kuroko2 • ΫοΫύουͷδϣϒ؅ཧγεςϜ kuroko2 ͷ঺հ • The Design Philosophy of Kuroko2 • kuroko2 documentation
  2. LVSPLPͷԊֵ • 2015/04 ౰ٕ࣌ज़෦௕ͩͬͨ Naoto Takai (ݱΤϯδχΞ౷ׅϚωʔδϟʔ )ͷεΧϯΫ ϫʔΫʹΑͬͯ։ൃ͞Εɺࣾ಺ʹಋೖ͞ΕΔ •

    2015/05 େੴ͕ kuroko2 ͷϝϯςΛҾ͖ܧ͙ • 2015/12 ΫοΫύου։ൃऀϒϩάʮΫοΫύουͷδϣϒ؅ཧγεςϜ kuroko2 ͷ঺ հʯ • OSSʹ͸͠ͳ͍ͭ΋Γͩͬͨ • 2016/10 ಥવͷOSSԽ • ॾൠͷࣄ৘ʹΑΓαΠϨϯτͳϦϦʔε • ʮOSS ʹͳͬͨ Kuroko2 ΛͲ͜ΑΓ΋ૣ͘ಋೖͨ͠ͷͰ঺հ͍ͨ͠ϒϩάʯͰ OSSԽ͕ੈؒʹ஌Ε౉Δ • 2017/01 Naoto Takai ͷࣾ಺޲͚LTʮThe Design Philosophy of Kuroko2ʯެ։
  3. LVSPLPͷํ਑ • ݱ࣮తͳӡ༻Λݟਾ͑ͨ҆ఆͨ͠ઃܭΛอͭ (The Design Philosophy of Kuroko2 p.20) •

    ൥ࡶʹͳΓ͕ͪͳόονδϣϒ؅ཧͷ໰୊ΛUI/UXͳͲͰղ ܾ͢Δ • γϯϓϦγςΟ • εέδϡʔϥʔͱ൚༻ੑͷߴ͍ϫʔΫϑϩʔ؅ཧʹప͢Δ • ͏·͘֎ͷػߏͱ࿈ܞ͢Δ (Bricolage, Hako) • ඞཁͳ෦෼͚ͩʹ։͔Ε֦ͨுੑ
  4. ΧελϜλεΫ 1. λεΫͷ࡞੒ $ cd your_kurko2_rails_apps/ $ mkdir -p lib/kuroko2/workflow/task/

    $ cat > my_project_runner.rb module Kuroko2 module Workflow module Task class MyProjectRunner < Execute def chdir '/home/alice/my_project' end def shell "bundle exec ./bin/rails runner -e production #{Shellwords.escape(option)}" end end end end end 2. kuroko2.yml ΁એݴ custom_tasks: my_project_runner: MyProjectRunner 3. kuroko2 script env: VAL1=A env: VAL2=B my_project_runner: MyProject::Batch1.run
  5. ,VSPLP"QQMJDBUJPO$POUSPMMFS֦ு 1. extentionͷ࡞੒ $ cd your_kurko2_rails_apps/ $ cat > lib/controller_extention.rb

    module ControllerExtention extend ActiveSupport::Concern included do before_action :additional_before_action end private def additional_before_action if signed_in? # do something end end end 2. kuroko2.yml ΁એݴ extentions: controller: - ControllerExtention
  6. ,VSPLP"QQMJDBUJPO$POUSPMMFS֦ுͷ࢖͍ॴ • ΫοΫύουͰ͸ Raven::Transports::Fluentd ΁ͷί ϯςΩετ௥ՃͳͲͰར༻ (Τϥʔ௨஌) • ϩάͳͲͷτϨʔγϯά •

    ϢʔβʔຖͷΞΫηε੍ݶ • Controller͚͍ͩ·ͷͱ͜ΖରԠ͍ͯ͠Δ͕ɺ΋͠ඞ ཁέʔε͕͋Ε͹֦ுϙΠϯτΛ૿΍͢͜ͱ͸ݕ౼͠ ͍ͨ
  7. Α͋͘Δ࣭໰ • OSSͷ kuroko2 ͸ΫοΫύουࣾ಺Ͱ࢖͍ͬͯΔͷʁ • YES • ࣾ಺όʔδϣϯ͸ଘࡏ͍ͯ͠ͳ͍ •

    masterϒϥϯνͷϦϦʔε௚લͷ΋ͷΛৗʹ࢖͏Α͏ ʹͯ͠ɺࣾ಺Ͱ໰୊ͳ͍͔֬ೝͯ͠ϦϦʔε͍ͯ͠Δ
  8. ن໛ • ໿700ݸͷόονδϣϒ (2017/06/01࣌఺) • Ұ೔͋ͨΓͷ࣮ߦճ਺͸ ໿6000 • kuroko2 ͷ্Ͱ͢΂ͯ؅ཧ

    • αʔϏεຖʹ෼͚ͣʹίϯιʔϧ͸͚̍ͭͩ • ͦ͜·Ͱେن໛Ͱ΋ͳ͍ (ͱࢥ͍ͬͯΔ)
  9. ߏ੒ • worker (commnad-executor) ͷ਺ ໿230 • 34ݸͷworker༻Πϯελϯε • ൚༻

    worker༻Πϯελϯε x 10 • CPUΛ࢖͏όον༻Πϯελϯε x 2 • Hako (docker) ΞϓϦέʔγϣϯ༻ x 3 • େྔϝʔϧ഑৴༻ x 8 • ϓογϡ௨஌༻ x 4 • DWH༻ x 1 • ͦͷଞ x 7
  10. ؂ࢹ • CPU, Disk, Network, ࢮ׆؂ࢹ ͳͲͷఆܗͷ΋ͷʹՃ͑ͯɺδϣϒͷঢ়گΛ؂ࢹ • OSS kuroko2

    ʹ΋͋ΔҎԼͷAPIΛఆظతʹୟ͍͍ͯΔ • /v1/stats/waiting_execution • /v1/stats/instance
  11. LVSPLPͷσϓϩΠ • kuroko2ຊମ͸ capistrano ͰσϓϩΠ • console, scheduler, processor, command-

    executer ͦΕͧΕʹroleΛ෼͚ͯσϓϩΠͯ͠ worker Λ restart • HUPγάφϧʹΑΔ graceful shutdown
  12. όονδϣϒͷσϓϩΠ • όονͷσϓϩΠ͸ͦΕͧΕͷΞϓϦέʔγϣϯຖʹ ߦ͍ͬͯΔ • ࠷ۙͷ΋ͷ͸ hako oneshot Ͱ ECS

    λεΫΛ࣮ߦ͠ ͍ͯΔͷͰ worker ʹରͯ͠഑෍͸͍Βͳ͍ • ݹ͍ΞϓϦέʔγϣϯ͸ worker಺΁഑෍͍ͯ͠Δ
  13. όονδϣϒͷ؅ཧ • όονδϣϒ͸֤։ൃऀɺ෦ॺ͕੹೚Λ΋ͭ • δϣϒ͕ࣦഊͨ͠৔߹͸ɺ୲౰ऀʹϝʔϧ΍SlackͰ௨஌ɺ֤୲౰෦ॺͰϦ τϥΠͳͲͷରԠ͢Δ • δϣϒͷ description ʹো֐࣌ͷӨڹɺରԠํ๏ɺϦτϥΠͷඞཁੑͳͲΛ

    ॻ͍͓ͯ͘͜ͱͰେ͖ͳো֐࣌ʹଞͷ෦ॺ(SRE ͳͲ)Ͱ΋ରԠͰ͖ΔΑ͏ʹ ͍ͯ͠Δ • ϩά͸ kuroko2 ͔Β AWS CloudWatch Logs ʹอଘͭͭ͠ɺΞϓϦέʔγϣ ϯ͕ͦΕͧΕ؅ཧ͍ͯ͠Δϩά΋ଘࡏ͍ͯ͠Δ • ෦ॺ΍δϣϒʹ·͕ͨͬͨδϣϒͷ࿈ܞʹ͸ wait λεΫ͕Α͘࢖ΘΕ͍ͯΔ
  14. ·ͱΊ • OSS ͷ kuroko2 Λ࢖͍ͬͯ·͢ • αʔϏεຖʹ෼͚ΔͷͰ͸ͳͯ͘ɺ΄΅͢΂ͯͷδϣϒΛ1ͭͷkuroko2 ΞϓϦͰ؅ཧ •

    தن໛͘Β͍? • 700ݸͷδϣϒ • 6000࣮ߦ/೔ • 230 worker • kuroko2 ͷػೳΛར༻ͨ͠όονઐ༻ͷ؂ࢹ߲໨͕͋Δ • kuroko2 ͷ job definition ͷςϯϓϨ௨Γʹӡ༻