A common practice to offload traffic from MySQL 5.6 is to use a caching layer to store expensive result sets or objects. Some typical use cases include:
- Complicated query result set (search results, recent users, recent posts, etc)
- Full page output (relatively static pages)
- Full objects (user or cart object built from several queries)
- Infrequently changing data (configurations, etc)
In pseudo-code, here is the basic approach:
data = fetchCache(key) if (data) { return data } data = callExpensiveFunction(params) storeCache(data, key) return data
Memcached is a very popular (and proven) option used in production as a caching layer. While very fast, one major potential shortcoming of memcached is that it is not persistent. While a common design consideration when using a cache layer is that “data in cache may go …
[Read more]