- Quickstarts
- Redis
Redis®* on Render
Render provides fully managed Redis instances for high-throughput, low-latency key-value storage. In a multi-service architecture, a Redis instance often acts as a shared cache, message broker, or job queue.
Paid Redis instances include disk-backed persistence. All instances currently run Redis version 6.2.14.
Quickstarts
These Render quickstarts include steps for provisioning a Redis instance:
- Deploy a Celery background worker
- Deploy Rails with Sidekiq
- Rails caching with Redis
- Connecting to Redis with ioredis
Create your Redis instance
-
Go to dashboard.render.com/new/redis, or select New > Redis in the Render Dashboard.
This form appears:
-
Provide a helpful Name for your instance.
- You can change this value at any time.
-
Choose a Region to run your instance in.
- Choose the same region as your services that will connect to the instance. This minimizes latency and enables communication over your private network.
-
Optionally change the instance’s Maxmemory Policy.
-
Scroll down and select an instance type. This determines its available RAM and connection limit.
-
Click Create Redis.
You’re all set! Your new instance’s status updates to Available in the Render Dashboard when it’s ready to use.
Connect to your Redis instance
Every Redis instance has two different URLs for incoming connections:
- An internal URL for connections from your other Render services running in the same region
- An external URL for connections from everything else
- Before you can use the external URL, you must first enable external connections for your Redis instance.
Use the internal URL wherever possible. It minimizes latency by enabling communication over your private network.
Both URLs are available from the Connect menu in the top-right corner of your instance’s page in the Render Dashboard:
Internal connection examples
To connect with your internal URL, your Redis instance and your connecting service must belong to the same workspace and run in the same region.
# Connect to your internal Redis instance using the REDIS_URL environment variable
# The REDIS_URL is set to the internal Redis URL e.g. redis://red-343245ndffg023:6379
Sidekiq.configure_server do |config|
config.redis = {url: ENV.REDIS_URL}
end
Sidekiq.configure_client do |config|
config.redis = {url: ENV.REDIS_URL}
end
# Simple example from https://github.com/mperham/sidekiq/wiki/Getting-Started
class HardJob
include Sidekiq::Job
def perform(name, count)
# do something
end
end
HardJob.perform_async('bob', 5)
Enabling external connections
By default, newly created Redis instances are not reachable at their external URL. To keep your instance secure, you can grant external access to specific sets of IPs.
In the Render Dashboard, go to your Redis instance’s Info page and scroll down to the Access Control section:
Here you can specify IP address blocks using CIDR notation. The example above grants access to the static outbound IPs for Render’s Ohio region.
These rules apply only to connections that use your Redis instance’s external URL.
Your Render services in the same region as your Redis instance can always connect using your instance’s internal URL.
If you attempt to connect from a disallowed IP address, your client will display an error like the following:
AUTH failed: Client IP address is not in the allowlist.
Connecting with redis-cli
The redis-cli
is a useful administrative tool for exploring and manipulating data on your Redis instance. There are 2 ways you can use redis-cli
with your Redis instance:
-
If you have a running non-Docker service,
redis-cli
will be available as part of the environment and is accessible from the service’s Shell page. The service must be in the same region as the Redis instance. You can also SSH into that service and runredis-cli
from there. -
You can run
redis-cli
locally on your machine. You first need to installredis-cli
onto your machine. A copy and pastableredis-cli
command is available in theExternal Access
section of your Redis settings. Note that you first need to enable external connections for your Redis instance.
External connections are TLS secured. The Redis CLI command provided will include the --tls
flag.
Once you have connected, you can set and get keys using various Redis commands.
oregon-redis.render.com:6379> set "render_is_cool" true
OK
oregon-redis.render.com:6379> get "render_is_cool"
"true"
oregon-redis.render.com:6379> KEYS r*
1) "render_is_cool"
Configure your Redis instance
Maxmemory policy
Your Redis instance’s maxmemory policy determines which data it evicts to free space when it reaches its memory limit. You select a policy on instance creation and can change it later.
- For caching use cases, we recommend using
allkeys-lru
. - For job queues, we recommend using
noeviction
to ensure that queued jobs are not lost. - For other use cases, select a policy from the table below based on your requirements.
You can select any of the following policies:
Option |
Description |
Can memory fill up? |
---|---|---|
|
Evict any key using approximated Least Recently Used (LRU). |
No |
|
Don’t evict data. Instead, return an error on write operations whenever the instance is out of memory. |
Yes |
|
Evict using approximated LRU, only keys with an expire set. | Yes |
|
Evict using approximated Least Frequently Used (LFU), only keys with an expire set. |
Yes |
|
Evict any key using approximated LFU. |
No |
|
Remove a random key having an expire set. |
Yes |
|
Remove a random key, any key. |
No |
|
Remove the key with the nearest expire time (minor TTL) |
Yes |
Changing instance types
You can upgrade your Redis instance to a larger instance type with more RAM and a higher connection limit.
Note the following before you upgrade:
- It is not currently possible to downgrade a Redis instance.
- Your Redis instance will be unavailable for a minute or two during the upgrade.
- If you upgrade a Free Redis instance, all of its data will be lost.
- This is because Free Redis instances don’t persist data to disk.
-
In the Render Dashboard, open your instance’s Info page and scroll down to the Redis Instance section.
-
Under Instance Type, click Update.
-
Select a new instance type and click Save Changes.
Need an instance with more than 10 GB of RAM?
Please reach out to our support team in the Render Dashboard.
Blueprint configuration
As with your other services, you can manage your Redis instances with Blueprints, Render’s infrastructure-as-code model. For details and examples, see the Blueprint YAML Reference.
Data persistence
Paid Redis instances on Render write their state to disk once per second via the configuration appendfsync everysec
. If a paid instance experiences an interruption (or if you upgrade your instance type), you might lose up to one second of writes.
Free Redis instances do not persist data to disk.
Metrics
Metrics for memory usage, CPU load, and active connections are available for Redis instances in the Render Dashboard.
The default metrics granularity shown is 12 hours, which can be adjusted from 5 minutes to 1 week.
*Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. Any use by Render Inc is for referential purposes only and does not indicate any sponsorship, endorsement or affiliation between Redis and Render Inc.