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

Zend Cache - Evolution

fwdays
November 24, 2012

Zend Cache - Evolution

В докладе я расскажу о своем опыте оптимизации “тяжелых” e-commerce проектов написанных на платформе Magento. В ходе доклада мы рассмотрим, практики и стратегии кэширования такие как:
— Точечное кэширование
— “Клонирование” приложения и генерация статического контента
— Кэширование вместо оптимизации
— Автоматическая генерация кэшей и др.
Немного остановимся на рассмотрении TwoLevels Cache в Zend 1 и математических моделях кэширования (LRU, LFU, LRU2, MRU).
Попробуем подобрать адекватное хранилище для кеша. Посмотрим чем нам может помочь cобытийно-ориентированная архитектура поддерживать валидность кэша.
И сравним Zend\Cache 2.0 с Zend_Cache 1.0.

fwdays

November 24, 2012
Tweet

More Decks by fwdays

Other Decks in Programming

Transcript

  1. Practical cache: my experience • Home page (8) < 1

    sec • Product page (18) < 3 sec • Category page (15 - 45) < 4 sec
  2. Practical cache: my experience • Home page (8) < 1

    sec • Product page (18) < 3 sec • Category page (15 - 45) < 4 sec • No docs, support, time
  3. Practical cache: my experience • Magical numbers • Spaghetti code

    • Dead code • Duplicated code • Much more: http://www.codinghorror.com/
  4. Practical cache: Cache strategies Bélády's Algorithm Most Recently Used Least

    Recently Used Least Frequently Used Adaptive Replacement Cache => LRU/LFU
  5. Practical cache: Research Home page (8) < 1 sec •

    Most viewed • Has dynamic content • Login area • Hot sells
  6. Practical cache: Research Home page (8) < 1 sec •

    Most viewed • Has dynamic content • Login area – not important • Hot sells – changes not often
  7. Practical cache: Zend Cache 1.0 Frontends Page cache Quick FPC

    Uses PHP Output (Capture) Blocks/Pages just cool
  8. Practical cache: Zend Cache 1.0: Output if (!($cache->start('UniqID'))) { Mage::run($mageRunCode,

    $mageRunType); $cache->end(); } else { $cache->end(); } 110 ms -> 20 ms
  9. Practical cache: Zend Cache 1.0 Backends File easy/cheap slow Memcache

    quick/independent flat data Database slow/independent expensive
  10. Practical cache: Research Product page (18) < 3 sec •

    Frequently viewed • Has dynamic content • Should be quick even for the first visitor
  11. Practical cache: Research Product page (18) < 3 sec •

    Frequently viewed • Cache blocks and parts of code • Has dynamic content • Validate on each change (EOA) • Should be quick even for the first visitor • Generate cache on our side
  12. Practical cache: Research Category page (15 - 45) < 4

    sec • Frequently viewed • Has dynamic content • Should be quick • Has high variety
  13. Practical cache: Research Category page (15 - 45) < 4

    sec • Frequently viewed • Cache blocks and parts of code • Has dynamic content • Validate on each change (EOA) • Has high variety • Cache collections
  14. Practical cache: Advices • Always Measure • Do not cache

    only because You can • Use Tags + Events for CRUD operations
  15. Practical cache: Advices • Always Measure • Do not cache

    only because You can • Use Tags + Events for CRUD operations • Generate cache by yourself if possible
  16. Practical cache: Advices • Always Measure • Do not cache

    only because You can • Use Tags + Events for CRUD operations • Generate cache by yourself if possible • Helpers sometimes don’t help
  17. Practical cache: Advices • Always Measure • Do not cache

    only because You can • Use Tags + Events for CRUD operations • Generate cache by yourself if possible • Helpers sometimes don’t help • File storage is slow on many files
  18. Zend Cache 1.0: TwoLevels Cache Response Request Slow Storage Fast

    Storage isCacheExists checkPriority Priority: 1-10 Depends on % of free space in the Fast Storage
  19. Zend Cache 1.0: TwoLevels Cache Priority: 1-10 Depends on %

    of free space in the Fast Storage Calculate priorities LRU/LFU