Spec-Zone .ru
спецификации, руководства, описания, API
|
This section outlines advantages and usage scenarios for the memcached interface to InnoDB
tables
introduced in Section 14.2.9, "InnoDB Integration with
memcached". The combination of InnoDB
tables and memcached offers advantages over using either by themselves:
Raw performance for simple lookups. Direct access to the InnoDB
storage engine avoids the parsing and planning overhead of SQL. Running memcached
in the same process space as the MySQL server avoids the network overhead of passing requests back and
forth.
Data is stored in a MySQL database to protect against crashes, outages, and corruption.
The transfer between memory and disk is handled automatically, simplifying application logic.
Data can be unstructured or structured, depending on the type of application. You can make an all-new table for the data, or map the NoSQL-style processing to one or more existing tables.
You can still access the underlying table through SQL, for reporting, analysis, ad hoc queries, bulk loading, set operations such as union and intersection, and other operations well suited to the expressiveness and flexibility of SQL.
You can ensure high availability of the NoSQL data by using this feature on a master server in combination with MySQL replication.
The integration of memcached with
MySQL provides a painless way to make the in-memory data persistent, so you can use it for more
significant kinds of data. You can put more add
, incr
, and similar write operations into your application, without
worrying that the data could disappear at any moment. You can bounce the memcached
server without losing updates made to the cached data. To guard against unexpected outages, you can take
advantage of InnoDB
crash recovery, replication, and backup procedures.
The way InnoDB
does fast primary
key lookups is a natural fit for memcached single-item
queries. The direct, low-level database access path used by the memcached plugin is much more efficient for key-value
lookups than equivalent SQL queries.
The serialization features of memcached, which can turn complex data structures, binary files, or even code blocks into storeable strings, offer a simple way to get such objects into a database.
Because you can access the underlying data through SQL, you can produce reports,
search or update across multiple keys, and call functions such as AVG()
and
MAX()
on the memcached data.
All of these operations are expensive or complicated with the standalone memcached.
You do not need to manually load data into memcached at startup. As particular keys are requested by an
application, the values are retrieved from the database automatically, and cached in memory using the
InnoDB
buffer pool.
Because memcached consumes relatively little CPU, and its memory footprint is easy to control, it can run comfortably alongside a MySQL instance on the same system.
Because data consistency is enforced through the usual mechanism as with regular
InnoDB
tables, you do not have to worry about stale memcached data or fallback logic to query the database
in the case of a missing key.