Skip to main content

Scaling in AWS

Create an ElastiCache Redis cache

warning

The purpose of Redis is to share the users' states between multiple instances. Never use Redis when you are using:

  • Vertical scaling (only one instance)
  • Horizontal scaling with sticky sessions. Because in-memory is faster, it is a waste of performance to use a Redis cache when sticky sessions are used.

For more information, see Load balancing, sticky sessions, and Redis

For horizontal scaling without sticky sessions, you must create a Redis cache. AWS has its own ElastiCache Redis cache.

  1. In the AWS console, search for 'ElastiCache', and select the resulting page.
  2. Click the Get started button.
  3. Click Create Cluster, and then Create Redis Cluster.
  4. In the next screen, in the Choose a cluster creation method area, click Configure and create new cluster.
  5. In the Cluster mode field, select Disabled.
  6. Enter a name and a description for Cluster info.
  7. In the Location part, in the Location field, select AWS Cloud, and enable Multi-AZ.
  8. In the Cluster settings part, leave the Engine version, Port, and Parameter group values as they are.
  9. In the Node type field, select a size and network speed that works for your usage. You can change these values later.

To see the difference in pricing, see this page. For Numbers of replicas, we recommend two production environments.

  1. In the Subnet group settings page, create a new subnet group and provide a name, optionally a description.
  2. Select the VPC you want to use.
  3. Leave the settings in the Availability Zone placements page as they are.
  4. Click Next. It is not necessary to enable Encryption.
  5. On the Security groups tab, add a security group that will be used by Elastic Beanstalk. If you do not have an Elastic Beanstalk at this time, you can add the security group later.
  6. In the Backup tab, disable the backup. This is not necessary because the data is short-lived.
  7. In the Maintenance tab, select the settings that work for your application. We recommend enabling Auto update minor versions.
  8. Leave the other settings as they are, and click Next.
  9. In this overview screen, check if all settings are correct. If not, change them as required.
  10. Click Create.

The Redis cache is now created.

To use the newly created Redis cache, add the following section to the appsettings.json configuration file, and specify the Primary endpoint.

"RedisSettings": {
"ConnectionString": "<Primary endpoint>"
},
...

Now, you can deploy this to EC2 or Elastic Beanstalk.

File cache settings for Indicium

To write the cache to an AWS S3 bucket, add the following section to the appsettings.json configuration file:

    "FileCache": {
"Type": "AWSS3",
"AWSRegion": "<Name of the region the s3 bucket is hosted in>",
"AWSAccessKeyID": "<The AWS Access Key ID of the s3 bucket>",
"AWSSecretAccessKey":"<The AWS Secret Access Key of the s3 bucket>",
"AWSBucketName":"<The s3 bucket name>",
"StoragePath": "indicium-cache",
"ClearLocalCacheOnStartup": true // See explanation below
}

ClearLocalCacheOnStartup - Optional. If not set or true, the local cache is cleared on startup. Set it to false if multiple instances of Indicium share the same cache folder. For example, when running multiple app service instances. It prevents that one instance clears the cache while another one tries to access files in the cache.


Was this article helpful?