マイクロサービス化を支える継続的切り替え術

0f54aa7d6df3dbcbde91a02d0e2f75d5?s=47 Shia
August 24, 2019

 マイクロサービス化を支える継続的切り替え術

0f54aa7d6df3dbcbde91a02d0e2f75d5?s=128

Shia

August 24, 2019
Tweet

Transcript

  1. ϚΠΫϩαʔϏεԽΛࢧ ͑Δܧଓత੾Γସ͑ज़ TIJB!ΫοΫύου

  2. ࣗݾ঺հ w γϜαϯϤϯ !TIJB  w ΫοΫύουגࣜձࣾ

  3. ࠓ೔ͷ࿩͸ wϞόΕͽ෼཭ ‣ γεςϜ෼཭࣌ͷ੾Γସ͑ઓུ

  4. ϞόΕͽͱ͸ wΨϥέʔ޲͚ͷαʔϏε wػೳ௥Ճ͸΄΅͍ͯ͠ͳ͍ wΞΫςΟϒͳϢʔβʔ͸ݮΒͳ͍

  5. ෼཭ͷ֓ཁ

  6. ෼཭ͷϙΠϯτ wڊେͳϞϊϦγοΫΞϓϦ͔Βͷ෼཭ w"1*ܦ༝ͰϦιʔεΛऔಘ͢Δ ‣ %#XJUIOαʔϏε͸ਏ͍ ‣ ͢Ͱʹ࢖͑ΔϦιʔε"1*͕͋Δ

  7. ෼཭ͷϙΠϯτ DB

  8. ෼཭ͷϙΠϯτ DB API αʔϏε

  9. ෼཭ͷϙΠϯτ w݁ՌɺϏδωεϩδοΫ͸΄΅࠶࣮૷ʹ

  10. ෼཭ͷن໛ײ wΤϯυϙΠϯτͷ਺͸ݸ΄Ͳ w෼཭ݩίʔυ͸໿ສߦ΄Ͳ

  11. ੾Γସ͑ઓུΛߟ͑Δ

  12. ཁ݅ wҰؾʹ੾Γସ͑ͳ͍ʂʂʂʂʂ ‣ ࣄނͬͨ৔߹ɺ֬ೝ͠ͳ͍ͱ͍͚ͳ͍ίʔ υͷ෼ྔ͕ଟ͍ ‣ ͦ΋ͦ΋ࣄނΔ֬཰͕ߴ͍͔Β΍Ί͓͍ͯ ͨ΄͏͕͍͍

  13. ͭ·ΓɺͲͬͪʹྲྀ͔͢ Ͱ͖Δ͚ͩࡉ੍͔͘ޚ͍ͨ͠

  14. چαʔϏε ཁ݅ ৽αʔϏε GET /recipes

  15. چαʔϏε ཁ݅ ৽αʔϏε ͦΕҎ֎ GET /recipes

  16. ख๏MPDBUJPOͰؤுΔ location /recipes { proxy_pass new_service; } location / {

    proxy_pass old_service; }
  17. چαʔϏε ৽αʔϏε ͦΕҎ֎ GET /recipes ख๏MPDBUJPOͰؤுΔ

  18. ख๏MPDBUJPOͰؤுΔ  ࣮૷Λ༻ҙ͢Δ  ৽αʔϏεΛσϓϩΠ  /(*/9ͷઃఆΛߋ৽ͯ͠Ϧϩʔυ

  19. ख๏MPDBUJPOͰ͸ؤுΕͳ͍ wσϓϩΠຖʹ/(*/9ͷઃఆΛॻ͖௚͠ ͍ͨʁ wύε͸ಉ͚ͩ͡Ͳॲཧ͸ҧ͏৔߹͸ʁ ‣ (&5SFDJQFTWT1045SFDJQFT

  20. ਅͷཁ݅ w੾Γସ͑खॱΛ؆୯ʹ͍ͨ͠ wΤϯυϙΠϯτ ΞΫγϣϯ ୯ҐͰ੾ Γସ͍͑ͨ

  21. ৽αʔϏεʹ੾Γସ͑ͷ ܾఆݖΛҠৡ͢Δ

  22. w৽αʔϏε͸ ‣ ॲཧՄೳͳΒॲཧͯ͠ฦ͢ ‣ ແཧͳΒແཧͱฦ͢ ख๏੾Γସ͑ͷܾఆݖΛҠৡ͢Δ

  23. ख๏੾Γସ͑ͷܾఆݖΛҠৡ͢Δ چαʔϏε ৽αʔϏε

  24. ख๏੾Γସ͑ͷܾఆݖΛҠৡ͢Δ چαʔϏε ৽αʔϏε GET /recipes 200 OK 200 OK

  25. ख๏੾Γସ͑ͷܾఆݖΛҠৡ͢Δ چαʔϏε ৽αʔϏε GET /recipes Ҏ֎ ະ࣮૷ͩΑʂʂ

  26. ख๏੾Γସ͑ͷܾఆݖΛҠৡ͢Δ چαʔϏε ৽αʔϏε GET /recipes Ҏ֎ 200 OK 200 OK

    ະ࣮૷ͩΑʂʂ
  27. w৽αʔϏεଆΛσϓϩΠ͢Δ͚ͩͰ͢΂ ͕ͯ׬݁͢Δ ख๏੾Γସ͑ͷܾఆݖΛҠৡ͢Δ

  28. ख๏࣮૷ྫ upstream backend { server new_service max_fails=0; server old_service backup;

    } server { location / { proxy_next_upstream http_503 non_idempotent; proxy_pass backend; } } ৄ͍͠આ໌͸͜͜ͰݟΕ·͢ https://techlife.cookpad.com/entry/2019/03/05/115000
  29. ऴΘΓ wͪΐͬͱؤுΕ͹ࡉ͔͍୯ҐͰɺ҆શʹ ָͯ͠੾Γସ͕͑Ͱ͖Δ