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

Magento 2 Caching Strategies

Magento 2 Caching Strategies

Meet Magento Poland, Warsaw, November 24th to November 25th 2014.

Marko Martinović

November 24, 2014
Tweet

More Decks by Marko Martinović

Other Decks in Programming

Transcript

  1. Meet Magento Poland 2014
    Meet Magento Poland 2014
    Marko Martinović
    Magento 2 Caching Strategies

    View Slide

  2. Meet Magento Poland 2014
    2.0 Platform Goals
    “Improved performance and scalability”

    View Slide

  3. Meet Magento Poland 2014
    Architecture
    Built on top of Zend_Cache

    View Slide

  4. Meet Magento Poland 2014
    Architecture
    Multiple frontend pools, each associated to
    one or two level backend adapter

    View Slide

  5. Meet Magento Poland 2014
    Architecture
    Each cache type with its own class enforcing
    specific cache tag

    View Slide

  6. Meet Magento Poland 2014
    Frontend Pools
    Out the box:
    • default - General type instances
    • page_cache - PageCache type instance

    View Slide

  7. Meet Magento Poland 2014
    Backend Adapters
    Cm_Cache_Backend_File as the default
    cache backend

    View Slide

  8. Meet Magento Poland 2014
    Backend Adapters
    All the usual suspects, with MongoDB
    adapter introduced

    View Slide

  9. Meet Magento Poland 2014
    Cache Types
    Good old
    ● Configuration
    ● Layouts
    ● Blocks HTML output
    ● Collections data
    ● EAV types and
    attributes
    ● Translations
    Brand New
    ● View files fallback
    ● View files pre-
    processing
    ● Integrations
    Configuration
    ● Integrations API
    Configuration
    ● Web Services
    Configuration
    ● PageCache

    View Slide

  10. Meet Magento Poland 2014
    Collections Data
    Fetch strategy interface with Query and
    Cache implementations

    View Slide

  11. Meet Magento Poland 2014
    Collections Data
    Store, Store Group, Website and Catalog
    Category collection cached

    View Slide

  12. Meet Magento Poland 2014
    EAV Types and Attributes
    Implemented to cache eav_entity_type
    table collection. Still here, still unused, still
    no one knows why.

    View Slide

  13. Meet Magento Poland 2014
    EAV Types and Attributes
    "One developer is working on it for a month,
    other comments it out for testing, third one is
    then afraid to enable it back"
    -Ivan Weiler @Inchoo

    View Slide

  14. Meet Magento Poland 2014
    View Files Fallback
    Requested asset is being searched for using
    fallback rules applied to fallback context

    View Slide

  15. Meet Magento Poland 2014
    View Files Fallback
    Path to requested asset resolved and
    cached

    View Slide

  16. Meet Magento Poland 2014
    View Files Pre-processing
    Pre-processing of Magento-flavoured CSS
    tricks like @magento_import, @import,
    scope notation file references and Less

    View Slide

  17. Meet Magento Poland 2014
    View Files Pre-processing
    Path to pre-processed asset cached

    View Slide

  18. Meet Magento Poland 2014
    PageCache
    Out the box:
    • PHP/AJAX based (Built-in)
    • Reverse proxy/ESI/AJAX based (Varnish)

    View Slide

  19. Meet Magento Poland 2014
    PageCache
    Caching controlled by ‘Cache-Control’:
    public, max-age=XY, s-maxage=XY
    vs.
    private, max-age=YZ
    vs.
    no-store, no-cache, must-revalidate, max-
    age=0

    View Slide

  20. Meet Magento Poland 2014
    PageCache
    Setting cacheable=false to some block
    results with whole page not being cached

    View Slide

  21. Meet Magento Poland 2014
    Hole Punching
    Setting _isScopePrivate to some block
    results with its content not being cached

    View Slide

  22. Meet Magento Poland 2014
    Hole Punching
    Setting ttl to some block results with its
    content being served through ESI and
    cached by Varnish

    View Slide

  23. Meet Magento Poland 2014
    Built-in
    Page cache saved through dedicated
    frontend instance by PHP code

    View Slide

  24. Meet Magento Poland 2014
    Built-in
    Dynamic blocks not cached and served
    exclusively through AJAX:
    Default welcome msg!

    View Slide

  25. Meet Magento Poland 2014
    Built-in
    Pros
    ● Works out the box with
    no special setup
    Cons
    ● Leaves a lot to be
    desired performance-
    wise

    View Slide

  26. Meet Magento Poland 2014
    Varnish

    View Slide

  27. Meet Magento Poland 2014
    Varnish
    Page cache maintained and served by
    reverse proxy

    View Slide

  28. Meet Magento Poland 2014
    Varnish
    Without ttl set, dynamic blocks not cached
    and served through AJAX

    View Slide

  29. Meet Magento Poland 2014
    Varnish
    With ttl set, dynamic blocks cached and
    served through ESI:

    View Slide

  30. Meet Magento Poland 2014
    Varnish
    Pros
    ● The best performing
    caching solution, if
    properly configured
    Cons
    ● The worst performing
    caching solution, if
    configured improperly
    ● Considerable setup and
    maintenance overhead
    ● Requires SSL
    termination proxy to
    support HTTPS

    View Slide

  31. Meet Magento Poland 2014
    Benchmarks Magento 2 (Alpha 102)
    Magento EE (1.14.0.1)

    View Slide

  32. Meet Magento Poland 2014
    Any questions?

    View Slide

  33. Meet Magento Poland 2014
    @MarkoTechyTalk
    Team Lead/MCD+ at Inchoo
    Thank you!

    View Slide