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

prevs.io開発の裏側とコンテナ仮想化時代のAPI運用

 prevs.io開発の裏側とコンテナ仮想化時代のAPI運用

API Meetup Tokyo #7での発表資料です

Naoki Ainoya

March 27, 2015
Tweet

More Decks by Naoki Ainoya

Other Decks in Programming

Transcript

  1. QSFWTJP։ൃͷཪଆͱ
    ίϯςφԾ૝Խ࣌୅ͷ"1*ӡ༻
    BQJNFFUVQ
    naokiainoya

    View full-size slide

  2. "CPVUNF
    ૬໺୩௚थ
    "*/0:"/BPLJ
    αʔόαΠυΤϯδχΞ
    ainoya
    naokiainoya

    View full-size slide

  3. ͜͜Ͱಇ͍ͯ·͢ɻ

    View full-size slide

  4. A tiny deployment pipeline tool
    walter-cd/walter
    Open source project

    View full-size slide

  5. Personal project
    by
    @mookjp, and me

    View full-size slide

  6. prevs.io
    2"؀ڥߏஙαʔϏε
    ଟ෼
    1BB4
    %PDLFSPO"84

    View full-size slide

  7. prevs.ioͱ͸

    View full-size slide

  8. ᶃର৅ͱͳΔΞϓϦέʔγϣϯͷ
    HJUϦϙδτϦΛઃఆ

    View full-size slide

  9. ᶄHJUίϛοτ*%΍ϒϥϯν໊Λ
    ؚΉQSFWTJPͷ63-ʹΞΫηε
    ᶃର৅ͱͳΔΞϓϦέʔγϣϯͷ
    HJUϦϙδτϦΛઃఆ

    View full-size slide

  10. ᶄHJUίϛοτ*%΍ϒϥϯν໊Λ
    ؚΉQSFWTJPͷ63-ʹΞΫηε
    ᶅίϛοτ*%࣌఺ͰͷιʔεͰ
    8FCΞϓϦέʔγϣϯΛىಈ
    ᶃର৅ͱͳΔΞϓϦέʔγϣϯͷ
    HJUϦϙδτϦΛઃఆ
    Ϗϧυதը໘

    View full-size slide

  11. ᶄHJUίϛοτ*%΍ϒϥϯν໊Λ
    ؚΉQSFWTJPͷ63-ʹΞΫηε
    ᶅίϛοτ*%࣌఺ͰͷιʔεͰ
    8FCΞϓϦέʔγϣϯΛىಈ
    ᶃର৅ͱͳΔΞϓϦέʔγϣϯͷ
    HJUϦϙδτϦΛઃఆ
    ᶆ8FCΞϓϦέʔγϣϯىಈޙɼ
    Ϩεϙϯεฦ٫
    XFCϒϥ΢βը໘

    View full-size slide

  12. http://5c80e7d.yourapp.prevs.io
    http://893c39d.yourapp.prevs.io
    http://de2c1d1.yourapp.prevs.io
    http://a7e7b86.yourapp.prevs.io
    http://a53dd8d.yourapp.prevs.io
    http://010c1a0.yourapp.prevs.io
    http://47517fc.yourapp.prevs.io
    ιʔεόʔδϣϯͱΞϓϦέʔγϣϯͷ̍ର̍ରԠ

    View full-size slide

  13. Marketer
    Engineer
    ͜ͷલ΍ͬͯ͘ΕͨվળҊ"ͷ
    ը໘ɼͪΐͬͱݟͤͯ͘Εͳ͍ʁ
    ෼͔Γ·ͨ͠ʙɽվળҊ"Λ
    εςʔδϯάʹσϓϩΠ͠·ͨ͠ ྃղʔ
    ͋ͱͰݟͱ͘Ͷɽ
    ೔ޙ

    ͋Εʁ͜ͷը໘"Ҋͷ͡Όͳ͘ͳ
    ͍ʁͲ͏ͳͬͯΜͷʁ
    εςʔδϯάผͷҊ݅Ͱ࢖͍·
    ͢ʔɽ
    ͋ɼ͍͢·ͤΜଞͷ֬ೝͰ
    εςʔδϯά࢖ͬͯ·ͨ͠ʜɽ
    ૣ͘νΣοΫ͍ͨ͠Μ͚ͩͲʂ
    ͋ɼࠓσϓϩΠ͠ͳ͓͠·ͨ͠ʂ
    ʢࣗ෼Ͱ΍Ε͹͍͍ͷʹ

    ֬ೝͰ͖·ͨ͠ʔɽ
    ͋ͱվળҊ#΋΍ͬͺΓؾʹͳΔ
    ͔ΒεςʔδϯάͰݟͤͯ͞
    ͋ɼࠓଞͷ2"Ͱεςʔδϯά
    ࢖ͬͯͯͰ͖ͳ͍Ͱ͢ʜɽ
    ͏Δ͍͞ૣ͘΍Εʂ
    ୀ৬ͩ
    8FC։ൃ͋Δ͋Δ

    View full-size slide

  14. de2c1d1.yourapp.prevs.io
    deaafe1d1.yourapp.prevs.io
    2131ap23bg.yourapp.prevs.io
    12th9axp.yourapp.prevs.io
    12thx8axp.yourapp.prevs.io
    a0pbzx01.yourapp.prevs.io
    loi823xf.yourapp.prevs.io
    loi81x3xf.yourapp.prevs.io
    lo30x0p1q.yourapp.prevs.io
    lo30233z.yourapp.prevs.io
    Preview ALL
    versions of
    your application

    View full-size slide

  15. But,
    How It
    Works?
    de2c1d1.yourapp.prevs.io
    deaafe1d1.yourapp.prevs.io
    2131ap23bg.yourapp.prevs.io
    12th9axp.yourapp.prevs.io
    12thx8axp.yourapp.prevs.io
    a0pbzx01.yourapp.prevs.io
    loi823xf.yourapp.prevs.io
    loi81x3xf.yourapp.prevs.io
    lo30x0p1q.yourapp.prevs.io
    lo30233z.yourapp.prevs.io

    View full-size slide

  16. ΞϓϦέʔγϣϯͷόʔδϣϯຖʹ
    ͭͷίϯςφΛىಈ
    QSFWTJPͷΞʔΩςΫνϟ֓؍
    ͜͜Ͱ࢖ͬͯΔ

    View full-size slide

  17. %PDLFS͓͞Β͍
    %PDLFS͕ग़͖ͯͨͱ͜ΖͰʜ

    View full-size slide

  18. %PDLFS͓͞Β͍
    %PDLFSΛ࢖͏ར఺
    IUUQXXXTMJEFTIBSFOFUUJNPUIZTDBQBDIFDPOFV

    View full-size slide

  19. “The open-source application container engine”

    ίϯςφԾ૝Խٕज़͕ϕʔεͷ

    ΞϓϦέʔγϣϯ؅ཧιϦϡʔγϣϯ
    ࠓճ஫໨͍ͨͭ͠ͷϝϦοτ
    w ΞϓϦέʔγϣϯͷϙʔλϏϦςΟ޲্
    w ϋʔυ΢ΣΞϦιʔεͷந৅Խ

    View full-size slide

  20. ΞϓϦέʔγϣϯͷϙʔλϏϦςΟ޲্
    ‣ ্ཱ͕ͪΓ͕ૣ͍

    ϋΠύʔόΠβܕԾ૝Խʹൺ΂ɼىಈ͕ߴ଎

    http://image.slidesharecdn.com/why-docker-website-130719212914-phpapp01-131208123039-phpapp01/95/hypervisor-versus-linux-
    containers-with-docker-25-638.jpg?cb=1386527777

    View full-size slide

  21. ΞϓϦέʔγϣϯͷϙʔλϏϦςΟ޲্
    ‣ ΞϓϦέʔγϣϯͷ؅ཧͷ͠΍͢͞

    %PDLFSpMFʹઃఆΛهड़͢Δ͚ͩ


    View full-size slide

  22. IUUQXXXTMJEFTIBSFOFUGBTHPODBMWFTIZQFSWJTPSWFSTVTMJOVYDPOUBJOFST

    View full-size slide

  23. ϋʔυ΢ΣΞϦιʔεͷந৅Խ
    ‣ -JOVYDHSPVQT

    ίϯςφ୯ҐͰϋʔυ΢ΣΞϦιʔεͷ

    ׂΓ౰ͯΛ੍ޚ

    $  docker  run  -­‐c  256  -­‐m  512m  your-­‐rails-­‐app

    View full-size slide

  24. ϋʔυ΢ΣΞϦιʔεͷந৅Խ
    ‣ Φʔόʔϔουͷগͳ͞

    ϋΠύʔόΠβܕʹൺ΂͓ͯಘ
    http://www.slideshare.net/wavemakersoftware/webinar-docker-apaas-enterprise-innovation-and-trends-for-2015

    View full-size slide

  25. http://www.slideshare.net/mesosphere/apache-mesos-and-mesosphere-live-webcast-by-ceo-and-cofounder-florian-li

    View full-size slide

  26. ͭͷར఺͕΋ͨΒ͢΋ͷ
    ‣ ΞϓϦέʔγϣϯͷϙʔλϏϦςΟ޲্
    ‣ $*؀ڥߏஙͷ༰қԽ
    ‣ ϋʔυ΢ΣΞϦιʔεͷந৅Խ
    ‣ Ϧιʔεͷޮ཰తͳར༻

    View full-size slide

  27. $*؀ڥߏஙͷ༰қԽ
    ‣ ςετͷͨͼʹαʔό؀ڥΛ࢖͍ࣺͯɼ͕
    ؆୯ʹͰ͖ΔΑ͏ʹͳͬͨ

    View full-size slide

  28. $*؀ڥߏஙͷ༰қԽ
    ΞϓϦέʔγϣϯͷόʔδϣϯຖʹ
    ͭͷίϯςφΛىಈ

    View full-size slide

  29. $*؀ڥߏஙͷ༰қԽ
    ϦΫΤετ͕͋ͬͨ࣌఺Ͱର৅ͷEPDLFSJNBHFΛϏϧυ͢Δ

    View full-size slide

  30. $*؀ڥߏஙͷ༰қԽ
    ಉ࣌࠷େίϯςφ਺ͷઃఆʹԠ͡
    ݹ͍΋ͷ͔Βॱʹίϯςφ͸࡟আ͞ΕΔ

    View full-size slide

  31. $*؀ڥߏஙͷ༰қԽ
    ඞཁͳͱ͖ɼඞཁͳ෼͚ͩͷ
    2"؀ڥ͕࢖͑Δ

    View full-size slide

  32. ϋʔυ΢ΣΞϦιʔεͷޮ཰తͳར༻
    ‣ ىಈͷૣ͞ɼίϯςφ୯ҐͰͷ

    Ϧιʔε੍ݶ
    ‣ αʔϏεͷधཁʹԠ͡ɼϋʔυ΢ΣΞϦιʔ
    εΛޮ཰Α͘഑෼Ͱ͖ΔΑ͏ʹͳͬͨ

    View full-size slide

  33. Data Center Operating
    System
    Apache mesosphere
    σʔληϯλͷαʔό܈Λͻͱ·ͱΊͷ
    ϦιʔεͷΑ͏ʹѻ͑ΔγεςϜ
    ෆ׆αʔόΛۃݶ·ͰݮΒͨ͢ΊͷΞΠσΞ

    View full-size slide

  34. ࣌ؒ͝ͱʹϦιʔεधཁ͕
    ͹Β͹Βͳαʔό
    ෆ׆ঢ়ଶ͕ଟ͘ɼແବ
    धཁʹԠͯ͡
    ϦιʔεΛద੾ʹ഑෼
    http://www.slideshare.net/tomasbart/introduction-to-apache-mesos?related=3

    View full-size slide

  35. http://www.slideshare.net/mesosphere/apache-mesos-and-mesosphere-live-webcast-by-ceo-and-cofounder-florian-li

    View full-size slide

  36. %PDLFSͷपลٕज़͕

    "1*ʹ΋ͨΒ͢͜ͱ
    Ԡ༻ࣄྫͱ͜Ε͔Β

    View full-size slide

  37. w ΞϓϦέʔγϣϯͷϙʔλϏϦςΟ޲্
    w ϋʔυ΢ΣΞϦιʔεͷந৅Խ

    View full-size slide

  38. w ඇಉظ"1*
    w "1*ϧʔςΟϯά
    w "1*ΦʔέετϨʔγϣϯ
    º

    View full-size slide

  39. ඇಉظAPI
    º

    View full-size slide

  40. ඇಉظ"1*
    w ॲཧͷ։࢝ཁٻͱ݁Ռͷऔಘ͕ผͷ"1*
    w σʔλॲཧ
    w ूܭॲཧ
    w +PC2VFVFγεςϜ΁ͷΠϯλʔϑΣΠε
    http://www.slideshare.net/apijp/webapthegoodparts-p

    View full-size slide

  41. ඇಉظ"1*ͷΠϯϑϥ՝୊
    w +PC2VFVFγεςϜ΁ͷΠϯλʔϑΣΠε
    w ॲཧཁٻͷ࣌ؒଳʹϜϥ͕͋ͬͨΓ
    w +PCͷॲཧ಺༰ʹԠͯ͡ҟͳΔύοέʔδ͕
    ඞཁͩͬͨΓ

    View full-size slide

  42. ඇಉظ"1*αʔϏε*SPOJPͰͷEPDLFS׆༻ࣄྫ

    View full-size slide

  43. High-Scale Async Task Processing
      #  Worker  code  can  be  anything  you  want.  
      puts  "Payload:  #{params}"  
      puts  "Simulating  hard  work  for  5  seconds..."  
      5.times  do  |i|  
      puts  "Sleep  #{i}..."  
      sleep  1  
      end  
      puts  "Completed  at  #{Time.now}"  
      #  Create  hello.worker  file  
      #  define  the  runtime  language  
      runtime  'ruby'  
      #  exec  is  the  file  that  will  be  executed:  
      exec  'hello_worker.rb'  
      #  Upload  Worker  
      $  iron_worker  upload  hello  
      #  Queue  Workers  
      require  "iron_worker_ng"  
      client  =  IronWorkerNG::Client.new  
      #  launch  100  tasks  in  parallel  
      100.times  do  
      client.tasks.create("hello",  foo:  "bar")  
      end  
      #  Run  task  once  per  hour  at  high  priority  
      $  iron_worker  schedule  hello  \    
                       —start-­‐at  "2013-­‐01-­‐01T00:00:00-­‐04:00"  \  
               -­‐-­‐run-­‐every  3600  -­‐-­‐priority  2  

    View full-size slide

  44. http://blog.iron.io/2014/10/docker-in-production-what-weve-learned.html

    View full-size slide

  45. http://blog.iron.io/2014/10/docker-in-production-what-weve-learned.html

    View full-size slide

  46. http://blog.iron.io/2014/10/docker-in-production-what-weve-learned.html

    View full-size slide

  47. http://blog.iron.io/2014/10/docker-in-production-what-weve-learned.html

    View full-size slide

  48. http://blog.iron.io/2014/10/docker-in-production-what-weve-learned.html

    View full-size slide

  49. *SPOJP͕EPDLFS࠾༻Ͱಘͨ͜ͱ
    w XPSLFSͷෳ਺ϓϥοτϑΥʔϜରԠ

    ҟͳΔݴޠຖʹJNBHFΛ༻ҙ͢Δ͚ͩͰΑ͍
    w XPSLFSผͷϦιʔε഑෼

    λεΫ༏ઌ౓ͳͲʹԠͯ͡ʜ

    View full-size slide

  50. APIϧʔςΟϯά
    º

    View full-size slide

  51. "1*ϧʔςΟϯά
    w "1*όʔδϣϯW W WʜͳͲ

    ϧʔςΟϯάʹ·ͭΘΔ໰୊
    HJUIVC"1*"DDFQUϔομʹόʔδϣϯΛهड़

    View full-size slide

  52. "1*όʔδϣχϯάͷྫ
    w "1*όʔδϣϯW W Wʜ

    ϧʔςΟϯάʹ·ͭΘΔ໰୊
    1BSTFDPN"1*BQJͷύεͰόʔδϣϯࢦఆ

    View full-size slide

  53. "1*ϧʔςΟϯάͷΠϯϑϥ՝୊
    w ύε΍ϔομΛݩʹͨ͠ϧʔςΟϯά
    w ෳࡶͳϧʔϧ
    w "1*όʔδϣϯ͝ͱʹҟͳΔόοΫΤϯυαʔό
    w ผϒϥϯνɼผݴޠ
    w NJDSPTFSWJDFT

    View full-size slide

  54. "1*ϧʔςΟϯάͷΠϯϑϥ՝୊
    w όοΫΤϯυͷಈత੾Γସ͑
    w ΞϓϦέʔγϣϯΛEPDLFSίϯςφͰߏ੒
    ͢Δ৔߹͸ಛʹʜ

    View full-size slide

  55. mailgun/vulcand
    w "1*ͷϧʔςΟϯάΛϓϩάϥϚϒϧʹ

    ੍ޚͰ͖ΔϓϩΩγ

    View full-size slide

  56. mailgun/vulcand
    w ઃఆΛFUDE ෼ࢄ,74ʣʹอଘ

    όοΫΤϯυαʔό౳ͷಈతมߋ͕Մೳ


    FUDE ෼ࢄ,74

    ઃఆ؅ཧ
    όοΫΤϯυαʔό܈

    View full-size slide

  57. όοΫΤϯυͷಈతมߋ
    w FUDEͷ3&45"1*ܦ༝ͰͷઃఆมߋʹΑͬͯ

    ແఀࢭσϓϩΠ͕Մೳ

    FUDE ෼ࢄ,74

    ઃఆ؅ཧ
    όοΫΤϯυαʔό܈
    όοΫΤϯυαʔόͷ௥Ճ

    View full-size slide

  58. "1*ϧʔςΟϯάपΓͷΠϯϑϥ՝୊ղܾ
    w ෳࡶͳϧʔςΟϯάɼNJDSPTFSWJDF
    w ϓϩάϥϚϒϧͳϓϩΩγͱ͍͏ղܾࡦ
    w NBJMHVOWVMDBOE
    w ෼ࢄ,74ͰઃఆΛ؅ཧ͢ΔΞϓϩʔν

    View full-size slide

  59. "1*ϧʔςΟϯάपΓͷΠϯϑϥ՝୊ղܾ
    w ॊೈͳϧʔςΟϯά
    w αʔϏεͷૄ݁߹Խ
    w όοΫΤϯυͷಈతͳมߋ
    w ແఀࢭσϓϩΠ
    w ΦʔτεέʔϧʹΑΔϦιʔεར༻ޮ཰Խ
    w ΞϓϦέʔγϣϯͷίϯςφԽͱͷ૬৐ޮՌ

    View full-size slide

  60. ΞϓϦέʔγϣϯଆʹ"1*ϧʔςΟϯάͷϩδοΫ͕͋Δ৔߹
    αʔϏεͷංେԽΛট͖΍͍͢
    http://tech.gc.com/scaling-engineering-with-docker/

    View full-size slide

  61. WVMDBOEͷΑ͏ͳ"1*Ϛωδϝϯτ૚ʹϧʔςΟϯάΛ೚ͤΔ
    αʔϏεͷػೳ֦ு͕͠΍͘͢ͳΔ
    http://tech.gc.com/scaling-engineering-with-docker/

    View full-size slide

  62. APIΦʔέετϨʔγϣϯ
    º

    View full-size slide

  63. NJDSPTFSWJDFΞʔΩςΫνϟͷྲྀߦ
    খ͞ͳαʔϏε܈ͷू߹
    http://blog.giantswarm.io/docker-and-related-services-enable-a-future-of-microservices-for-everyone

    View full-size slide

  64. NJDSPTFSWJDFΞʔΩςΫνϟͷྲྀߦ

    ػೳ୯ҐͰνʔϜ͕͋Γɼ
    νʔϜ͝ͱʹҟͳΔݴޠɾΞϓϦέʔγϣϯ
    http://blog.giantswarm.io/docker-and-related-services-enable-a-future-of-microservices-for-everyone

    View full-size slide

  65. NJDSPTFSWJDFΞʔΩςΫνϟͷྲྀߦ
    ௒ۃ୺ͳྫ
    ̍Ϧιʔε̍ΞϓϦέʔγϣϯ
    http://blog.giantswarm.io/docker-and-related-services-enable-a-future-of-microservices-for-everyone

    View full-size slide

  66. NJDSPTFSWJDFTͱΫϥΠΞϯτ"1*ؒͷ
    ΠϯϐʔμϯεϛεϚον
    ΫϥΠΞϯτ͕ཉ͍͠"1*ͱγεςϜͷཻ౓͕ҟͳΔ
    http://blog.giantswarm.io/docker-and-related-services-enable-a-future-of-microservices-for-everyone

    View full-size slide

  67. ΦʔέετϨʔγϣϯ૚Ͱ

    ΫϥΠΞϯτʹ΍͍͞͠"1*Λ࡞Δ
    http://www.slideshare.net/apijp/webapthegoodparts-p

    View full-size slide

  68. NJDSPTFSWJDFΞʔΩςΫνϟʹ͓͚Δ։ൃ࣌ͷ՝୊
    ͓ޓ͍ͷ؀ڥΛߏஙͰ͖ͳ͍
    http://tech.gc.com/scaling-engineering-with-docker/

    View full-size slide

  69. NJDSPTFSWJDFΞʔΩςΫνϟʹ͓͚Δӡ༻࣌ͷ՝୊
    Πϯϑϥӡ༻νʔϜ΁ͷෛՙ
    http://tech.gc.com/scaling-engineering-with-docker/

    View full-size slide

  70. %PDLFSίϯςφʹΑΔαʔϏεͷந৅Խ
    ػೳ։ൃνʔϜ͕EPDLFSίϯςφΛ֤ࣗʹ࡞੒
    http://tech.gc.com/scaling-engineering-with-docker/

    View full-size slide

  71. %PDLFSίϯςφʹΑΔαʔϏεͷந৅Խ
    νʔϜؒͷ։ൃίϛϡχέʔγϣϯ͕
    %PDLFSpMFͱ͍͏γϯϓϧͳڞ௨ݴޠͰ؆୯ʹ
    http://tech.gc.com/scaling-engineering-with-docker/

    View full-size slide

  72. %PDLFSίϯςφʹΑΔαʔϏεͷந৅Խ
    ӡ༻νʔϜ͸ڞ௨Խ͞ΕͨEPDLFSΠϯϑϥ؀ڥͷ
    ໘౗ΛݟΔ͚ͩ
    http://tech.gc.com/scaling-engineering-with-docker/

    View full-size slide

  73. w ඇಉظ"1*
    w "1*ϧʔςΟϯά
    w "1*ΦʔέετϨʔγϣϯ
    º

    View full-size slide

  74. ͜Ε͔Βͷ"1*ӡ༻
    w EPDLFSؔ࿈Ͱ཈͓͖͍͑ͯͨར఺
    w ΞϓϦέʔγϣϯͷϙʔλϏϦςΟ޲্
    w Ϧιʔεͷར༻ޮ཰Խ

    View full-size slide

  75. ʠશ͕ͯ"1*ʹͳΔʡཪଆͰ
    ʠશ͕ͯίϯςφʡʹͳΖ͏ͱ͍ͯ͠Δ

    View full-size slide

  76. ϦϦʔε͸΋͏͠͹Β͓͘଴͍ͪͩ͘͞ʜ
    ໨Լ։ൃதͰ͢ɽ

    View full-size slide

  77. OSS͋Γ·͢
    https://github.com/mookjp/pool

    View full-size slide

  78. ଴ͯͳ͍͔ͨ͸ͪ͜Β
    https://github.com/mookjp/pool

    View full-size slide