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

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

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

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

E32fe793290d1e72b0a78648da9c687b?s=128

Naoki Ainoya

March 27, 2015
Tweet

Transcript

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

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

  3. ͜͜Ͱಇ͍ͯ·͢ɻ

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

  5. Personal project by @mookjp, and me

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

  8. º 

  9. prevs.ioͱ͸

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

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

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

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

  15. 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 ιʔεόʔδϣϯͱΞϓϦέʔγϣϯͷ̍ର̍ରԠ

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

    ͋Εʁ͜ͷը໘"Ҋͷ͡Όͳ͘ͳ ͍ʁͲ͏ͳͬͯΜͷʁ εςʔδϯάผͷҊ݅Ͱ࢖͍· ͢ʔɽ ͋ɼ͍͢·ͤΜଞͷ֬ೝͰ εςʔδϯά࢖ͬͯ·ͨ͠ʜɽ ૣ͘νΣοΫ͍ͨ͠Μ͚ͩͲʂ ͋ɼࠓσϓϩΠ͠ͳ͓͠·ͨ͠ʂ ʢࣗ෼Ͱ΍Ε͹͍͍ͷʹ ֬ೝͰ͖·ͨ͠ʔɽ ͋ͱվળҊ#΋΍ͬͺΓؾʹͳΔ ͔ΒεςʔδϯάͰݟͤͯ͞ ͋ɼࠓଞͷ2"Ͱεςʔδϯά ࢖ͬͯͯͰ͖ͳ͍Ͱ͢ʜɽ ͏Δ͍͞ૣ͘΍Εʂ ୀ৬ͩ 8FC։ൃ͋Δ͋Δ
  17. 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
  18. 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
  19. ΞϓϦέʔγϣϯͷόʔδϣϯຖʹ ͭͷίϯςφΛىಈ QSFWTJPͷΞʔΩςΫνϟ֓؍ ͜͜Ͱ࢖ͬͯΔ

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

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

  22. “The open-source application container engine”
 ίϯςφԾ૝Խٕज़͕ϕʔεͷ
 ΞϓϦέʔγϣϯ؅ཧιϦϡʔγϣϯ ࠓճ஫໨͍ͨͭ͠ͷϝϦοτ w ΞϓϦέʔγϣϯͷϙʔλϏϦςΟ޲্

    w ϋʔυ΢ΣΞϦιʔεͷந৅Խ
  23. ΞϓϦέʔγϣϯͷϙʔλϏϦςΟ޲্ ‣ ্ཱ͕ͪΓ͕ૣ͍
 ϋΠύʔόΠβܕԾ૝Խʹൺ΂ɼىಈ͕ߴ଎
 http://image.slidesharecdn.com/why-docker-website-130719212914-phpapp01-131208123039-phpapp01/95/hypervisor-versus-linux- containers-with-docker-25-638.jpg?cb=1386527777

  24. ΞϓϦέʔγϣϯͷϙʔλϏϦςΟ޲্ ‣ ΞϓϦέʔγϣϯͷ؅ཧͷ͠΍͢͞
 %PDLFSpMFʹઃఆΛهड़͢Δ͚ͩ


  25. IUUQXXXTMJEFTIBSFOFUGBTHPODBMWFTIZQFSWJTPSWFSTVTMJOVYDPOUBJOFST

  26. ϋʔυ΢ΣΞϦιʔεͷந৅Խ ‣ -JOVYDHSPVQT
 ίϯςφ୯ҐͰϋʔυ΢ΣΞϦιʔεͷ
 ׂΓ౰ͯΛ੍ޚ
 $  docker  run  -­‐c  256

     -­‐m  512m  your-­‐rails-­‐app
  27. ϋʔυ΢ΣΞϦιʔεͷந৅Խ ‣ Φʔόʔϔουͷগͳ͞
 ϋΠύʔόΠβܕʹൺ΂͓ͯಘ http://www.slideshare.net/wavemakersoftware/webinar-docker-apaas-enterprise-innovation-and-trends-for-2015

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

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

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

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

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

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

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

  35. ϋʔυ΢ΣΞϦιʔεͷޮ཰తͳར༻ ‣ ىಈͷૣ͞ɼίϯςφ୯ҐͰͷ
 Ϧιʔε੍ݶ ‣ αʔϏεͷधཁʹԠ͡ɼϋʔυ΢ΣΞϦιʔ εΛޮ཰Α͘഑෼Ͱ͖ΔΑ͏ʹͳͬͨ

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

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

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

  40. %PDLFSͷपลٕज़͕
 "1*ʹ΋ͨΒ͢͜ͱ Ԡ༻ࣄྫͱ͜Ε͔Β

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

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

  43. ඇಉظAPI º

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

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

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

  47. 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  
  48. http://blog.iron.io/2014/10/docker-in-production-what-weve-learned.html

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

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

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

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

  53. *SPOJP͕EPDLFS࠾༻Ͱಘͨ͜ͱ w XPSLFSͷෳ਺ϓϥοτϑΥʔϜରԠ
 ҟͳΔݴޠຖʹJNBHFΛ༻ҙ͢Δ͚ͩͰΑ͍ w XPSLFSผͷϦιʔε഑෼
 λεΫ༏ઌ౓ͳͲʹԠͯ͡ʜ

  54. APIϧʔςΟϯά º

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

  56. "1*όʔδϣχϯάͷྫ w "1*όʔδϣϯW W Wʜ
 ϧʔςΟϯάʹ·ͭΘΔ໰୊ 1BSTFDPN"1*BQJͷύεͰόʔδϣϯࢦఆ

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

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

  59. mailgun/vulcand w "1*ͷϧʔςΟϯάΛϓϩάϥϚϒϧʹ
 ੍ޚͰ͖ΔϓϩΩγ

  60. mailgun/vulcand w ઃఆΛFUDE ෼ࢄ,74ʣʹอଘ
 όοΫΤϯυαʔό౳ͷಈతมߋ͕Մೳ
 
 FUDE ෼ࢄ,74  ઃఆ؅ཧ

    όοΫΤϯυαʔό܈
  61. όοΫΤϯυͷಈతมߋ w FUDEͷ3&45"1*ܦ༝ͰͷઃఆมߋʹΑͬͯ
 ແఀࢭσϓϩΠ͕Մೳ
 FUDE ෼ࢄ,74  ઃఆ؅ཧ όοΫΤϯυαʔό܈ όοΫΤϯυαʔόͷ௥Ճ

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

  63. "1*ϧʔςΟϯάपΓͷΠϯϑϥ՝୊ղܾ w ॊೈͳϧʔςΟϯά w αʔϏεͷૄ݁߹Խ w όοΫΤϯυͷಈతͳมߋ w ແఀࢭσϓϩΠ w

    ΦʔτεέʔϧʹΑΔϦιʔεར༻ޮ཰Խ w ΞϓϦέʔγϣϯͷίϯςφԽͱͷ૬৐ޮՌ
  64. ΞϓϦέʔγϣϯଆʹ"1*ϧʔςΟϯάͷϩδοΫ͕͋Δ৔߹ αʔϏεͷංେԽΛট͖΍͍͢ http://tech.gc.com/scaling-engineering-with-docker/

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

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

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

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

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

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

  71. ΦʔέετϨʔγϣϯ૚Ͱ
 ΫϥΠΞϯτʹ΍͍͞͠"1*Λ࡞Δ http://www.slideshare.net/apijp/webapthegoodparts-p

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

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

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

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

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

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

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

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

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

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

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