Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. Redis is great for the following web use cases (taken from my friend the excellent HighScalability blog, more details here):
- Latest items in a Craigslist or eBay clone
- Leaderboards or Digg & Reddit style voting sites
- Counters and Rate Limiting like number of API calls per client per month
- Stats tracking, like unique pageviews
- Pub/Sub, like Amazon SNS (topic-based message filtering, although content-based filtering can be achieved in your app)
- Message queues, like Amazon SQS
- Caching html fragments, like you would do with memcached
The Redis role currently uses 2.2.X (2.2.5 on CentOS and latest 2.2.X branch from apt repository on Ubuntu).
How To Add This Role
Redis roles are available under the Farm Designer (Main Menu > Farms > Add Button ). If you cannot find something that suits your needs, we recommend using the Role Builder: Main Menu > Roles > Add Button > Role Builder.
Scalr provides useful information about your Redis databases such as the password, DNS endpoints, and data bundles. To have access to your Redis status, go to Main Menu > Farms > Select your farm > Actions (rightmost column) > Redis status.
Scalr generates a unique password for you to connect to your application:
You may also disable redis authentication for speed purposes. In this case, Scalr will automatically create secure iptables rules to only allow access to your redis servers from servers that are in the same farm.
Under the same Redis status, Scalr provides endpoints to connect your application to your database. Information on how to use these endpoints to connect your database to your application is published here.
You can manually create backups of your Redis databases. You can learn more about databases backups below:
As an in-memory database, Redis holds the whole dataset in RAM. Since RAM is volatile (a power down or crash results in total loss of all memory data), Redis offers two persistence models:
- Snapshotting: A semi-persistent durability mode where the dataset is asynchronously transferred from memory to disk from time to time
- Append-only: A file or journal that is written as operations modifying the dataset in memory are processed, which allows Redis to rewrite the append-only file in the background in order to avoid an indefinite growth of the journal.
Backups can be either scheduled automatically in the Farm Designer or created manually on the Redis Status panel. For Amazon EC2 users, their backups will be stored on Amazon S3. Please keep in mind that backups and data bundles are different:
- Data bundles are snapshots of the EBS volume containing the data (binary storage)
- Backups are snapshot of the EBS volume containing the data by running a database dump (object storage)
Backups are taken on slaves and data bundles are taken only on the master server. This is due to technical limitations.
- To setup your backup automatically, go to Main Menu > Farms > Select your farm > Actions (rightmost column) > Edit > Click on the Redis role > Databases settings.
- To create a backup manually, go to Main Menu > Farms > Select your farm > Actions (rightmost column) > Redis status.
- You can see the progress of the current backup bundle.
- You can also view the details of the current or last backup bundle by opening the Main Menu, selecting DB Backups, and clicking on the desired backup.
Currently replication is automatically set up for read scaling only. For example, if you enable scaling for this role, and you set the number of minimum instances to 1 and the maximum to 4, then when Scalr detects a load increase above your defined threshold, it will launch a new instance and automatically configure it to be a slave to the master. Hence instance #1 will be the master, and instances #2, #3, and #4 will be slaves. You can find more information about scaling on our wiki.
In the above example, if instance #1 (the master) becomes unavailable (hardware fault, server crash, alien invasion), then Scalr will detect it and trigger failover. This happens by promoting one of the slave servers, say instance #2, to become a new master, and reconfiguring instances #3 and #4 to replicate from the new master (instance #2). If you set minimum_instances to 2, then Scalr will bring up a slave server (instance #2) even if the load is low, in addition to the master server (instance #1). This is recommended if you need quick failover. Also, when a server fail, Scalr detects it and removes that record from the DNS zone. This means that reads/writes directed at the endpoint will no longer hit the failed server.
|More details on Redis and specific behaviors for Rackspace and AWS can be found under the scaling section.|
Different types of storage ara available to Amazon EC2 users. To select your storage for your Redis databases, go to Main Menu > Farms > Select your farm > Actions (rightmost column) > Edit > Click on the Redis role > Databases settings. Once you have choosen your storage type and launched your farm, you will not be able to change it unless you remove and add the Redis role again.
- EBS Volumes: The data persists independently from the life of an instance.
- Ephemeral device: Ephemeral storage or Instance store volumes are ideal for temporary storage of information that changes frequently, such as buffers, caches, scratch data, and other temporary content, or for data that is replicated across a fleet of instances, such as a load-balanced pool of web servers. The data persists only during the life of the associated Amazon EC2 instance.
- RAID Array: Redundant Array of Independent Disks and is a storage technology that combines multiple disk drive components (EBS volumes) into a logical unit. Data is distributed across the drives in one of several ways called “RAID levels”. Scalr allows you to select 4 different RAID levels, the number of volumes you want and their respective size.
Service Configuration Presets
This application feature is deprecated and should be skipped unless you are using an earlier version of Scalr.
You can think of Service Configuration presets as configuration file templates. For example if you create a ConfigTemplate, apply it to some of your servers and make a change to the presets, Scalr will automatically merge the preset with the config file, overriding previous values. Scalr is smart enough to know which configuration option modifications require a service restart, and which ones don’t. Services Configurations Presets are available for our Redis roles. You can learn about this on the Service Configuration Presets page.
Go to Roles > Service Configuration Presets > Create new (https://my.scalr.net/#/services/configurations/presets/build)
Choose a name and select Redis as a the service
Set the parameters and hit save.
Once you have a ConfigTemplate, you can apply it to your server farm’s roles. Go to Server Farms > View All > Select your farm > Options (rightmost column) > Edit
Select the Redis role to apply the ConfigTemplate
In the left column, click on Services config and select the template
Hit save and you are done!