PHPで学ぶCacheの距離の話

 PHPで学ぶCacheの距離の話

Cacheの距離について

F04982ad61107b5408ad139966596316?s=128

Ryo Tomidokoro

October 31, 2018
Tweet

Transcript

  1. PHPͰֶͿCacheͷڑ཭ͷ࿩ 1)1ษڧձ

  2. Cacheͱ͸ʁ

  3. Oxford Dictionary ΑΓ An auxilirary memory from which high speed

    retrieval is possible ߴ଎Ͱσʔλऔಘ͕Ͱ͖ΔهԱ૷ஔ
  4. WebΞϓϦͰͷར༻༻్ ߴෛՙΫΤϦͷॲཧ݁Ռ ूܭॲཧͷ݁Ռ ϧʔςΟϯά ઃఆϑΝΠϧ CDNͱ͔ϒϥ΢βΩϟογϡ͸ɺࠓճ͸ର৅֎

  5. ࠓ೔࿩͢͜ͱ CacheͷޮՌΛࣄલʹ೺Ѳ͢Δ͜ͱ ΑΓߴ͍ޮՌΛಘΔͨΊͷCacheͷڑ཭ͷ࿩

  6. ࠓ೔࿩͞ͳ͍͜ͱ Cacheͷϛυϧ΢ΣΞ Cacheͷӡ༻ ࢀߟ1 WebαʔϏεʹ͓͚ΔΩϟογϡઓུ https://speakerdeck.com/yusukebe/websabisuniokeru-kiyatusiyuzhan-lue ࢀߟ2 WebΞϓϦέʔγϣϯͷΩϟογϡઓུͱͦͷύλʔϯ https://speakerdeck.com/moznion/pattern-and-strategy-of-web-application-caching

  7. CacheͷޮՌΛࣄલʹ೺Ѳ͢Δ

  8. CacheΛ࢖͏͜ͱͰԿނ଎͘ͳΔͷ͔ʁ

  9. ྫ͑͹͜Μͳߏ੒

  10. ಉҰωοτϫʔΫ಺ͷDBͷΫΤϦ݁ՌΛCache ΫΤϦ݁ՌΛಘΔ·Ͱͷ࣌ؒ 5$1઀ଓ $16ԋࢉ %JTL*0 MySQL + +

  11. 5$1઀ଓ $16ԋࢉ %JTL*0 MySQL + + ΫΤϦ݁ՌΛಘΔ·Ͱͷ࣌ؒ - RedisʹCache 5$1઀ଓ

    .FNPSZ*0 Redis + ಉҰωοτϫʔΫ಺ͷDBͷΫΤϦ݁ՌΛCache ΫΤϦ݁ՌΛಘΔ·Ͱͷ࣌ؒ
  12. $16ԋࢉ %JTL*0 MySQL + .FNPSZ*0 Redis MemoryIOͷํ͕଎͚Ε͹ɺ଎౓޲্͕ݟࠐΊͦ͏

  13. ϨΠςϯγʔ https://gist.github.com/jboner/2841832

  14. ͔͠͠ɺ͋·Γ଎͘ͳΒͳ͍ύλʔϯ͕͋Δ

  15. DBͷσʔλ͕ϝϞϦʹ৐Δ৔߹ ΫΤϦ݁ՌΛಘΔ·Ͱͷ࣌ؒ 5$1઀ଓ ΄΅.FNPSZ*0 MySQL + ΫΤϦ݁ՌΛಘΔ·Ͱͷ࣌ؒ - RedisʹCache 5$1઀ଓ

    .FNPSZ*0 Redis +
  16. DBͷσʔλ͕ϝϞϦʹ৐Δ৔߹ ΄΅.FNPSZ*0 MySQL .FNPSZ*0 Redis Φʔμʔ͕มΘΔΑ͏ͳ଎౓޲্͸ݟࠐΊͳ͍

  17. ͜ΕҎ্ͷ଎౓޲্Λ͢Δʹ͸ʁʁ

  18. WebΞϓϦ͔ΒCache·Ͱͷڑ཭Λม͑Δ 5$1઀ଓ .FNPSZ*0 ͬͪ͜ +

  19. WebΞϓϦ͔ΒCache·Ͱͷڑ཭Λม͑Δ 5$1઀ଓ .FNPSZ*0 ͬͪ͜ + TCP઀ଓΛ΍ΊΔ -> ϩʔΧϧCache

  20. https://gist.github.com/jboner/2841832 ϨΠςϯγʔ

  21. PHPͰϩʔΧϧCache ϩʔΧϧRedis, Memcached -> ਏ͍ ϑΝΠϧ -> ͍͍͚Ͳ… APCu(ϝϞϦ) ->

    ྑͦ͞͏ աڈͷऔΓ૊Έ - ແཧ΍ΓOPCache࢖͏Cache https://speakerdeck.com/hanhan1978/cachegasu-ifalsekaque-ren-suruhua
  22. PHPͷࣄ৘ ϓϩηεͷಠཱੑ͕ߴ͍ ॲཧऴྃޙʹϝϞϦ͸ΫϦΞ͞ΕΔ ϓϩηεؒͰͷϝϞϦڞ༗͕ग़དྷͳ͍ɻ PHP΢Σϒαʔόʔͷొ৔͕๬·ΕΔ

  23. ࣮ଌͯ͠Έͨ

  24. Trans/SecͱCacheํ๏ ํ๏ USBOTTFD ϦϞʔτ.Z42-  ϦϞʔτ3FEJT  ϩʔΧϧ"1$V  DBσʔλ͕ϝϞϦʹ৐͍ͬͯΔ৔߹ʹ͍ͭͯݕূ

  25. ·ͱΊ Latencyͷද͸͓֮͑ͯ͜͏Ͷ CacheʹΑΔվળݟࠐΈ͸ࣄલʹཱͯΔ ܭࢉྔ͚ͩ͡Όͳ͘ڑ཭΋ߟ͑Δ ͳ͓ɺCacheӡ༻͸পͰ͢….

  26. ͓͠·͍