3
2

More than 1 year has passed since last update.

Elasticacheの設定って分かりにくくないですか?

Last updated at Posted at 2022-05-29

はじめに

Elasticache(Redis)を初めて使った際、設定に少し混乱したので備忘録としてまとめておきます。

アーキテクチャと用語

  • Elasticacheは、たとえNodeが1つだけでも、必ず「クラスター」を構成する
  • 「クラスターモード」とは
    • 「クラスターモード:on」 => 複数のShardにshardingされる(データを分散して配置する)
    • 「クラスターモード:off」 => shardingされない(1つのShardにまとめてデータを配置する)
  • 「レプリケーション」とは
    • Shard内のバックアップのこと。
    • 「クラスターモード:on」であればShardに分散された分だけのバックアップとなる。

※ 図はこちらからお借りしています。
スクリーンショット 2022-05-29 11.55.02.png

エンドポイント

クラスターモードによってエンドポイントの名称は異なる。
「クラスターモード:on」であれば、shardingによりデータは分散されているため、どのNodeと読み書きすべきかはAWS側で決める。このため、Configuration Endpointしか指定できない。

スクリーンショット 2022-05-29 12.41.59.png

CloudFormationサンプル

「クラスターモード:off」かつNodeが1つだけのとき

one-node
ElastiCacheRedis:
    Type: AWS::ElastiCache::ReplicationGroup
    Properties:
      MultiAZEnabled: false
      Engine: redis
      EngineVersion: 6.2
      Port: 6379
      CacheNodeType: !Ref ElastiCacheInstanceType
      NumNodeGroups: 1
      ReplicasPerNodeGroup: 0
      AutomaticFailoverEnabled: false
      AutoMinorVersionUpgrade: false
      CacheSubnetGroupName: !Ref ElastiCacheSubnetGroup
      SecurityGroupIds:
        - !Ref ElastiCacheSecurityGroupId
      CacheParameterGroupName: default.redis6.x

「クラスターモード:on」かつShardが1つだけのとき

one-node
ElastiCacheRedis:
    Type: AWS::ElastiCache::ReplicationGroup
    Properties:
      MultiAZEnabled: true
      Engine: redis
      EngineVersion: 6.2
      Port: 6379
      CacheNodeType: !Ref ElastiCacheInstanceType
      NumNodeGroups: 1
      ReplicasPerNodeGroup: 1
      AutomaticFailoverEnabled: true
      AutoMinorVersionUpgrade: false
      CacheSubnetGroupName: !Ref ElastiCacheSubnetGroup
      SecurityGroupIds:
        - !Ref ElastiCacheSecurityGroupId
      CacheParameterGroupName: default.redis6.x.cluster.on

その他メモ

Redisのパスワード認証はTLS通信が前提となるので、単にパスワード認証を組み込むだけではダメ。

参考

こちらの記事を大いに参考にさせていただきました。多謝。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2