Databases Reference
In-Depth Information
For example, if your cache hit rate is 90% and you lose the cache for some reason, the
load on the database will increase tenfold. It's rather likely that this will exceed the
database server's capacity.
To avoid surprises such as this, you should think about some kind of high-availability
solution for the cache (the data as well as the service), or at least measure the perfor-
mance impact of disabling the cache or losing its data. You might need to design the
application to degrade its functionality, for example.
Using HandlerSocket and memcached Access
Instead of storing data in MySQL and caching it outside of MySQL, an alternative
approach is to create a faster access path to MySQL and then bypass the cache. For
small, simple queries, a large portion of the overhead can come from parsing the SQL,
checking privileges, generating an execution plan, and so on. If this overhead can be
eliminated, MySQL can be very fast at simple queries.
There are currently two solutions that take advantage of this by permitting so-called
NoSQL access to MySQL. The first is a daemon plugin called HandlerSocket, which
was created at DeNA, a large Japanese social networking site. It permits you to access
an InnoDB Handler object through a simple protocol. In effect, you're reaching past
the upper layers of the server and connecting directly to InnoDB over the network.
There are reports of HandlerSocket achieving over 750,000 queries per second.
HandlerSocket is distributed with Percona Server, and the memcached access to InnoDB
is available in a lab release of MySQL 5.6.
The second option is accessing InnoDB through the memcached protocol. The lab re-
leases of MySQL 5.6 have a plugin that permits this.
Both approaches are somewhat limited—especially the memcached approach, which
doesn't support as many access methods to the data. Why would you ever want to
access your data through anything but SQL? Aside from speed, the biggest reason is
probably simplicity. It's a big win to get rid of caches, and all of the invalidation logic
and additional infrastructure that accompanies them.
Extending MySQL
If MySQL can't do what you need, one possibility is to extend its capabilities. We won't
show you how to do that, but we want to mention some of the possibilities. If you're
interested in exploring any of these avenues further, there are good resources online,
and there are books available on many of the topics.
When we say “MySQL can't do what you need,” we mean two things: MySQL can't
do it at all, or MySQL can do it, but in a slow or awkward way that's not good enough.
Either is a reason to look at extending MySQL. The good news is that MySQL is be-
coming more and more modular and general-purpose.
 
Search WWH ::




Custom Search