开发者

How best to implement Memcached on a Ecommerce Website

I've got a large ECommerce website running LAMP and was wondering how best to easily implement Memcached?

开发者_StackOverflow中文版
  • Store all queries in memcached for a certain period - sounds pointless

  • Store only certain important data like product information into Memcached and make sure the proper updates can expire it correctly - sounds like an end to end solution.

  • Store complex query results which do not change often - involves a lot of static code

Trying to get an overview of what changes I should make to take the best advantage of memcached.

Thanks :)


I'd let your users decide.

In other words rather than trying to second guess what will work best, I'd rework ALL the database queries to use memcached along the lines of;

  1. Can memcache answer this query? If so - return the results from cache.
  2. If not 1), pull results from database and write back to memcached so the next time it's in the cache.
  3. Ensure all your updates / inserts / deletes invalidate the appropriate cache keys.

Now given that 3) might be complex, I'd use that factor to choose which queries to load through the cache - if it's hard and/or time consuming to invalidate the cache, don't cache back those queries to start with.

Because memcached will automatically dump the least recently used keys when the store approaches capacity, you can set everything to never expire and just allow available resources to determine what is currently in the cache. This will largely be determined by user behaviour (which products are popular etc) and hence my first comment about letting the users decide.

It's also worth saying that you should ensure your MySQL database is well tuned first as that can often be an easier win. Query caching, checking heavy queries with Explain to tune your indexes etc, all of this can have a greater impact.


There is no way to get optimization tailored specifically to your system here.
Either you put the name of the OS system you use, or pay someone to analyze what you have.
There is no "common threads" here. (besides, to cache queries, you can do it in the level of the DB with enough memory)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