Finding connection endpoints - Amazon ElastiCache

Finding connection endpoints

Your application connects to your cluster using endpoints. An endpoint is a node or cluster's unique address.

Which endpoints to use
  • Memcached cluster, If you use Automatic Discovery, you can use the cluster's configuration endpoint to configure your Memcached client. This means you must use a client that supports Automatic Discovery.

    If you don't use Automatic Discovery, you must configure your client to use the individual node endpoints for reads and writes. You must also keep track of them as you add and remove nodes.

     

The following sections guide you through discovering the endpoints you'll need for the engine you're running.

All Memcached endpoints are read/write endpoints. To connect to nodes in a Memcached cluster your application can use either the endpoints for each node, or the cluster's configuration endpoint along with Automatic Discovery. To use Automatic Discovery you must use a client that supports Automatic Discovery.

When using Automatic Discovery, your client application connects to your Memcached cluster using the configuration endpoint. As you scale your cluster by adding or removing nodes, your application will automatically "know" all the nodes in the cluster and be able to connect to any of them. Without Automatic Discovery your application would have to do this, or you'd have to manually update endpoints in your application each time you added or removed a node. For additional information on Automatic Discovery, see Automatically identify nodes in your cluster.

To copy an endpoint, choose the copy icon directly in front of the endpoint address. For information on using the endpoint to connect to a node, see Connecting to nodes.

Configuration and node endpoints look very similar. The differences are highlighted with bold following.

myclustername.xxxxxx.cfg.usw2.cache.amazonaws.com:port # configuration endpoint contains "cfg" myclustername.xxxxxx.0001.usw2.cache.amazonaws.com:port # node endpoint for node 0001
Important

If you choose to create a CNAME for your Memcached configuration endpoint, in order for your automatic discovery client to recognize the CNAME as a configuration endpoint, you must include .cfg. in the CNAME.

You can use the AWS CLI for Amazon ElastiCache to discover the endpoints for nodes and clusters.

Finding Endpoints for Nodes and Clusters (AWS CLI)

You can use the AWS CLI to discover the endpoints for a cluster and its nodes with the describe-cache-clusters command. For Memcached clusters, the command returns the configuration endpoint. If you include the optional parameter --show-cache-node-info, the command will also return the endpoints of the individual nodes in the cluster.

The following command retrieves the configuration endpoint (ConfigurationEndpoint) and individual node endpoints (Endpoint) for the Memcached cluster mycluster.

For Linux, macOS, or Unix:

aws elasticache describe-cache-clusters \ --cache-cluster-id mycluster \ --show-cache-node-info

For Windows:

aws elasticache describe-cache-clusters ^ --cache-cluster-id mycluster ^ --show-cache-node-info

Output from the above operation should look something like this (JSON format).

{ "CacheClusters": [ { "Engine": "memcached", "CacheNodes": [ { "CacheNodeId": "0001", "Endpoint": { "Port": 11211, "Address": "mycluster.1abc4d.0001.usw2.cache.amazonaws.com" }, "CacheNodeStatus": "available", "ParameterGroupStatus": "in-sync", "CacheNodeCreateTime": "2016-09-22T21:30:29.967Z", "CustomerAvailabilityZone": "us-west-2b" }, { "CacheNodeId": "0002", "Endpoint": { "Port": 11211, "Address": "mycluster.1abc4d.0002.usw2.cache.amazonaws.com" }, "CacheNodeStatus": "available", "ParameterGroupStatus": "in-sync", "CacheNodeCreateTime": "2016-09-22T21:30:29.967Z", "CustomerAvailabilityZone": "us-west-2b" }, { "CacheNodeId": "0003", "Endpoint": { "Port": 11211, "Address": "mycluster.1abc4d.0003.usw2.cache.amazonaws.com" }, "CacheNodeStatus": "available", "ParameterGroupStatus": "in-sync", "CacheNodeCreateTime": "2016-09-22T21:30:29.967Z", "CustomerAvailabilityZone": "us-west-2b" } ], "CacheParameterGroup": { "CacheNodeIdsToReboot": [], "CacheParameterGroupName": "default.memcached1.4", "ParameterApplyStatus": "in-sync" }, "CacheClusterId": "mycluster", "PreferredAvailabilityZone": "us-west-2b", "ConfigurationEndpoint": { "Port": 11211, "Address": "mycluster.1abc4d.cfg.usw2.cache.amazonaws.com" }, "CacheSecurityGroups": [], "CacheClusterCreateTime": "2016-09-22T21:30:29.967Z", "AutoMinorVersionUpgrade": true, "CacheClusterStatus": "available", "NumCacheNodes": 3, "ClientDownloadLandingPage": "https://console.aws.amazon.com/elasticache/home#client-download:", "CacheSubnetGroupName": "default", "EngineVersion": "1.4.24", "PendingModifiedValues": {}, "PreferredMaintenanceWindow": "mon:09:00-mon:10:00", "CacheNodeType": "cache.m4.large", } ] }
Important

If you choose to create a CNAME for your Memcached configuration endpoint, in order for your auto discovery client to recognize the CNAME as a configuration endpoint, you must include .cfg. in the CNAME. For example, mycluster.cfg.local in your php.ini file for the session.save_path parameter.

For more information, see the topic describe-cache-clusters.

You can use the Amazon ElastiCache API to discover the endpoints for nodes and clusters.

Finding Endpoints for Nodes and Clusters (ElastiCache API)

You can use the ElastiCache API to discover the endpoints for a cluster and its nodes with the DescribeCacheClusters action. For Memcached clusters, the command returns the configuration endpoint. If you include the optional parameter ShowCacheNodeInfo, the action also returns the endpoints of the individual nodes in the cluster.

The following command retrieves the configuration endpoint (ConfigurationEndpoint) and individual node endpoints (Endpoint) for the Memcached cluster mycluster.

https://elasticache.us-west-2.amazonaws.com/ ?Action=DescribeCacheClusters &CacheClusterId=mycluster &ShowCacheNodeInfo=true &SignatureVersion=4 &SignatureMethod=HmacSHA256 &Timestamp=20150202T192317Z &Version=2015-02-02 &X-Amz-Credential=<credential>
Important

If you choose to create a CNAME for your Memcached configuration endpoint, in order for your auto discovery client to recognize the CNAME as a configuration endpoint, you must include .cfg. in the CNAME. For example, mycluster.cfg.local in your php.ini file for the session.save_path parameter.