Choosing a network type in ElastiCache - Amazon ElastiCache

Choosing a network type in ElastiCache

ElastiCache supports the Internet Protocol versions 4 and 6 (IPv4 and IPv6), allowing you to configure your cluster to accept:

  • only IPv4 connections,

  • only IPv6 connections,

  • both IPv4 and IPv6 connections (dual-stack)

IPv6 is supported for workloads using Valkey 7.2 and onward, or Redis OSS engine version 6.2 and onward on all instances built on the Nitro system. There are no additional charges for accessing ElastiCache over IPv6.

Note

Migration of clusters created prior to the availability of IPV6 / dual-stack is not supported. Switching between network types on newly created clusters is also not supported.

IPv6 is supported for workloads using Memcached engine version 1.6.6 onward on all instances built on the Nitro system. There are no additional charges for accessing ElastiCache over IPv6.

Configuring subnets for network type

If you create a cluster in an Amazon VPC, you must specify a subnet group. ElastiCache uses that subnet group to choose a subnet and IP addresses within that subnet to associate with your nodes. ElastiCache clusters require a dual-stack subnet with both IPv4 and IPv6 addresses assigned to them to operate in dual-stack mode and an IPv6-only subnet to operate as IPv6-only.

Using dual-stack

When using ElastiCache (Redis OSS) in cluster mode enabled, from an application's perspective, connecting to all the cluster nodes through the configuration endpoint is no different than connecting directly to an individual cache node. To achieve this, a cluster-aware client must engage in a cluster discovery process and request the configuration information for all nodes. Redis' discovery protocol supports only one IP per node.

When you create a cache cluster with ElastiCache (Memcached)and choose dual-stack as the network type, you then need to designate an IP discovery type – either IPv4 or IPv6. ElastiCache will default the network type and IP discovery to IPv6, but that can be changed. If you use Auto Discovery, only the IP addresses of your chosen IP type are returned returned to the Memcached client. For more information, see Automatically identify nodes in your cluster (Memcached).

To maintain backwards compatibility with all existing clients, IP discovery is introduced, which allows you to select the IP type (i.e., IPv4 or IPv6) to advertise in the discovery protocol. While this limits auto discovery to only one IP type, dual-stack is still beneficial for cluster mode enabled workloads, as it enables migrations (or rollbacks) from an IPv4 to an IPv6 Discovery IP type with no downtime.

TLS enabled dual stack ElastiCache clusters

When TLS is enabled for ElastiCache clusters the cluster discovery functions such as cluster slots, cluster shards, and cluster nodes with Valkey or Redis OSS and config get cluster with Memcached return hostnames instead of IPs. The hostnames are then used instead of IPs to connect to the ElastiCache cluster and perform a TLS handshake. This means that clients won’t be affected by the IP Discovery parameter. For TLS enabled clusters the IP Discovery parameter has no effect on the preferred IP protocol. Instead, the IP protocol used will be determined by which IP protocol the client prefers when resolving DNS hostnames.

For examples on how to configure an IP protocol preference when resolving DNS hostnames, see TLS enabled dual stack ElastiCache clusters.

Using the AWS Management Console (Valkey and Redis OSS)

When creating a cluster using the AWS Management Console, under Connectivity, choose a network type, either IPv4, IPv6 or Dual stack. If you are creating a Valkey or Redis OSS (cluster mode enabled) cluster and choose dual stack, you then must select a Discovery IP type, either IPv6 or IPv4.

For more information, see Creating a Valkey or Redis OSS (cluster mode enabled) cluster (Console) or Creating a Valkey or Redis OSS (cluster mode disabled) (Console).

When creating a replication group using the AWS Management Console, choose a network type, either IPv4, IPv6 or Dual stack. If you choose dual stack, you then must select a Discovery IP type, either IPv6 or IPv4.

For more information, see Creating a Valkey or Redis OSS (Cluster Mode Disabled) replication group from scratch or Creating a replication group in Valkey or Redis OSS (Cluster Mode Enabled) from scratch.

Using the AWS Management Console (Memcached)

