MySQL memcached support - Amazon Relational Database Service (original) (raw)

Amazon RDS supports using the memcached interface to InnoDB tables that was introduced in MySQL 5.6. The memcached API enables applications to use InnoDB tables in a manner similar to NoSQL key-value data stores.

Note

The memcached interface is no longer available in MySQL 8.4. When you upgrade your DB instances to MySQL 8.4, you must disable memcached in existing option groups.

The memcached interface is a simple, key-based cache. Applications usememcached to insert, manipulate, and retrieve key-value data pairs from the cache. MySQL 5.6 introduced a plugin that implements a daemon service that exposes data from InnoDB tables through the memcached protocol. For more information about the MySQL memcached plugin, see InnoDB integration with memcached.

To enable memcached support for an RDS for MySQL DB instance
  1. Determine the security group to use for controlling access to the memcached interface. If the set of applications already using the SQL interface are the same set that will access the memcached interface, you can use the existing VPC security group used by the SQL interface. If a different set of applications will access the memcached interface, define a new VPC or DB security group. For more information about managing security groups, see Controlling access with security groups
  2. Create a custom DB option group, selecting MySQL as the engine type and version. For more information about creating an option group, see Creating an option group.
  3. Add the MEMCACHED option to the option group. Specify the port that the memcached interface will use, and the security group to use in controlling access to the interface. For more information about adding options, see Adding an option to an option group.
  4. Modify the option settings to configure the memcached parameters, if necessary. For more information about how to modify option settings, see Modifying an option setting.
  5. Apply the option group to an instance. Amazon RDS enables memcached support for that instance when the option group is applied:
    • You enable memcached support for a new instance by specifying the custom option group when you launch the instance. For more information about launching a MySQL instance, see Creating an Amazon RDS DB instance.
    • You enable memcached support for an existing instance by specifying the custom option group when you modify the instance. For more information about modifying a DB instance, see Modifying an Amazon RDS DB instance.
  6. Specify which columns in your MySQL tables can be accessed through thememcached interface. The memcached plug-in creates a catalog table named containers in a dedicated database namedinnodb_memcache. You insert a row into the containers table to map an InnoDB table for access through memcached. You specify a column in the InnoDB table that is used to store the memcached key values, and one or more columns that are used to store the data values associated with the key. You also specify a name that a memcached application uses to refer to that set of columns. For details on inserting rows in thecontainers table, see InnoDB memcached plugin internals. For an example of mapping an InnoDB table and accessing it through memcached, see Writing applications for the InnoDB memcached plugin.
  7. If the applications accessing the memcached interface are on different computers or EC2 instances than the applications using the SQL interface, add the connection information for those computers to the VPC security group associated with the MySQL instance. For more information about managing security groups, see Controlling access with security groups.

You turn off the memcached support for an instance by modifying the instance and specifying the default option group for your MySQL version. For more information about modifying a DB instance, see Modifying an Amazon RDS DB instance.

MySQL memcached security considerations

The memcached protocol does not support user authentication. For more information about MySQL memcached security considerations, see Security Considerations for the InnoDB memcached Plugin in the MySQL documentation.

You can take the following actions to help increase the security of the memcached interface:

MySQL memcached connection information

To access the memcached interface, an application must specify both the DNS name of the Amazon RDS instance and the memcached port number. For example, if an instance has a DNS name of my-cache-instance.cg034hpkmmjt.region.rds.amazonaws.com and the memcached interface is using port 11212, the connection information specified in PHP would be:

<?php

$cache = new Memcache;
$cache->connect('my-cache-instance.cg034hpkmmjt.region.rds.amazonaws.com',11212);
?> 
To find the DNS name and memcached port of a MySQL DB instance
  1. Sign in to the AWS Management Console and open the Amazon RDS console athttps://console.aws.amazon.com/rds/.
  2. In the top right corner of the AWS Management Console, select the region that contains the DB instance.
  3. In the navigation pane, choose Databases.
  4. Choose the MySQL DB instance name to display its details.
  5. In the Connect section, note the value of the Endpoint field. The DNS name is the same as the endpoint. Also, note that the port in the Connect section is not used to access the memcached interface.
  6. In the Details section, note the name listed in the Option Group field.
  7. In the navigation pane, choose Option groups.
  8. Choose the name of the option group used by the MySQL DB instance to show the option group details. In the Options section, note the value of thePort setting for the MEMCACHED option.

MySQL memcached option settings

Amazon RDS exposes the MySQL memcached parameters as option settings in the Amazon RDS MEMCACHED option.

MySQL memcached parameters

Amazon RDS configures these MySQL memcached parameters, and they cannot be modified: DAEMON_MEMCACHED_LIB_NAME,DAEMON_MEMCACHED_LIB_PATH, andINNODB_API_ENABLE_BINLOG. The parameters that MySQL administrators set by using daemon_memcached_options are available as individualMEMCACHED option settings in Amazon RDS.

MySQL daemon_memcached_options parameters

Amazon RDS configures these MySQL DAEMON_MEMCACHED_OPTIONS parameters, they cannot be modified: DAEMON_PROCESS,LARGE_MEMORY_PAGES,MAXIMUM_CORE_FILE_LIMIT,MAX_ITEM_SIZE,LOCK_DOWN_PAGE_MEMORY, MASK,IDFILE, REQUESTS_PER_EVENT,SOCKET, and USER.