Skip to main content

Deploy a Ruby app on Heroku using Redis

Profile picture for Ajeet Raina
Ajeet Raina, Former Developer Growth Manager at Redis

Heroku is a popular PaaS offering that allows software developers to easily deploy their code without worrying about the underlying infrastructure. By using a simple 'git push heroku' command, developers are able to deploy their application flawlessly. This platform offers support for a wide range of programming languages such as Java, Ruby, PHP, Node.js, Python, Scala, and Clojure.

Here's a quickstart guide to deploy Ruby apps on Heroku using Redis. We will be deploying a sample Leaderboard app and will be using company valuation and stock tickers as its domain.

Step 1. Create a Redis Enterprise Cloud Database​

Create your free Redis Enterprise Cloud account by visiting this link.


For a limited time, use TIGER200 to get $200 credits on Redis Enterprise Cloud and try all the advanced capabilities!

πŸŽ‰ Click here to sign up


Follow this link to create a Redis Enterprise Cloud subscription and database. Once you create the database, you will be provisioned with a unique database endpoint URL, port and password. Save these for future reference.

Step 2. Create a Heroku account​

If you are using Heroku for the first time, create your new Heroku account through this link.

Step 3. Install the Heroku CLI on your system​

 brew install heroku

Step 4. Login to Heroku​

 heroku login
heroku: Press any key to open up the browser to login or q to exit:
Opening browser to
Logging in... done
Logged in as your_email_address

Step 5. Connect your application to Redis Enterprise Cloud​

For this demonstration, we will be using a Sample Redis Leaderboard app.

Clone the repository​

 git clone

Run the commands below to get a functioning Git repository that contains a simple application as well as a app.json file.

heroku create
Creating app... done, β¬’ thawing-shore-07338 |

Step 6. Setting up Environment Variables​

Go to the Heroku dashboard, click "Settings" and set REDIS_HOST and REDIS_PASSWORD under the Config Vars. Refer to Step 1 for the correct values to use.


You now have a functioning Git repository that contains a simple application as well as a app.json file, which is used by Node’s dependency manager.

Step 7. Deploy your code​

$ git push heroku

Wait for few seconds and you will see the messages below:

remote: -----> Discovering process types
remote: Procfile declares types -> (none)
remote: Default types for buildpack -> console, rake, web
remote: -----> Compressing...
remote: Done: 125.9M
remote: -----> Launching...
remote: Released v10
remote: deployed to Heroku
remote: Verifying deploy... done.
* [new branch] master -> master

Step 8. Accessing the application​

Open to access your application on the browser.


The Web URL is unique, hence it will be different in your case.


How does it work?​

How the data is stored:​

  • The AAPL's details - market cap of 2.6 triillions and USA origin - are stored in a Redis hash like this:

     HSET "company:AAPL" symbol "AAPL" market_cap "2600000000000" country USA
  • The market capitalization for each company is also stored in a ZSET (Redis Sorted Set).

     ZADD  companyLeaderboard 2600000000000 company:AAPL

How the data is accessed:​

  • Top 10 companies:

     ZREVRANGE companyLeaderboard 0 9 WITHSCORES
  • All companies:

     ZREVRANGE companyLeaderboard 0 -1 WITHSCORES
  • Bottom 10 companies:

     ZRANGE companyLeaderboard 0 9 WITHSCORES
  • Between rank 10 and 15:

     ZREVRANGE companyLeaderboard 9 14 WITHSCORES
  • Show rank for AAPL, FB and TSLA:

     ZREVRANGE  companyLeaderBoard company:AAPL company:FB company:TSLA
  • Add 1 billion to the market cap of the FB company:

     ZINCRBY companyLeaderBoard 1000000000 "company:FB"
  • Reduce the market cap of the FB company by 1 billion:

     ZINCRBY companyLeaderBoard -1000000000 "company:FB"
  • How many companies have a market cap between 500 billion and 1 trillion?:

     ZCOUNT companyLeaderBoard 500000000000 1000000000000
  • How many companies have a market cap over a Trillion?:

     ZCOUNT companyLeaderBoard 1000000000000 +inf

Next Steps​