When creating a cache cluster using the AWS Management Console, under Connectivity, choose a network type, either IPv4, IPv6 or Dual stack. If you choose dual stack, you then must select a Discovery IP type, either IPv6 or IPv4.

For more information, see Creating a Memcached cluster (console).

Using the CLI with Valkey, Redis OSS or Memcached

Redis OSS

When creating a cache cluster with Valkey or Redis OSS using the CLI, you use the create-cache-cluster command and specify the NetworkType and IPDiscovery parameters:

For Linux, macOS, or Unix:

aws elasticache create-cache-cluster \ --cache-cluster-id "cluster-test" \ --engine redis \ --cache-node-type cache.m5.large \ --num-cache-nodes 1 \ --network-type dual_stack \ --ip-discovery ipv4

For Windows:

aws elasticache create-cache-cluster ^ --cache-cluster-id "cluster-test" ^ --engine redis ^ --cache-node-type cache.m5.large ^ --num-cache-nodes 1 ^ --network-type dual_stack ^ --ip-discovery ipv4

When creating a replication group with cluster mode disabled using the CLI, you use the create-replication-group command and specify the NetworkType and IPDiscovery parameters:

For Linux, macOS, or Unix:

aws elasticache create-replication-group \ --replication-group-id sample-repl-group \ --replication-group-description "demo cluster with replicas" \ --num-cache-clusters 3 \ --primary-cluster-id redis01 \ --network-type dual_stack \ --ip-discovery ipv4

For Windows:

aws elasticache create-replication-group ^ --replication-group-id sample-repl-group ^ --replication-group-description "demo cluster with replicas" ^ --num-cache-clusters 3 ^ --primary-cluster-id redis01 ^ --network-type dual_stack ^ --ip-discovery ipv4

When creating a replication group with cluster mode enabled and use IPv4 for IP discovery using the CLI, you use the create-replication-group command and specify the NetworkType and IPDiscovery parameters:

For Linux, macOS, or Unix:

aws elasticache create-replication-group \ --replication-group-id demo-cluster \ --replication-group-description "demo cluster" \ --cache-node-type cache.m5.large \ --num-node-groups 2 \ --engine redis \ --cache-subnet-group-name xyz \ --network-type dual_stack \ --ip-discovery ipv4 \ --region us-east-1

For Windows:

aws elasticache create-replication-group ^ --replication-group-id demo-cluster ^ --replication-group-description "demo cluster" ^ --cache-node-type cache.m5.large ^ --num-node-groups 2 ^ --engine redis ^ --cache-subnet-group-name xyz ^ --network-type dual_stack ^ --ip-discovery ipv4 ^ --region us-east-1

When creating a replication group with cluster mode enabled and use IPv6 for IP discovery using the CLI, you use the create-replication-group command and specify the NetworkType and IPDiscovery parameters:

For Linux, macOS, or Unix:

aws elasticache create-replication-group \ --replication-group-id demo-cluster \ --replication-group-description "demo cluster" \ --cache-node-type cache.m5.large \ --num-node-groups 2 \ --engine redis \ --cache-subnet-group-name xyz \ --network-type dual_stack \ --ip-discovery ipv6 \ --region us-east-1

For Windows:

aws elasticache create-replication-group ^ --replication-group-id demo-cluster ^ --replication-group-description "demo cluster" ^ --cache-node-type cache.m5.large ^ --num-node-groups 2 ^ --engine redis ^ --cache-subnet-group-name xyz ^ --network-type dual_stack ^ --ip-discovery ipv6 ^ --region us-east-1

Memcached

When creating a cache cluster with Memcached using the CLI, you use the create-cache-cluster command and specify the NetworkType and IPDiscovery parameters:

For Linux, macOS, or Unix:

aws elasticache create-cache-cluster \ --cache-cluster-id "cluster-test" \ --engine memcached \ --cache-node-type cache.m5.large \ --num-cache-nodes 1 \ --network-type dual_stack \ --ip-discovery ipv4

For Windows:

aws elasticache create-cache-cluster ^ --cache-cluster-id "cluster-test" ^ --engine memcached ^ --cache-node-type cache.m5.large ^ --num-cache-nodes 1 ^ --network-type dual_stack ^ --ip-discovery ipv4