{"id":357,"date":"2007-12-07T02:11:39","date_gmt":"2007-12-07T07:11:39","guid":{"rendered":"http:\/\/blogs.n1zyy.com\/n1zyy\/2007\/12\/07\/memcached\/"},"modified":"2007-12-07T02:11:39","modified_gmt":"2007-12-07T07:11:39","slug":"memcached","status":"publish","type":"post","link":"https:\/\/blogs.n1zyy.com\/n1zyy\/2007\/12\/07\/memcached\/","title":{"rendered":"memcached"},"content":{"rendered":"<p>On my continuing series of me poking around at ways to improve performance&#8230;<\/p>\n<p>I accidentally stumbled across something on <a href=\"http:\/\/www.danga.com\/memcached\/\">memcached<\/a>. The classic example is LiveJournal (which, incidentally, created memcached for their needs). It&#8217;s <em>extraordinarily<\/em> database-intensive, and spread across dozens of servers. For what they were doing, generating HTML pages didn&#8217;t make sense that often. So it does something creative: it creates a cache (in the form of a hash table) that works across a network. You might have 2GB of RAM to spare on your database server (actually, you shouldn&#8217;t?) and 1GB RAM you could use on each of 6 nodes. Viola, 8 GB of cache. You modify your code to ask the cache for results, and, if you don&#8217;t get a result, then you go get it from the database (or whatever) as usual.<\/p>\n<p>But what about situations like mine? I have one server. And I use MySQL query caching. But it turns out it&#8217;s useful. (One argument for using it is that you can just run multiple clients on a single server to render moot any problems with using more than 4GB on a 32-bit system&#8230; But I&#8217;m not lucky enough to have problems with not being able to address my memory.)<\/p>\n<p>MySQL&#8217;s query cache has one really irritating &#8220;gotcha&#8221;&#8211;it doesn&#8217;t catch TEXT and BLOB records, since they&#8217;re of variable length. Remembering that this is a blog, consisting of lots and lots of text, you&#8217;ll quickly see my problem: nearly every request is a cache miss. (This is actually an oversimplification: there are <em>lots<\/em> of less obvious queries benefiting, but I digress.) (WordPress complicates things by insisting on using the exact timestamp in each query, which also renders a query cache useless.) I just use SuperCache on most pages, to generate HTML caches, which brings a tremendous speedup.<\/p>\n<p>But on the main page, I&#8217;m just hitting the database directly on each load. It holds up fine given the low traffic we have, but &#8220;no one uses it&#8221; isn&#8217;t a reason to have terrible performance. I&#8217;ve wanted to do some major revising anyway, so I think a rewrite in my spare time is going to experiment with using memcached to improve performance.<\/p>","protected":false},"excerpt":{"rendered":"<p>On my continuing series of me poking around at ways to improve performance&#8230; I accidentally stumbled across something on memcached. The classic example is LiveJournal (which, incidentally, created memcached for their needs). It&#8217;s extraordinarily database-intensive, and spread across dozens of &hellip; <a href=\"https:\/\/blogs.n1zyy.com\/n1zyy\/2007\/12\/07\/memcached\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,10,13,18,22,24],"tags":[],"class_list":["post-357","post","type-post","status-publish","format-standard","hentry","category-computers","category-ideas","category-linux-tips","category-ocd","category-programming","category-rants-raves"],"_links":{"self":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/comments?post=357"}],"version-history":[{"count":0,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/posts\/357\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/media?parent=357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/categories?post=357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.n1zyy.com\/n1zyy\/wp-json\/wp\/v2\/tags?post=357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}