How to Deploy a Python app on Heroku using Redis
Published: 2022-02-10 12:34:22

![Image34](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/akkvr0u7atcoo247w6ga.png)
 

[Heroku](https://heroku.com) is a container-based cloud Platform as a Service (PaaS). It is a new way of building and deploying web apps. Heroku lets app developers spend 100% of their time on their application code, not managing servers, deployment, ongoing operations, or scaling. Developers use Heroku to deploy, manage, and scale modern apps. The Heroku platform is elegant, flexible, and easy to use, offering developers the simplest path to getting their apps to market.

Some of the notable features offered by Heroku are:

- Agile deployment for Node.js, Java, Python, Ruby, Go and Scala
- Run and scale any type of app
- Flexibility to customize and support unique DevOps workflow needs
- Total visibility across your entire app
- Offers a powerful dashboard and CLI

## Step 1. Create Redis Enterprise Cloud#

Create your free Redis Enterprise Cloud account by [visiting this link](https://redis.com/try-free)

![Image1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yeofxakw7ohn9uraquem.png)
 

Follow this link to create a Redis Enterprise Cloud subscription and database as shown below:

![Image3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cwegmqi9ikvbplbvc20m.png)
 

The database endpoint URL is unique for all and hence might be different in your case. Save it 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.

![Image4](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/57fgl2vt5ad09ed1d9ej.png)
 

## 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-python
```

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

```
$ heroku create
Creating app... done, ⬢ fast-reef-76278
https://fast-reef-76278.herokuapp.com/ | https://git.heroku.com/fast-reef-76278.git
Step 6. Setting up Environment Variables#
Go to the 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.
```
![Image5](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/co8ud2kqq4cfg4igshl7.png)
 

## Step 7. Deploy your code#

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

```
$ git push heroku                        
Enumerating objects: 512, done.
Counting objects: 100% (512/512), done.
Delta compression using up to 12 threads
Compressing objects: 100% (256/256), done.
Writing objects: 100% (512/512), 1.52 MiB | 660.00 KiB/s, done.
Total 512 (delta 244), reused 512 (delta 244)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Python app detected
…

emote: -----> Compressing...
remote:        Done: 59.3M
remote: -----> Launching...
remote:        Released v5
remote:        https://fast-reef-76278.herokuapp.com/ deployed to Heroku
remote: 
remote: Verifying deploy... done.
To https://git.heroku.com/fast-reef-76278.git
 * [new branch]      master -> master
```

## Step 8. Accessing the application

Open https://fast-reef-76278.herokuapp.com/ to see your application

![Image8](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/34bulriffjvdqkb9m4o2.png)
 

## Read More

- [Deploy Java app on Heroku using Redis](https://developer.redis.com/create/heroku/herokujava)
- [Deploy a NodeJS app on Heroku using Redis](https://developer.redis.com/create/heroku/herokunodejs)
- [Deploy a Go app on Heroku using Redis](https://developer.redis.com/create/heroku/herokugo)

Have queries? Reach out to me over [Twitter](https://twitter.com/ajeetsraina)