ablog

不器用で落着きのない技術者のメモ

ElastiCache(Redis) の障害時動作

There are a number of instances where ElastiCache for Redis may need to replace a primary node; these include certain types of planned maintenance and the unlikely event of a primary node or Availability Zone failure.

This replacement results in some downtime for the cluster, but if Multi-AZ is enabled, the downtime is minimized. The role of primary node will automatically fail over to one of the read replicas. There is no need to create and provision a new primary node, because ElastiCache will handle this transparently. This failover and replica promotion ensure that you can resume writing to the new primary as soon as promotion is complete.

ElastiCache also propagates the Domain Name Service (DNS) name of the promoted replica. It does so because then if your application is writing to the primary endpoint, no endpoint change is required in your application. If you are reading from individual endpoints, make sure that you change the read endpoint of the replica promoted to primary to the new replica's endpoint.

Minimizing downtime in ElastiCache for Redis with Multi-AZ - Amazon ElastiCache for Redis

Multi-AZ を有効にしていると、プライマリノード障害時に自動的にレプリカにフェイルオーバーし、DNSも自動的に書き換わるため、アプリからの接続先を変更する必要はない。

Failure scenarios with Multi-AZ responses

Before the introduction of Multi-AZ, ElastiCache detected and replaced a cluster's failed nodes by recreating and reprovisioning the failed node. If you enable Multi-AZ, a failed primary node fails over to the replica with the least replication lag. The selected replica is automatically promoted to primary, which is much faster than creating and reprovisioning a new primary node. This process usually takes just a few seconds until you can write to the cluster again.

Minimizing downtime in ElastiCache for Redis with Multi-AZ - Amazon ElastiCache for Redis

フェイルオーバーに要する時間は数秒程度。

Failure scenarios when only the primary node fails

If only the primary node fails, the read replica with the least replication lag is promoted to primary. A replacement read replica is then created and provisioned in the same Availability Zone as the failed primary.

Minimizing downtime in ElastiCache for Redis with Multi-AZ - Amazon ElastiCache for Redis

プライマリノード障害時はレプリカがプライマリに昇格し、障害が発生したプライマリと同じAZにレプリカが作成される。

Q: マルチ AZ はどのように機能するのですか?

Amazon ElastiCache for Redis を利用する際、レプリケーショングループ内にプライマリノードと、1 つ以上のリードレプリカがある場合にマルチ AZ を使用できます。プライマリノードに障害が発生すると、Amazon ElastiCache は自動的に障害を検知し、利用可能なリードレプリカを 1 つ選択し、新しいプライマリに昇格させます。Amazon ElastiCache は昇格したレプリカの DNS の変更を伝達します。そのためアプリケーションはプライマリのエンドポイントに書き込み続けることが可能です。また、障害が発生したプライマリのアベイラビリティーゾーンには、昇格したリードレプリカを置き換えるための新しいノードが Amazon ElastiCache によってスピンアップされます。プライマリの障害が、一時的なアベイラビリティーゾーンの中断によって起きた場合、アベイラビリティーゾーンの復旧後に新しいレプリカが起動します。

プライマリノード側がAZ障害になった場合、AZ復旧後に同じAZにレプリカが作成される。