AWS anomaly: how to properly create a redis cache cluster

I want to instantiate elasticity using redis.

I think I should use it "cluster mode disabled" because everything will fit into one server. In order not to have SPOF, I want to create a read replica that will be promoted by AWS if the master fails. If possible, it would be great to balance read operations between master and slave only, but this is not necessary.

I created master / read-replica job using aws console and then used cloudformer to generate cloudformation json conf. Cloudformer created two unrelated ones for me AWS::ElastiCache::CacheCluster

while reading the doc. I don't understand how to link them ... At the moment I have this configuration:

{
    "cachehubcache001": {
      "Type": "AWS::ElastiCache::CacheCluster",
      "Properties": {
        "AutoMinorVersionUpgrade": "true",
        "AZMode": "single-az",
        "CacheNodeType": "cache.t2.small",
        "Engine": "redis",
        "EngineVersion": "3.2.4",
        "NumCacheNodes": "1",
        "PreferredAvailabilityZone": { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "Az1B"]},
        "PreferredMaintenanceWindow": "sun:04:00-sun:05:00",
        "CacheSubnetGroupName": {
          "Ref": "cachesubnethubprivatecachesubnetgroup"
        },
        "VpcSecurityGroupIds": [
          {
            "Fn::GetAtt": [
              "sgiHubCacheSG",
              "GroupId"
            ]
          }
        ]
      }
    },
    "cachehubcache002": {
      "Type": "AWS::ElastiCache::CacheCluster",
      "Properties": {
        "AutoMinorVersionUpgrade": "true",
        "AZMode": "single-az",
        "CacheNodeType": "cache.t2.small",
        "Engine": "redis",
        "EngineVersion": "3.2.4",
        "NumCacheNodes": "1",
        "PreferredAvailabilityZone": { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "Az1A"]},
        "PreferredMaintenanceWindow": "sun:02:00-sun:03:00",
        "CacheSubnetGroupName": {
          "Ref": "cachesubnethubprivatecachesubnetgroup"
        },
        "VpcSecurityGroupIds": [
          {
            "Fn::GetAtt": [
              "sgiHubCacheSG",
              "GroupId"
            ]
          }
        ]
      }
    },
}

      

I know this is wrong, but I cannot figure out how to create the correct replica. I cannot understand the AWS doc, to begin with, I cannot figure out which type I should use between:

Since the cloudformer has created AWS::ElastiCache::CacheCluster

, I will go with it, but I got the feeling that it should only create one resource and use the parameter NumCacheNodes

to create two resources.

redis cannot use:

  • NumCacheNodes

  • AZMode

    and PreferredAvailabilityZones

so I don't know how to make this multi-AZ solution ...

+3


source to share


1 answer


I managed to do this by using the AWS::ElastiCache::ReplicationGroup

parameter NumCacheClusters

provides the ability to have multiple servers. Beware: it seems like you need to handle the control / slave communication yourself (but if the master fails, aws usually has to detect it and change the slave dns so you can point without changing your configuration). Here's an example:



"hubElastiCacheReplicationGroup" : {
      "Type" : "AWS::ElastiCache::ReplicationGroup",
      "Properties" : {
        "ReplicationGroupDescription" : "Hub WebServer redis cache cluster",
        "AutomaticFailoverEnabled" : "false",
        "AutoMinorVersionUpgrade" : "true",
        "CacheNodeType" : "cache.t2.small",
        "CacheParameterGroupName" : "default.redis3.2",
        "CacheSubnetGroupName" :  { "Ref": "cachesubnethubprivatecachesubnetgroup" },
        "Engine" : "redis",
        "EngineVersion" : "3.2.4",
        "NumCacheClusters" : { "Ref" : "ElasticacheRedisNumCacheClusters" },
        "PreferredMaintenanceWindow" : "sun:04:00-sun:05:00",
        "SecurityGroupIds" : [ { "Fn::GetAtt": ["sgHubCacheSG",  "GroupId"] } ]
      }
    },

      

+1


source







All Articles