Ivan Chepurnyi - MM14NL

  • 98 views
Uploaded on

Varnish Cache and its usage in the real world! …

Varnish Cache and its usage in the real world!

In the modern era of e-commerce, it is quite obvious that web-shop revenue is strictly bound to its code performance. If you can satisfy customer withing 300ms of total page load time, you’ll get this sale. MorЕ over your web-shop will be more likely to get ranked higher in Google.

During my presentation you will find the best practices in integration of Varnish cache into Magento webshop.
Varnish, de-facto is the best front-cache available on the market, but most of the people don’t use it at its maximums!

Enjoy my useful speech and find a lot of interesting things in Magento’s life!

More in: Software , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
98
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
2
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Varnish Cache and its usage in the real world Ivan Chepurnyi Owner EcomDev BV
  • 2. Ivan Chepurnyi About me Meet Magento • Technical Consultant, Owner at EcomDev B.V. • Was one of the first five developers in original Magento core team • Providing trainings and coaching of Magento Developers in Europe • Main areas of my expertise: – System Architecture – Performance Optimization – Test Driven Development – Complex Customizations
  • 3. Ivan Chepurnyi Meet Magento Varnish is not a cache backend
  • 4. Ivan Chepurnyi Meet Magento Varnish is a frontend caching proxy
  • 5. Ivan Chepurnyi Simple Workflow Meet Magento First call to a page
  • 6. Ivan Chepurnyi Simple Workflow Meet Magento Subsequent requests
  • 7. Ivan Chepurnyi How Varnish Works Meet Magento recv hit passmiss hash pipe deliver fetch • recv – request is received from client • pipe – direct output of backend data (streaming) • hash – request is cacheable, lookup cache entry • pass – request is not cacheable • hit – cache entry is found • miss – cache entry not found • fetch – retrieval of data from backend • deliver – return data to client
  • 8. Ivan Chepurnyi What can we do with it? Meet Magento • Cache static pages (Homepage, CMS, Contacts, etc) • Cache catalog pages: – Category listings – Product search results – Product view pages • Cache page parts: – CMS Blocks – Header – Footer
  • 9. Ivan Chepurnyi Meet Magento Is it possible to clear Varnish cache based on product, category, store, etc? YES!!!
  • 10. Ivan Chepurnyi Meet Magento The Secret is in Cache Object structure
  • 11. Ivan Chepurnyi Cached Object in Varnish Meet Magento Cached Object Response Headers Response Body Cache Metadata Cache Content
  • 12. Ivan Chepurnyi Meet Magento We just going to supply object ID with its type in response headers, so it later on can be used to flush pages containing our object.
  • 13. Ivan Chepurnyi Meet Magento But is it possible to make cache lifetime dynamic for per product, category, etc? YES!!!
  • 14. Ivan Chepurnyi Meet Magento You can supply a response header, that contains a TTL of the page.
  • 15. Ivan Chepurnyi Meet Magento So what should be done to implement Varnish in Magento with all the benefits?
  • 16. Ivan Chepurnyi Varnish in Magento Meet Magento • Collect current page objects, that are shown on the page. Also add them into response headers. • Create a connector to a Varnish admin protocol, that will be used for flushing of the page by object ids. • Implement auto-updated AJAX blocks for: – Shopping cart – Wishlist – Customer Account links
  • 17. Ivan Chepurnyi Meet Magento But I have a good news: I alredy developed a module that gives you a solid foundation for using Varnish in your project!
  • 18. Ivan Chepurnyi EcomDev_Varnish Meet Magento Download URL: http://bit.ly/ecomdev_varnish Requires: • Varnish 3.0 • Minimal changes to your theme Supports: • Flush of cache on update of product, category, cms page, csm block, price rules • Client side cacheable AJAX placeholders (Cart, Wishlist, etc) • Possibility to make cache based on customer segment • Cache for logged in users
  • 19. Ivan Chepurnyi Meet Magento Making an element dynamic on varnish cached page
  • 20. Ivan Chepurnyi Code Sample Dynamic Block Meet Magento
  • 21. Ivan Chepurnyi Meet Magento Adding custom TTL for a page
  • 22. Ivan Chepurnyi Code Sample Custom TTL Meet Magento
  • 23. Ivan Chepurnyi Meet Magento Making custom page cacheable
  • 24. Ivan Chepurnyi Code Sample Custom Page Meet Magento
  • 25. Ivan Chepurnyi Meet Magento Move blocks as a standalone cached page (ESI).
  • 26. Ivan Chepurnyi Code Sample ESI Meet Magento
  • 27. Ivan Chepurnyi Varnish vs Full Page Cache Meet Magento Varnish • Avg. time to first byte 30ms • Dedicated software • Tools to monitor cache usage • Scalable • Requires adaptation of themes for dynamic parts • Possibility to flush group of pages Magento FPC implementation • Avg. time to first byte 300ms • Magento code level • N/A • Only as another backend • Most of the time it is not required • N/A
  • 28. Ivan Chepurnyi Conclusion Meet Magento Be smart and use Varnish correctly!
  • 29. Ivan Chepurnyi OpenSource Roadmap 2014 Meet Magento 1. Finalize EcomDev_Varnish module and make it open source; 2. EcomDev_PHPUnit refactoring for API based fixtures; 3. Working on EcomDev_Index module, to provide alternative of standard indexation mechanism in Magento: – Flat Indexers (failover indexation) – UrlRewrites (full refactor of existing module) – Layered Navigation (Sphinx) – Better Search (Sphinx)
  • 30. Ivan Chepurnyi Meet Magento Thank You!
  • 31. Questions?