Database | Amazon ElastiCache for Redis Flashcards
What is Amazon ElastiCache for Redis?
Features
Amazon ElastiCache for Redis | Database
Amazon ElastiCache for Redis is a web service that makes it easy to deploy and run Redis protocol-compliant server nodes in the cloud. The service enables the management, monitoring and operation of a Redis node; creation, deletion and modification of the node can be carried out through the ElastiCache console, the command line interface or the web service APIs. Amazon ElastiCache for Redis supports Redis Master / Slave replication.
Is Amazon ElastiCache for Redis protocol-compliant with open source Redis?
Features
Amazon ElastiCache for Redis | Database
Yes, Amazon ElastiCache for Redis is protocol-compliant with open source Redis. Code, applications, drivers and tools a customer uses today with their existing standalone Redis data store will continue to work with ElastiCache for Redis and no code changes will be required for existing Redis deployments migrating to ElastiCache for Redis unless noted. We currently support Redis 2.8.21, 2.8.22, 2.8.23, 2.8.24 and 3.2.4.
What are Amazon ElastiCache for Redis nodes and shards?
Features
Amazon ElastiCache for Redis | Database
An Amazon ElastiCache node is the smallest building block of an ElastiCache for Redis Cluster deployment. Each node supports the Redis protocol with Amazon’s enhancements and has its own endpoint and port. Multiple types of nodes are supported, each with varying amount of CPU capability, and memory capacity.
A shard is a collection of one or more nodes that is responsible for a partition of the logical key space. Within a shard, a node may exist in isolation or in a primary/replica relationship with other nodes. If there are multiple nodes within a shard, one of the nodes will take on the read/write primary role and all other nodes will take on a read-only replica role.
Does Amazon ElastiCache for Redis support Redis persistence?
Features
Amazon ElastiCache for Redis | Database
Yes, you can achieve persistence by snapshotting your Redis data using the Backup and Restore feature. Please see here for details.
How can I migrate from Amazon ElastiCache for Memcached to Amazon ElastiCache for Redis and vice versa?
Features
Amazon ElastiCache for Redis | Database
We currently do not support automatically migrating from Memcached to Redis or vice versa. You may, however, use a Memcached client to read from a Memcached cluster and use a Redis client to write to a Redis cluster. Similarly, you may read from a Redis cluster using a Redis client and use a Memcached client to write to a Memcached cluster. Make sure to consider the differences in data format, and cluster configuration between the two engines.
Does Amazon ElastiCache for Redis support Multi-AZ operation?
Features
Amazon ElastiCache for Redis | Database
Yes, with Amazon ElastiCache for Redis you can create a read replica in another AWS Availability Zone. Upon a failure of the primary node, we will provision a new primary node. In scenarios where the primary node cannot be provisioned, you can decide which read replica to promote to be the new primary. For more details on how to handle node failures see here.
What options does Amazon ElastiCache for Redis provide for node failures?
Features
Amazon ElastiCache for Redis | Database
Amazon ElastiCache for Redis will repair the node by acquiring new service resources, and will then redirect the node’s existing DNS name to point to the new service resources. Thus, the DNS name for a Redis node remains constant, but the IP address of a Redis node can change over time. If you have a replication group with one or more read replicas and Multi-AZ is enabled, then in case of primary node failure ElastiCache will automatically detect the failure, select a replica and promote it to become the new primary. It will also propagate the DNS so that you can continue to use the primary endpoint and after the promotion it will point to the newly promoted primary. For more details see the Multi-AZ section of this FAWhen Redis replication option is selected with Multi-AZ disabled, in case of primary node failure you will be given the option to initiate a failover to a read replica node. The failover target can be in the same zone or another zone. To failback to the original zone, promote the read replica in the original zone to be the primary. You may choose to architect your application to force the Redis client library to reconnect to the repaired Redis server node. This can help as some Redis libraries will stop using a server indefinitely when they encounter communication errors or timeouts.
Features
Amazon ElastiCache for Redis | Database
How does failover work?
Features
Amazon ElastiCache for Redis | Database
For Multi-AZ enabled replication groups, the failover behavior is described at the Multi-AZ section of this FAQ.
If you choose not to enable Multi-AZ, then if Amazon ElastiCache monitors the primary node, and in case the node becomes unavailable or unresponsive, Amazon ElastiCache for Redis will repair the node by acquiring new service resources, and will then redirect the node’s existing DNS name to point to the new service resources. Thus, the DNS name for a Redis node remains constant, but the IP address of a Redis node can change over time. However, if the primary node cannot be healed (and your Multi-AZ is disabled) you will have the choice to promote one of the read replicas to be the new primary. See here for how to select a new primary. The DNS record of the primary’s endpoint will be updated to point to the promoted read replica node. A read replica node in the original primary’s AZ will then be created to be a read replica in the shard and will follow the new primary.
Are my read replicas available during a primary node failure?
Features
Amazon ElastiCache for Redis | Database
Yes, during a primary node failure, the read replicas continue to service requests. After the primary node is restored, either as a healed node or as a promoted read replica, there is a brief period during which the read replicas will not serve any requests as they sync the cache information from the primary.
How do I configure parameters of my Amazon ElastiCache for Redis nodes?
Features
Amazon ElastiCache for Redis | Database
You can configure your Redis installation using a parameter group, which must be specified for a Redis cluster. All read replica clusters use the parameter group of their primary cluster. A Redis parameter group acts as a “container” for Redis configuration values that can be applied to one or more Redis primary clusters. If you create a Redis primary cluster without specifying a parameter group, a default parameter group is used. This default group contains defaults for the node type you plan to run. However, if you want your Redis primary cluster to run with specified configuration values, you can simply create a new cache parameter group, modify the desired parameters, and modify the primary Redis cluster to use the new parameter group.
Can I access Redis through the Amazon ElastiCache console?
Features
Amazon ElastiCache for Redis | Database
Yes, Redis appears as an Engine option in the ElastiCache console. You can create a new Redis cache cluster with the Launch Wizard by choosing the Redis engine. You can also modify or delete an existing Redis cluster using the ElastiCache console.
Can Amazon ElastiCache for Redis clusters be created in an Amazon VPC?
Features
Amazon ElastiCache for Redis | Database
Yes, just as you can create Memcached clusters within a VPC, you can create Redis clusters within a VPC as well. If your account is a VPC by default account, your Redis clusters will be created within the default VPC associated with your account. Using the ElastiCache console, you can specify a different VPC when you create your cluster.
Is Redis AUTH functionality supported in Amazon ElastiCache for Redis?
Features
Amazon ElastiCache for Redis | Database
Yes, Redis AUTH functionality is available on Amazon ElastiCache for Redis. At the time of Redis cluster creation via the console or command line interface, once you enable encryption in-transit, you can use the Redis AUTH command to provide an authentication token for communication with the Redis cluster.
How do I upgrade to a newer engine version?
Features
Amazon ElastiCache for Redis | Database
You can easily upgrade to a newer engine version by using the ModifyCacheCluster or ModifyReplicationGroup APIs and specifying your preferred engine version for the EngineVersion parameter. On the ElastiCache console, you can select a cluster and click “Modify”. In the “Modify” window select your preferred engine version from the available options. The engine upgrade process is designed to make a best effort to retain your existing data and requires Redis replication to succeed. For more details on that see here.
Can I downgrade to an earlier engine version?
Features
Amazon ElastiCache for Redis | Database
No. Downgrading to an earlier engine version is not supported.
How do I scale up to a larger node type?
Features
Amazon ElastiCache for Redis | Database
You can easily scale up to a larger node type by using the ModifyCacheCluster or ModifyReplicationGroup APIs and specifying your preferred node type for the CacheNodeType parameter. On the ElastiCache console, you can select a cache cluster or replication group and click “Modify”. In the “Modify” window select your preferred node type from the available options. The scale up process is designed to make a best effort to retain your existing data and requires Redis replication to succeed. For more details on that see here.
Can I scale down to a smaller node type?
Read Replica
Amazon ElastiCache for Redis | Database
Moving to a smaller node type is currently not supported.
What does it mean to run a Redis node as a Read Replica?
Read Replica
Amazon ElastiCache for Redis | Database
Read Replicas serve two purposes in Redis:
Failure Handing
Read Scaling
When you run a node with a Read Replica, the “primary” serves both writes and reads. The Read Replica acts as a “standby” which is “promoted” in failover scenarios. After failover, the standby becomes the primary and accepts your cache operations. Read Replicas also make it easy to elastically scale out beyond the capacity constraints of a single node for read-heavy cache workloads.
When would I want to consider using a Redis read replica?
Read Replica
Amazon ElastiCache for Redis | Database
There are a variety of scenarios where deploying one or more read replicas for a given primary node may make sense. Common reasons for deploying a read replica include:
Scaling beyond the compute or I/O capacity of a single primary node for read-heavy workloads. This excess read traffic can be directed to one or more read replicas.
Serving read traffic while the primary is unavailable. If your primary node cannot take I/O requests (e.g. due to I/O suspension for backups or scheduled maintenance), you can direct read traffic to your read replicas. For this use case, keep in mind that the data on the read replica may be “stale” since the primary Instance is unavailable. The read replica can also be used to restart a failed primary warmed up.
Data protection scenarios; in the unlikely event or primary node failure or that the Availability Zone in which your primary node resides becomes unavailable, you can promote a read replica in a different Availability Zone to become the new primary.
How do I deploy a read replica node for a given primary node?
Read Replica
Amazon ElastiCache for Redis | Database
You can create a read replica in minutes using a CreateReplicationGroup API or a few clicks of the Amazon ElastiCache Management Console. When creating a cluster, you specify the MasterCacheClusterIdentifier. The MasterCacheClusterIdentifier is the cache cluster Identifier of the “primary” node from which you wish to replicate. You then create the read replica cluster within the shard by calling the CreateCacheCluster API specifying the ReplicationGroupIdentifier and the CacheClusterIdentifier of the master node. As with a standard cluster, you can also specify the Availability Zone. When you initiate the creation of a read replica, Amazon ElastiCache takes a snapshot of your primary node in a shard and begins replication. As a result, you will experience a brief I/O suspension on your primary node as the snapshot occurs. The I/O suspension typically lasts on the order of one minute.
The read replicas are as easy to delete as they are to create; simply use the Amazon ElastiCache Management Console or call the DeleteCacheCluster API (specifying the CacheClusterIdentifier for the read replica you wish to delete).
Can I create both a primary and read replicas at the same time?
Read Replica
Amazon ElastiCache for Redis | Database
Yes. You can create a new cache cluster along with read replicas in minutes using the CreateReplicationGroup API or using the “Create” wizard at the Amazon ElastiCache Management Console and selecting “Multi-AZ Replication”. When creating the cluster, specify an identifier, the total number of desired shard in a cluster a read replicas per shard, along with cahe creation parameters such as node type, engine version, etc. You can also specify the Availability Zone for each shard in the cluster.
How do I connect to my read replica(s)?
Read Replica
Amazon ElastiCache for Redis | Database
You can connect to a read replica just as you would connect to a primary cache node, using the DescribeCacheClusters API or AWS Management Console to retrieve the endpoint(s) for you read replica(s). If you have multiple read replicas, it is up to your application to determine how read traffic will be distributed amongst them.
How many read replicas can I create for a given primary node?
Read Replica
Amazon ElastiCache for Redis | Database
At this time, Amazon ElastiCache allows you to create up to five (5) read replicas for a given primary node.
What happens to read replicas if failover occurs?
Read Replica
Amazon ElastiCache for Redis | Database
In the event of a failover, any associated and available read replicas should automatically resume replication once failover has completed (acquiring updates from the newly promoted read replica).
Can I create a read replica of another read replica?
Read Replica
Amazon ElastiCache for Redis | Database
Creating a read replica of another read replica is not supported.
Can I promote my read replica into a “standalone” primary node?
Read Replica
Amazon ElastiCache for Redis | Database
No, this is not supported. Instead, you may snapshot your ElastiCache for Redis node (you may select the primary or any of the read-replicas). You can then use the snapshot to seed a new ElastiCache for Redis primary.
Will my read replica be kept up-to-date with its primary node?
Read Replica
Amazon ElastiCache for Redis | Database
Updates to a primary node will automatically be replicated to any associated read replicas. However, with Redis’s asynchronous replication technology, a read replica can fall behind its primary cache node for a variety of reasons. Typical reasons include:
Write I/O volume to the primary cache node exceeds the rate at which changes can be applied to the read replica
Network partitions or latency between the primary cache node and a read replica
Read replicas are subject to the strengths and weaknesses of Redis replication. If you are using read replicas, you should be aware of the potential for lag between a read replica and its primary cache node, or “inconsistency”. You can monitor such lag potentially occuring via the “Replication Lag” CloudWatch metric, accessible through both the ElastiCache console and API, as well as those of the CloudWatch service.
How do I gain visibility into active read replica(s)?
Read Replica
Amazon ElastiCache for Redis | Database
You can use the standard DescribeCacheClusters API to return a list of all the cache clusters you have deployed (including read replicas), or simply click on the “Redis” tab of the Amazon ElastiCache Management Console.
Amazon ElastiCache monitors the replication status of your read replicas and updates the Replication State field to Error if replication stops for any reason. You can review the details of the associated error thrown by the Redis engine by viewing the Replication Error field and take an appropriate action to recover from it. You can learn more about troubleshooting replication issues in the Troubleshooting a Read Replica problem section of the Amazon ElastiCache User Guide. If a replication error is fixed, the Replication State changes to Replicating.
Amazon ElastiCache allows you to gain visibility into how far a read replica has fallen behind its primary through the Amazon CloudWatch metric (“Replica Lag”) available via the AWS Management Console or Amazon CloudWatch APIs.
My read replica has fallen significantly behind its primary node. What should I do?
Read Replica
Amazon ElastiCache for Redis | Database
As discussed in the previous questions, “inconsistency” or lag between a read replica and its primary node is common with Redis asynchronous replication. If an existing read replica has fallen too far behind to meet your requirements, you can reboot it. Keep in mind that replica lag may naturally grow and shrink over time, depending on your primary node’s steady-state usage pattern.
How do I delete a read replica? Will it be deleted automatically if its primary node is deleted?
Read Replica
Amazon ElastiCache for Redis | Database
You can easily delete a read replica with a few clicks of the AWS Management Console or by passing its cache cluster identifier to the DeleteCacheCluster API. If you want to delete the read replica in addition to the primary cache node, you must use the DeleteReplicationGroup API or AWS Management Console.
How much do read replicas cost? When does billing begin and end?
Read Replica
Amazon ElastiCache for Redis | Database
A read replica is billed as a standard node and at the same rates. Just like a standard node, the rate per “Node hour” for a read replica is determined by the node class of the read replica – please see Amazon ElastiCache detail page for up-to-date pricing. You are not charged for the data transfer incurred in replicating data between your primary cache node and read replica. Billing for a read replica begins as soon as the read replica has been successfully created (i.e. when status is listed as “active”). The read replica will continue being billed at standard Amazon ElastiCache cache node hour rates until you issue a command to delete it.
What happens during failover and how long does it take?
Read Replica
Amazon ElastiCache for Redis | Database
Initiated failover is supported by Amazon ElastiCache so that you can resume operations as quickly as possible. When failing over, Amazon ElastiCache simply flips the DNS record for your node to point at the read replica, which is in turn promoted to become the new primary. We encourage you to follow best practices and implement cache node connection retry at the application layer. Start-to-finish, failover typically completes within three to six minutes.
Can I create a read replica in another region as my primary?
Read Replica
Amazon ElastiCache for Redis | Database
No. Your read replica may only be provisioned in the same or different Availability Zone of the same Region as your cache node primary.
Can I see which Availability Zone my primary is currently located in?
Read Replica
Amazon ElastiCache for Redis | Database
Yes, you can gain visibility into the location of the current primary by using the AWS Management Console or DescribeCacheClusters API.
After failover, my primary is now located in a different Availability Zone than my other AWS resources (e.g. EC2 instances).
Should I be concerned about latency?
Multi-AZ
Amazon ElastiCache for Redis | Database
Availability Zones are engineered to provide low latency network connectivity to other Availability Zones in the same Region. In addition, you may want to consider architecting your application and other AWS resources with redundancy across multiple Availability Zones so your application will be resilient in the event of an Availability Zone failure.
What is Multi-AZ for ElastiCache for Redis?
Multi-AZ
Amazon ElastiCache for Redis | Database
An ElastiCache for Redis shard consists of a primary and up to five read replicas. Redis asynchronously replicates the data from the primary to the read replicas. During certain types of planned maintenance, or in the unlikely event of ElastiCache node failure or Availability Zone failure, Amazon ElastiCache will automatically detect the failure of a primary, select a read replica, and promote it to become the new primary. ElastiCache also propagates the DNS changes of the promoted read replica, so if your application is writing to the primary node endpoint, no endpoint change will be needed.
What are the benefits of using Multi-AZ?
Multi-AZ
Amazon ElastiCache for Redis | Database
The main benefits of running your ElastiCache for Redis in Multi-AZ mode are enhanced availability and smaller need for administration. If an ElastiCache for Redis primary node failure occurs, the impact on your ability to read/write to the primary is limited to the time it takes for automatic failover to complete. When Multi-AZ is enabled, ElastiCache node failover is automatic and requires no administration. You no longer need to monitor your Redis nodes and manually initiate a recovery in the event of a primary node disruption.
How does Multi-AZ work?
Multi-AZ
Amazon ElastiCache for Redis | Database
You can use Multi-AZ if you are using ElastiCache for Redis and have a shard consisting of a primary node and one or more read replicas. If the primary node fails, ElastiCache will automatically detect the failure, select one from the available read replicas, and promote it to become the new primary. When cluster_mode parameter is disabled, ElastiCache will propagate the DNS changes of the promoted replica so that your application can keep writing to the primary endpoint. For cluster_mode enabled, ElastiCache will update the node map of the cluster. ElastiCache will also spin up a new node to replace the promoted read replica in the same Availability Zone of the failed primary. In case the primary failed due to temporary Availability Zone disruption, the new replica will be launched once that Availability Zone has recovered.
Can I have replicas in the same Availability Zone as the primary?
Multi-AZ
Amazon ElastiCache for Redis | Database
Yes. Note that placing both the primary and the replica(s) in the same Availability Zone will not make your ElastiCache for Redis replication group resilient to an Availability Zone disruption.
What events would cause Amazon ElastiCache to fail over to a read replica?
Multi-AZ
Amazon ElastiCache for Redis | Database
Amazon ElastiCache will failover to a read replica in the event of any of the following:
Loss of availability in primary’s Availability Zone
Loss of network connectivity to primary
Compute unit failure on primary
When should I use Multi-AZ?
Multi-AZ
Amazon ElastiCache for Redis | Database
Using Redis replication in conjunction with Multi-AZ provides increased availability and fault tolerance. Such deployments are a natural fit for use in production environments. When running ElastiCache for Redis Cluster with cluster mode enabled, if your shards have one or more read replicas, Multi-AZ will automatically be enabled.
How do I create an ElastiCache for Redis replication group with Multi-AZ enabled?
Multi-AZ
Amazon ElastiCache for Redis | Database
You can create an ElastiCache for Redis primary and read replicas by clicking “Create” on the ElastiCache Management Console. You can also do so by calling the CreateReplicationGroup API. For existing clusters (Redis 2.8.6, 2.8.19, 2.8.21, 2.8.22, 2.8.23, 2.8.24 and 3.2.4 with cluster_mode=disabled), you can enable Multi-AZ by choosing a cluster and clicking Modify on the ElastiCache Management Console or by using the ModifyReplicationGroup API. Switching a replication group to Multi-AZ is not disruptive to your Redis data and does not interfere your nodes’ ability to serve requests.
Which read replica will be promoted in case of primary node failure?
Multi-AZ
Amazon ElastiCache for Redis | Database
If there are more than one read replicas, the read replica with the smallest asynchronous replication lag to the primary will be promoted.
How much does it cost to use Multi-AZ?
Multi-AZ
Amazon ElastiCache for Redis | Database
Multi-AZ is free of charge. You only pay for the ElastiCache nodes that you use.
What are the performance implications of Multi-AZ?
Multi-AZ
Amazon ElastiCache for Redis | Database
ElastiCache currently uses the Redis engine’s native, asynchronous replication and is subject to its strengths and limitations. In particular, when a read replica connects to a primary for the first time, or if the primary changes, the read replica does a full synchronization of the data from the primary, imposing load on itself and the primary. For additional details regarding Redis replication please see here.
What node types support Multi-AZ?
Multi-AZ
Amazon ElastiCache for Redis | Database
All available node types in ElastiCache support Multi-AZ with one exception. When using Redis 2.8.x or Redis 3.x with cluster_mode=disabled, T2 family doesn’t support Multi-AZ.