Share
Embed
1400万ユーザーのWebサービスを 15年運用して考える、 Javaである理由
masaozi3
May 18, 2019
Transcript
86 slides
-
w ϑϦϡʔגࣜձࣾ!ژ w ࣾձਓྺ+BWBྺ w +BWBͱ4QSJOHͰz(*3-4Λ)"11:ʹz͢ΔࣄΛ͍ͯ͠·͢ w େֶ࣌1ZUIPOͰ8FCΞϓϦΛ։ൃ ͖ͳͷ ษڧձͷελοϑɺϊϕϧςΟͷൃɺ͓͍͍͓͠ञ
ϔΞΧϥʔϒϦʔνɺͷૹঢ়گΛோΊΔ ླਅੜ !NBTBP[J !2 ʘ·͓͞Ͱ͢ʗ w w w -
w ࠓͷΰʔϧ w ͷ͖͔͚ͬ w ฐࣾͷαʔϏεͱٕज़બͷ w ʑͷӡ༻͔ΒΈΔ+BWBͰ͋Δཧ༝ w ʲ͓·͚ʳ+%,ͷҠߦͷ
w ݁ w ͓͠Βͤ ࠓ͢͜ͱ !3 ੩͔ʙʹฉ͘ΑΓ ΘʔΘʔݴ͍ͳ͕Β ฉ͍ͯΒ͑Εخ͍͠Ͱ͢ʂ -
w ࠓͷΰʔϧ w ͷ͖͔͚ͬ w ฐࣾͷαʔϏεͱٕज़બͷ w ʑͷӡ༻͔ΒΈΔ+BWBͰ͋Δཧ༝ w ʲ͓·͚ʳ+%,ͷҠߦͷ
w ݁ w ͓͠Βͤ ࠓ͢͜ͱ !4 ʮӡ༻ͯ͠ʯͱ͍͍ͭͭ ϲ݄͔͠ݟͯͳ͍ͷͰ ௐͨใ͋Γ·͢ -
w 4DBMB͕େ͖ͳઌഐ͕+BWBΛॻ͍͍ͯͯʑۤͦ͠͏Ͱ͋Δ w पғͷ༑ਓ͕ʮ+BWBઈରॻ͖ͨ͘ͳ͍ʯͳͲݴ͍ͬͯͯɺ ͳΜ͔ͩ൵͍͠ w ͱ͍͑ࣗ+BWB͕͖͘͢͝ͱ͍͏Θ͚Ͱͳ͍ w ྡͷνʔϜαʔόʔαΠυ,PUMJOΛݕ౼͍ͯ͠ΔΑ͏ͩʁ w
ผͷݴޠΛݕ౼ͨ͜͠ͱ͋ΔΒ͍͠ɹɹɹɹɹͳͲͳͲ ͷ͖͔͚ͬ !8 -
w 4DBMB͕େ͖ͳઌഐ͕ʑۤͦ͠͏Ͱ͋Δ w पғͷ༑ਓ͕ʮ+BWBઈରॻ͖ͨ͘ͳ͍ʯͳͲݴ͍ͬͯͯɺͳΜ͔ͩ൵ ͍͠ w ͱ͍͑ࣗ+BWB͕͖͘͢͝ͱ͍͏Θ͚Ͱͳ͍ w ྡͷνʔϜαʔόαΠυ,PUMJOΛݕ౼͍ͯ͠ΔΑ͏ͩʁ w
ผͷݴޠΛݕ౼ͨ͜͠ͱ͋ΔΒ͍͠ ͷ͖͔͚ͬ !9 ͳΜͰ+BWBΛ͍ͬͯΔΜͩΖ͏ʁ +BWB͕ద͍ͯ͠ΔͷͬͯͳΜͩΖ͏ʁ ଐ͞ΕͨϓϩμΫτ͕+BWB͔ͩͬͨΒ Ҏ֎ͷཧ༝ͳ͍ͷͩΖ͏͔ʁ -
w 4DBMB͕େ͖ͳઌഐ͕ʑۤͦ͠͏Ͱ͋Δ w पғͷ༑ਓ͕ʮ+BWBઈରॻ͖ͨ͘ͳ͍ʯͳͲݴ͍ͬͯͯɺͳΜ͔ͩ൵ ͍͠ w ͱ͍͑ࣗ+BWB͕͖͘͢͝ͱ͍͏Θ͚Ͱͳ͍ w ྡͷνʔϜαʔόαΠυ,PUMJOΛݕ౼͍ͯ͠ΔΑ͏ͩʁ w
ผͷݴޠΛݕ౼ͨ͜͠ͱ͋ΔΒ͍͠ ͷ͖͔͚ͬ !10 ⾠ܾͯ͠ϚαΧϦΛ͛ʹདྷͨͷͰͳ͍Ͱ͢ ʮ͏͔Βʹɺྑ͞ΛΓ͍ͨʯ Έͳ͞Μͷ+BWBΛબΜͩཧ༝ +BWBͷ͖ͳͱ͜ΖͳͲͥͻฉ͖͍ͨͰ͢ -
w Ψϥέʔ͚αΠτΛϦϦʔε αʔόʔͷ࣮+BWB w εϚϗ͚αΠτωΠςΟϒΞϓϦΛϦϦʔε αΠτΞϓϦͷαʔόʔͱʹ+BWB "OESPJEΞϓϦ+BWB w ݱࡏʜ ਓͰӡ༻։ൃத
ฐࣾͷαʔϏεϐΫτϦϯΫ !15 ࠓมΘΒͣ+BWB+BWB͍ͯ͠Δʂ -
ٕज़બͷ !21 Ψϥέʔ͚αʔϏε͕+BWBͰ͋ͬͨཧ༝ w ΤϯλʔςΠϯϝϯτܥͷ͜ͱ͍ͨ͠ʂ w ଞͷݴޠݕ౼ͯ͠Έͨˠબࢶ͕গͳ͍ w "QBDIF5PNDBUͰͭ͘ΔΑ͏ͳͷ w
ࣾʹ+BWBͷݟ͕ཷ·͍ͬͯΔͳʜ 1FSM "QBDIF "QBDIF 5PNDBU +BWB -
ٕज़બͷ !22 Ψϥέʔ͚αʔϏε͕+BWBͰ͋ͬͨཧ༝ w ΤϯλʔςΠϯϝϯτܥͷ͜ͱ͍ͨ͠ʂ w ଞͷݴޠݕ౼ͯ͠Έͨˠબࢶ͕গͳ͍ w "QBDIF5PNDBUͰͭ͘ΔΑ͏ͳͷ w
ࣾʹ+BWBͷݟ͕ཷ·͍ͬͯΔͳʜ +BWB ݟ͕ઌબࢶͷগͳ͞Ͱ+BWBʹ -
w ʙͷϦϦʔεʹ͚ٕͯज़ݕ౼Λ͢Δ +BWBʹݶΒͣଞͷݴޠϑϨʔϜϫʔΫݕ౼ w ࣾࢿ࢈׆༻͍ͨ͠ͷͰ+7.ݴޠ͕ྑ͍ Ψϥέʔ͚αʔϏεͰ։ൃͨ͠ϥΠϒϥϦͳͲ w 1MBZͱ4DBMBͷΈ߹Θ͕ͤ҆ఆ͍ͯ͠ͳ͍࣌ظ ٕज़બͷ !26
εϚϗ͚αʔϏε͕+BWBʹͳͬͨཧ༝ 4 1MBZ +BWB ʜ 1)1 4DBMB -
w ʙͷϦϦʔεʹ͚ٕͯज़ݕ౼Λ͢Δ +BWBʹݶΒͣଞͷݴޠϑϨʔϜϫʔΫݕ౼ w ࣾࢿ࢈׆༻͍ͨ͠ͷͰ+7.ݴޠ͕ྑ͍ Ψϥέʔ͚αʔϏεͰ։ൃͨ͠ϥΠϒϥϦͳͲ w 1MBZͱ4DBMBͷΈ߹Θ͕ͤ҆ఆ͍ͯ͠ͳ͍࣌ظ ٕज़બͷ !27
εϚϗ͚αʔϏε͕+BWBʹͳͬͨཧ༝ 4 1MBZ +BWB ʜ 1)1 4DBMB ҆ఆͱલαʔϏεɺ+7.Ͱ+BWBʹ -
ϥΠϒϥϦଆͰ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !38 public interface VegetableService { /** *
ݱࡏͷ०ͷࡊΛฦ͢ * @return */ Vegetable getInSeason(List<Vegetable> vegetables); } -
ར༻ଆͰ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !39 public class KithenController { @Resource VegetableService
vegetableService; @RequestMapping(path = "/recommend") public ModelAndView recommendMenu() { List<Vegetable> vegetables = refrigeratorService.findVegetables(); Vegetable vegetable = vegetableService.getInSeason(vegetables); //ฦ͖ͬͯͨࡊͰ͓͢͢ΊͷݙཱΛߟ͑Δ… return new ModelAndView("/reccomend.html"); } } -
ར༻ଆͰ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !40 public class KithenController { @Resource VegetableService
vegetableService; @RequestMapping(path = "/recommend") public ModelAndView recommendMenu() { List<Vegetable> vegetables = refrigeratorService.findVegetables(); Vegetable vegetable = vegetableService.getInSeason(vegetables); //ฦ͖ͬͯͨࡊͰ͓͢͢ΊͷݙཱΛߟ͑Δ… return new ModelAndView("/reccomend.html"); } } ०ͷࡊͬͯ Ұݸ͡Όͳ͍Αͳ -
ϥΠϒϥϦଆͰ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !41 public interface VegetableService { /** *
ݱࡏͷ०ͷࡊΛฦ͢ * @return */ List<Vegetable> getInSeason(List<Vegetable> vegetables); } -
ར༻ଆͰ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !42 public class KithenController { @Resource VegetableService
vegetableService; @RequestMapping(path = "/recommend") public ModelAndView recommendMenu() { List<Vegetable> stockVegetables = refrigeratorService.findVegetables(); List<Vegetable> vegetables = vegetableService.getInSeason(stockVegetables); //ฦ͖ͬͯͨࡊͰ͓͢͢ΊͷݙཱΛߟ͑Δ… return new ModelAndView("/reccomend.html"); } } -
ར༻ଆͰ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !43 public class KithenController { @Resource VegetableService
vegetableService; @RequestMapping(path = "/recommend") public ModelAndView recommendMenu() { List<Vegetable> stockVegetables = refrigeratorService.findVegetables(); List<Vegetable> vegetables = vegetableService.getInSeason(stockVegetables); //ฦ͖ͬͯͨࡊͰ͓͢͢ΊͷݙཱΛߟ͑Δ… return new ModelAndView("/reccomend.html"); } } ίϯύΠϧ Τϥʔ -
ಉ͘͡ར༻ଆͰ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !44 public class ShoppingController { @Resource VegetableService vegetableService;
@RequestMapping(path = "/market") public ModelAndView market() { List<Vegetable> vegetables = specialPriceService.findVegetables(); Vegetable vegetable = vegetableService.getInSeason(vegetables); //ฦ͖ͬͯͨ०ͷࡊΛͲ͜… return new ModelAndView("/market.html"); } } Θʔ͍͢·ͤΜ ͦͬͪͬͯͨ -
ϥΠϒϥϦଆͰ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !47 public interface VegetableService { /** *
ݱࡏͷ०ͷࡊΛฦ͢ * @return */ List<Vegetable> getInSeason(List<Vegetable> vegetables); } -
ϥΠϒϥϦଆͰ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !48 public interface VegetableService { /** *
ݱࡏͷ०ͷࡊΛฦ͢ * @return */ List<Vegetable> getInSeason(List<Vegetable> vegetables) throws NoVegetablesException; } ۭͳΒ ྫ֎ʹͨ͘͠ ͳ͖ͬͯͨ -
ར༻ଆͰ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !49 List<Vegetable> vegetables = vegetableService.getInSeason(stockVegetables); try
{ List<Vegetable> vegetables = vegetableService.getInSeason(stockVegetables); } catch (NoVegetablesException e) { e.printStackTrace(); } ,JUDIFO$POUSPMMFSͱ 4IPQQJOH$POUSPMMFSͰ ͚ͬͯͨͬͳʙ -
ར༻ଆͰ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !50 List<Vegetable> vegetables = vegetableService.getInSeason(stockVegetables); try
{ List<Vegetable> vegetables = vegetableService.getInSeason(stockVegetables); } catch (NoVegetablesException e) { e.printStackTrace(); } ίϯύΠϧ Τϥʔ -
ػೳՃ͞Ε͍ͯͨʂ ੩తܕ͚ͰίϯύΠϥ͕ڧྗ !51 public class FlyerController { @Resource VegetableService vegetableService;
@RequestMapping(path = "/available") public ModelAndView availableFlyerView() { List<Vegetable> vegetables = specialPriceService.findVegetables(); Vegetable vegetable = vegetableService.getInSeason(vegetables); //ฦ͖ͬͯͨ०ͷࡊΛͲ͜… return new ModelAndView(“/available.html"); } } Θʔ͓ ͦͬͪͬͯͨ -
Ϣʔβʔ͕ສਓ͍Δͱʮكͳҟৗܥʯׂ͕ͱΑ͘ൃੜ͢Δ ͜͏͍͏ಛघέʔεʹରͯ͠ɺ ͕ࣗͨͪѻ͍͍͢ྫ֎Λఆٛͯ͠ॲཧΛଅͤΔͷར ྫ֎Λ໌֬ʹॲཧͰ͖Δ !58 //΄΅ى͜Γ͑ͳ͍͕… if(hoge.isEmpty()) { return
throw new HogeIsEmptyException(); } ྫ֎ʹͨͬͨ͠ ΄͏͕͍ͳ -
ߟ͑ΒΕΔબࢶ͍͔ͭ͘ w 0SBDMF+%,Ͱܖ͢Δ w 0SBDMF+%,Ͱܖ͢Δ w ֤ࣾஂମͷ+%,ʹҠߦ͢Δ w ͍ͬͦଞͷݴޠʹͯ͠͠·͏ +%,ͷҠߦ
!67 ͙͢ʹରԠ͢Δͷ͍͠ ͙͢ʹରԠ͢Δͷ͍͠ ͳ͔ͳ͔ͷֹۚʹͳΓͦ͏ʜ ͳ͔ͳ͔ͷֹۚʹͳΓͦ͏ʜ -
͓Βͤͦͷ̍ !83 w ژӺɹెา w ΧϯϑΝϨϯεࣾඅͰʂ ަ௨අ॓ധඅࢀՃඅ͓څྉग़·͢ w ࣾͰͷษڧձ͍Ζ͍Ζ w
ৄͪ͘͜͠Β ΤϯδχΞืूதʂ -
͓Βͤͦͷ !84 ژ%FW͔;͐ w ژӺલʙ w ςʔϚ৭ʑ w ίʔώʔɺ࠙ձ͖ w
ৄ͘͠DPOOQBTTͰʂ ษڧձͬͯΔͷͰདྷ͍ͯͩ͘͞ʂ