MySQL server now includes embedded memcached for performance
The latest MySQL release (5.6.6) integrates the memcached daemon into the core server which allows you to use the memcached protocol to query InnoDB tables. This is interesting because it means you can store all your data in one database – MySQL – and structure the data for analysis using SQL, but configure options to allow queries to get the performance benefits of having data stored in memcached. Queries against memcached avoid the query parsing and planning overheads of SQL but still gives you the crash and corruption durability guarantees that InnoDB offers.
Perhaps the biggest benefit is the ability to do fast key lookups in some situations but use the same data store to do more advanced SQL based analysis. With many new NoSQL products, there is usually a tradeoff between these – key/value stores are not designed for large scale analysis and equally, big data products are more designed towards long running map/reduce style jobs rather than fast key lookups.
This hasn’t been released as a stable package as yet but there is already fairly detailed documentation on the plugin. Some interesting excerpts include:
- Running memcached in the same process space as the MySQL server avoids the network overhead of passing requests back and forth (source).
- The transfer between memory and disk is handled automatically, simplifying application logic (source).
- Multi-column support: you can map multiple columns into the “value” part of the key/value store, with column values delimited by a user-specified separator character (source).
- You can configure the system as a traditional memcached server, with all data cached only in memory, or use a combination of memcached caching and InnoDB persistent storage (source).
The Percona distribution of MySQL has had similar functionality for a while through the HandlerSocket plugin but now this is in core MySQL, it will mean that many benefits of NoSQL key/value stores are moot, at least where they exist as caching systems designed to be a layer in front of MySQL.
Of course, this just reduces the need for one particular use case of key/value stores. In many cases, they are used where the durability of the likes of InnoDB isn’t necessary but the ability to link traditional SQL tables directly into a caching layer is compelling, particularly for legacy applications already using MySQL.
Enjoy this post? You may also like MongoDB Benchmarks