RailsのCacheつかってますか?@表参道.rb #44

586a2d464eed3c7e5dd809d6fe0269d7?s=47 YABOO JAPAN
March 07, 2019
400

RailsのCacheつかってますか?@表参道.rb #44

586a2d464eed3c7e5dd809d6fe0269d7?s=128

YABOO JAPAN

March 07, 2019
Tweet

Transcript

  1. RailsͷCache͔ͭͬͯ·͔͢ʁ @yaboojp on දࢀಓ.rb #44 2019/3/7

  2. Self • Name: େ༅ Ӭ / @yaboojp • Jobs: •

    22Inc. Co-Founder & CTO • ex NTTdata • Location: ژ౎ -> ౦ژ • Favorites: ΫϥϑτϏʔϧ, Իָ, όΠΫ, JALϚΠ ϧ
  3. None
  4. Cacheͱ͍ͬͯ΋৭ʑ $MJFOU /HJOY 6OJDPSO 3%#.4 )UUQ)FBEFS &YQJSFT &5BH  $BDIF$POUSPM

    -BTU .PEJpFEͳͲ 1BHF$BDIF 'SBHNFOU$BDIF "DUJPO$BDIF .JEEMFXBSF
 7BSOJTI 4RVJEͳͲ $%/ $MPVE'MPOUͳͲ 42-$BDIF ௿ϨϕϧΩϟογϡ %/4 -#
  5. on Railsͳͱ͚ͩ͜

  6. PageCacheͱ͸ • Rails3·Ͱ͸ඪ४૷උ͕ͩͬͨɺࠓ͸Gem • ॳճΞΫηε࣌Ҏ֎Rubyʹ࢓ࣄͤ͞ͳ͍

  7. PageCache ࣮ݧ • ྫ͑͹͜Μͳϖʔδʹ΍ΔͱͲ͏͔ʁ

  8. PageCache ݁Ռ • ݁Ռɿ 173ms => 170ms • 1.7%ߴ଎Խ... ͱ͍͏͔ɺ΄΅มΘΒͳ͍

    • ಈతίϯςϯπ͕গͳ͍ViewͰ΍Δҙຯ͸͋·Γͳ ͍ • ͨͩɺunicornͳͲͷAppαʔόͷෛՙܰݮɺো֐࣌ Ͱ΋ฦͤΔͱ͍ͬͨϝϦοτ͸͋Δ
  9. ͡Ό͋ɺ ಈతίϯςϯπ͕ଟ͍ϖʔδ ͰPageCache࢖ͬͯΈΑ͏

  10. PageCache ஫ҙ఺ • Railsͷaction͕Ұ੾࣮ߦ͞Εͳ͍ͨΊɺ֤छ ϩδοΫ͸΋ͪΖΜɺೝূ͢Β͢Γൈ͚Δ Ϣʔβຖͷ ίϯςϯπΤϦΞ ͕͜͜ॳճʹΞΫηεͨ͠Ϣʔβͷ৘ใͱͯ͠Ϩϯμ Ϧϯά͞Εͨ)5.-Λৗʹฦ͢ ˞෦෼తʹ"KBYߋ৽͢Δઃܭ͸͋Γ

  11. ࢖͍ॴ͕ͳ͔ͬͨ

  12. PageCache ΦϚέ • ͠ΐ͏͕ͳ͍ͷͰɺ͜͏͍͏࣮ݧ • ݁Ռɿ 1100ms => 100ms ͙Β͍

  13. PageCache ·ͱΊ • Railsʹ౸ୡ͠ͳ͍ͷڧ͍ • ίϯςϯπͷग़͠෼͚ͳͲʹ͸࢖͑ͳ͍ͳͲ ࢖͍ॴ͕ݶఆ͞ΕΔ • ಋೖίετΊͬͪΌ௿͍

  14. ஌ݟ!!...??

  15. ࣍ʂʂ

  16. FragmentCacheͱ͸ • Ұ౓ϨϯμϦϯάͨ͠ViewϑΝΠϧΛϑϥά ϝϯτͱ͍͏୯ҐͰCacheStoreʹอଘ Ωϟογϡ͍ͨ͠ ΤϦΞ 'SBHNFOU

  17. FragmentCache ઃఆ • อଘઌ͸ࣗ༝ʹઃఆ

  18. FragmentCache ࢖͍ํ • key͸ id + updated_at ͱ͔ҰҙʹͳΔΑ͏ʹ

  19. ϩγΞϯυʔϧΩϟογϡ

  20. FragmentCache σόοά • ։ൃ؀ڥ͸ઃఆೖΕͱ͘ͱ • ͜ΜͳΩϟογϡͷར༻ঢ়گ͕֬ೝͰ͖Δ

  21. FragmentCache #1 • ͋Γ;Εͨ৘ใϖʔδ • 800ms -> 720ms 10%ߴ଎Խ

  22. FragmentCache #2 • ΊͬͪΌॏ͍ϖʔδ • 9925ms -> 805ms 1240%ߴ଎Խ ͳΜ͔ΞϗΈ͍ͨ

    ʹॏ͍ϖʔδ ʢ/ ؚΉʣ
  23. ద੾ʹExpireͤ͞Δ keyʹ஫ҙ • id + updated_at ͱ͔͕ϕετϓϥΫςΟε • ϛεͬͨΒେࣄނʹͳΔ͜ͱ΋

  24. ΩϟογϡͰૣͯ͘͠Α Ωϟογϡͳ͍ͱ஗͍ ΋ͬͱΩϟογϡΛ ஗͍ʂʂ ੑೳ Ωϟογϡ ผͷՕॴ͕஗͘ͳΔͱ Ωϟογϡ

  25. ༻๏ɾ༻ྔΛकͬͯ ਖ਼͓͘͠࢖͍͍ͩ͘͞

  26. None
  27. We Are Hiring

  28. Thanks