Skip to main content

Profile picture for Ajeet Raina
Author:
Ajeet Raina, was Developer Growth Manager at Redis

Deploy Java app on Heroku using Redis

Heroku is a cloud service provider and software development platform which facilitates fast and effective building, deploying and scaling of web applications. It offers you a ready-to-use environment that allows you to deploy your code fast.

Some of the notable benefits of Heroku include:

  • Users can get started with the free tier of Heroku
  • Let developers concentrate on coding and not server management
  • Integrates with familiar developer workflows
  • Enhance the productivity of cloud app development teams
  • Helps your development, QA, and business stakeholders create a unified dashboard
  • Support for Modern Open Source Languages

Step 1. Create Redis Enterprise Cloud​

Create your free Redis Enterprise Cloud account by visiting this link

TIP

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

recloud

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

heroku

Step 3. Install 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 https://cli-auth.heroku.com/auth/cli/browser/XXXXXXXXXXA
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 Rate Limiting application.

Clone the repository​

 git clone https://github.com/redis-developer/basic-rate-limiting-demo-java
heroku create
Creating app... done, β¬’ hidden-woodland-03996
https://hidden-woodland-03996.herokuapp.com/ | https://git.heroku.com/hidden-woodland-03996.git

Step 6. Setting up Environment Variables​

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

heroku

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

Step 7. Deploy your code​

Heroku generates a random name (in this case hidden-woodland-03996) for your app, or you can pass a parameter to specify your own app name. Now deploy your code:

$ git push heroku
remote: BUILD SUCCESSFUL in 1m 5s
remote: 12 actionable tasks: 12 executed
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 298.9M
remote: -----> Launching...
remote: Released v3
remote: https://hidden-woodland-03996.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/hidden-woodland-03996.git
* [new branch] master -> master

Step 8. Accessing the application​

Open https://hidden-woodland-03996.herokuapp.com/ to see your application

heroku

Next Steps​