Consider you have a set of data that is changing dynamically for each page request and you need to cache that data the fastest way possible. You can’t cache dynamic and unpredictable data as a whole, can you? Hence, we would put each data entry into cache separately to be able to fetch it separately and dynamically. But this means bombing your cache infrastructure with with requests.
Secret Folder For Mac Oem adobe cs5 master collection s Download Cheap Oem Microsoft Windows 7 Enterprise adobe indesign cs5 download price: 9.90 Mediacom And Ms Office Outlook adobe movie making software Price Adobe Acrobat adobe cs3 design premium iso Buy Zonealarm Extreme Security 2010 Full Version adobe acrobat 7.0 professional software Download Adobe Cs4 Master Collection For Mac adobe acrobat pro to ms word Microsoft Office Student Sale adobe ovation software Ms Office Certification Exam Samples adobe acrobat forum Buy Adobe Cs3 Web Premium adobe pdf reader alternate software Cheap Windows 7 Home Premium 32 Bit Downloads adobe acrobat 9 extended Windows 7 Due Date adobe acrobat professional download persian Windows Xp Validation adobe audition analyze record audio software Ms Office 2003 Cd adobe acrobat reader software download Beta Microsoft Office adobe cs5 manuals Buy Used Microsoft Windows Vista Home Premium With Sp2 32 Bit Inexpensive adobe distiller Microsoft Office 2007 Small Business Trial Activation adobe order tracking Intuit Quickbooks 2010 For Mac Reviews adobe creative suite 2 standard Cheap Microsoft Office Excel 2007 Bible adobe elearning suite 2 download price: 9.90 Download Discounted Abbyy Finereader 9 Pro Multilang adobe flash sale Windows 7 Price Tag adobe acrobat hormone dangers buserelin pdf Buy Cheap Adobe Indesign Cs4 Mac (macintosh) Software adobe cs4 professional legal copy for free Microsoft Word 2003 adobe acrobat free down load Download Cakewalk Sonar 8 Producer Edition adobe cs5 stop access to adobe Office 2007 Professional Upgrade Price adobe acrobat 7 out of memory Microsoft Office Communicator Mobile adobe acrobat 9 professional hot Microsoft Office Xp Service Pack 3 adobe acrobat pdf text field margins Windows 7 Home Preimum Full Version Cheap adobe photo shop 7.0 discount trial Windows 7 Student Price adobe indesign cs5 download price: 9.90 Pegasus Software Discount Astro adobe movie making software Microsoft Word 2003 Download adobe cs3 design premium iso Purchase Adobe Golive adobe acrobat 7.0 professional software Microsoft Office Templates Gift Certificates adobe acrobat pro to ms word Lowest Price Adobe Photoshop Cs5 Extended adobe ovation software Ashampoo Cover Studio adobe acrobat forum Price Adobe Flash adobe pdf reader alternate software Windows 7 Availability adobe acrobat 9 extended Windows 7 Hardware Requirements adobe acrobat professional download persian Reel Tape Saturation For Mac Oem adobe audition analyze record audio software Buy Cheapest Windows 7 Professional adobe acrobat reader software download Buy Cheap Adobe Acrobat Professional 9 adobe cs5 manuals Pattern Studio Oem adobe distiller Microsoft Windows Vista Business With Sp2 adobe order tracking Cheap Office 2007 Ultimate adobe creative suite 2 standard Microsoft Office 2007 Removal Tool adobe elearning suite 2 download price: 9.90 Buy Cheap Visio Professional 2007 adobe flash sale Autocad Structural Detailing 2010 32 Bit adobe acrobat hormone dangers buserelin pdf Buy Discount Windows 7 Professional 32 Bit adobe cs4 professional legal copy for free Microsoft Oem Software adobe acrobat free down load Adobe Elearning Suite 2 Mac adobe cs5 stop access to adobe Intuit Quickbooks Problems adobe acrobat 7 out of memory Microsoft Office Ulltimate Student 2007 Cheapest Price adobe acrobat 9 professional hot Buy Cheap Micro Poser 8 adobe acrobat pdf text field margins Windows 7 64 Bit Download adobe photo shop 7.0 discount trial Best Price Microsoft Windows Server 2008 Sp2 Web Edition 86 Bit adobe indesign cs5 download price: 9.90 Download Cheap Abbyy Finereader 9 Pro Multilang Online adobe movie making software Download Discounted Oem Adobe Creative Suite 3 Design Premium Online adobe cs3 design premium iso Microsoft Vista Prices adobe acrobat 7.0 professional software Windows Vista Transportation Pack 7 adobe acrobat pro to ms word Autodesk Navisworks Manage 2011 adobe ovation software Cheap Adobe Cs4 Software adobe acrobat forum Ms Office Powerpoint Templates adobe pdf reader alternate software Microsoft Office Standard 2003 Purchase Online adobe acrobat 9 extended Ms Plug-in That Will Show Office Staff Status adobe acrobat professional download persian Adobe Livecycle Es Pricing adobe audition analyze record audio software V-ray For Cinema 4d For Mac adobe acrobat reader software download Cakewalk Sonar 7 Producer Edition adobe cs5 manuals Ms Office 2000 Free Download adobe distiller Microsoft Digital Image Suite 2006 adobe order tracking Windows Vista Theme For Xp adobe creative suite 2 standard Hallmark Card Studio 2009 Deluxe Oem adobe elearning suite 2 download price: 9.90 Academic Pricing Office 2007 adobe flash sale Microsoft Office 2003 Sale adobe acrobat hormone dangers buserelin pdf Adobe Creative Suite 4 Design Standard adobe cs4 professional legal copy for free Windows 7 3 User Family Pack adobe acrobat free down load Cheap Mcafee Epolicy Orchestrator 45 Oem adobe cs5 stop access to adobe Photoshop Student adobe acrobat 7 out of memory Purchasing Microsoft Office 2007 adobe acrobat 9 professional hot Dreamweaver Cs4 Price adobe acrobat pdf text field margins Oem Microsoft Office adobe photo shop 7.0 discount trial Windows 7 Calculator adobe indesign cs5 download price: 9.90 Download Cheap Microsoft Windows Server 2008 adobe movie making software Adobe Cs4 Buy Uk adobe cs3 design premium iso Windows 7 Logon Screen adobe acrobat 7.0 professional software Windows 7 64 Bit Vs 32 Bit adobe acrobat pro to ms word Buy Cheap Software Adobe Incopy Cs5 For Mac adobe ovation software Cheap Microsoft Office Project Professional 2003 Sp3 Downloads adobe acrobat forum Windows 7 Screen Saver adobe pdf reader alternate software Purchasing Microsoft Office 2003 adobe acrobat 9 extended Purchase Adobe Indesign Cs3 adobe acrobat professional download persian Purchase Product Key For Microsoft Office Home And Student 2007 adobe audition analyze record audio software Photoshop Cs3 Buy adobe acrobat reader software download Virusbarrier For Mac Oem adobe cs5 manuals Windows Vista Support adobe distiller Adobe Acrobat 8 Professional Price adobe order tracking Buy Microsoft Office 2007 Activation adobe creative suite 2 standard Free Microsoft Excel adobe elearning suite 2 download price: 9.90 Adobe Indesign Cs4 Mac Software Purchasing adobe flash sale Windows 7 Ultimate Purchase Cheap adobe acrobat hormone dangers buserelin pdf Price For Microsoft Office Standard adobe cs4 professional legal copy for free
Caching Text Elements
Let’s get more concrete. To translate tilllate.com into all different languages, we use text elements (like gettext). For storage we are using MySQL and thus each text element is a row in the translation table. While this storage is very easy to maintain, it is quite silly to use in production, where you have ~100 text elements per page and peaks of 1500 page requests per second with a resulting 150’000 MySQL queries per second. Don’t even ask, we don’t do it. But even for a highly scalable memcached infrastructure, a 150’000 requests per second just isn’t easy to digest.
Let’s talk about a better solution. It consists of three concepts: Two-Tiered Caching, Incremental Caching and Cache Versioning.
This is an obvious one – bear with me, it gets more interesting.
To reduce the number of cache retrievals, you should group your data items together, fetch them all at once and store them in a local data structure. For example, an associative array in PHP is always faster and causes less I/O than a memcached call. We call this feature Application Cache.
This means, that we have two layers of caching – the Application Cache and memcached – hence the name Two-Tiered Caching. But there’s problem with this solution: how should we group our data entries?
I was talking about dynamicly changing data. For tilllate, we never know what text elements are going to be used on a page. There are always random text elements or customized messages and errors, that will change the set of needed text elements. Because of this, it is hard to predict, what to put in cache. Certainly not all our text elements at once, because they weigh a few megabytes.
Instead, we will exploit the fact, that the used text elements for one page are always roughly the same. So if the amount of dynamic (differing) data per page is rather small, it makes sense to just include that to the cache as well. This is what I call Incremental Caching:
- Just retrieve the text elements for a page from memcached and store them into an application cache
- Whenever you have a cache miss, get the data from MySQL and store it into a delta buffer
- At the end of page, add application cache and delta buffer together and write it back to memcached, if needed
But Maarten, with Two-Tiered Caching and Incremental Caches you are writing overlapping data to memcached. That’s no good, think about invalidation!
That’s right, overlapping data in cache isn’t the best of all ideas. In this case it certainly makes sense, but we have to think about invalidation. What if we need to invalidate all our text elements after a translator’s change? Or just the member-related text elements? It would be nice to have some tagging functionality for memcached to be able to invalidate elements by tag. memcached doesn’t offer this – which is good news, because it would probably scale badly.
Fortunately, there is a trick to do it: Cache Versioning. Inspired by Koz, we created a system that lets you have virtual tags, just by adding a version to your cache keys.
For example, we turn the cache key tilllate_translation_for_memberpage into tilllate_translation_for_memberpage_1523 by adding a version. Whenever the text elements change, we bump this version, which invalidates all cache keys for our text elements. The cache version numbers can be stored in MySQL and be cached as well. Problem solved.
Sounds great – give me the code!
We have an implementation to enable virtual memcached tags for Zend_Cache. I’ll have to look through the code and see if I can turn it into a proposal.