28

I'm looking for a straightforward explanation of what all happens when I enter the following command:

heroku ps:scale web=1 

What is Heroku doing behind the scenes to deploy the app? I ask because I'm just now using Heroku to deploy and would like to better understand the process. Thanks!

Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
Ahmed Haque
  • 7,174
  • 6
  • 26
  • 33

4 Answers4

37

This command does not deploy the app. It starts it, after you have deployed.

When you deploy your application, heroku creates a "slug". A runnable zipped version of your app which is then stored. You can then start "dynos", which take your current slug and start it on one of heroku's servers.

Running heroku ps:scale web=1 will scale your app to one running dyno, basically meaning you have one server running your app currently.

If you deploy your app again, a new slug will be generated and stored, and your currently running dynos will be destroyed, to be replaced by new ones with the new version of your code.

Damien MATHIEU
  • 31,924
  • 13
  • 86
  • 94
  • 1
    What is happening if I only deployed the code onto Heroku but didn't run ```heroku ps:scale web=1```? I found that I can still reach the site in this case. So is it meant running ```heroku ps:scale web=1``` is not a must? – xemexpress Nov 14 '21 at 23:53
  • 2
    On a first deploy, Heroku will automatically scale the web process to 1. If you run `heroku ps`, you will see you do have one dyno running. – Damien MATHIEU Nov 15 '21 at 08:44
  • thanks! @Damien MATHIEU – xemexpress Nov 16 '21 at 11:46
5

Whenever you freshly deploy your app in heroku it starts up one dyno where the app runs. Just consider it as a server. This server cant handle large number of requests all at once.

So in order to handle all these bulk requests you may want to run multiple instances of your app i.e. multiple dyno using the spare resources available in heroku just like running multiple instances in tomcat for the same application using the command (within limits ofcourse):

heroku ps:scale web=<number_dynos_u_want>

Heroku does the load-balancing for you. Thus you are able to horizontally scale your app to handle more load. Hope this clears this concept!

3

Though the other answers are correct, I think some might find it useful to understand the actual breakdown of the command.

  • ps is a command which prefixes many commands affecting dynos (~virtual machine instances); I'm assuming it's related to the linux ps command, which stands for "process status."
  • ps:scale is used to increase the number of dynos running a process.
  • ps:scale web=1 specifies to run the process on 1 web dyno.

An index of Heroku CLI commands can be found here: https://devcenter.heroku.com/articles/heroku-cli-commands

Andrew
  • 3,825
  • 4
  • 30
  • 44
1

You scale the number of web dynos to 1.
I would say there is a lot of docu about this topic.
https://devcenter.heroku.com/articles/scaling
https://devcenter.heroku.com/articles/dynos

noBillSide
  • 528
  • 5
  • 18