In the public document, there is a statement like this
"The scale command affects only process types named in the command. For example, if the app already has a dyno formation of two web dynos, and you run heroku ps:scale worker=2, you will now have a total of four dynos (two web, two worker)."
Actually, I have read a whole documentation about Dyno, so I assume I know basic principles.
However, I can't understand the meaning I quoted above. In the case I showed first, how many dynos we have? Now we have two dynos in the situation and then type the command, heroku ps:scale worker=2, so can we get two of worker dynos as well as the original two web dynos?
Maybe I have an easy misunderstanding, but now really confused.
Thanks.
You are correct.
In the example you posted, there is an application running on Heroku that has two types of dynos defined in the application's Procfile:
web: command_to_run_webserver
worker: command_to_run_worker
In the example above, they said that there are ALREADY 2 web servers running (but no workers).
This means that when you run the command:
heroku ps:scale worker=2
Heroku will create two new worker dynos, leaving you with a total of 4 dynos (2 web, and 2 worker).
Related
I currently have one hobby dyno and I'd like to upgrade it to Standard 1x because of the preboot feature laid out here: https://devcenter.heroku.com/articles/preboot
Instead of stopping the existing set of web dynos before starting the
new ones, preboot ensures that the new web dynos are started (and
receive traffic) before the existing ones are terminated. This can
contribute to zero downtime deployments.
The wording is confusing because it sounds like I must have more than 1 dyno for it to work. An old one and a new one. Is this true? Or can I do zero downtime deploys with just 1 standard dyno?
This also works with 1 dyno, since the second dyno then is handled by heroku in the background. We're heavily using it for all kinds of applications.
The article already states most of the important details.
I have deployed my node app on heroku free web dyno plan.I want to know how much free hours are remaining and how much are left so for that I am using
heroku ps -a <AppName>
After running above command I got something like this below:
As per the result everything is clear but what does Web(Free) mean written in green color. Someone please let me know any help would be appreciated.
THANKS
It means your app is running on a single web dyno and free dyno type.
Dyno configurations
Every dyno belongs to one of the three following configurations:
Web: Web dynos are dynos of the “web” process type that is defined in your Procfile. Only web dynos receive HTTP traffic from the routers.
Worker: Worker dynos can be of any process type declared in your Procfile, other than “web”. Worker dynos are typically used for background jobs, queueing systems, and timed jobs. You can have multiple kinds of worker dynos in your application. For example, one for urgent jobs and another for long-running jobs. For more information, see Worker Dynos, Background Jobs and Queueing.
One-off: One-off dynos are temporary dynos that can run detached, or with their input/output attached to your local terminal. They’re loaded with your latest release. They can be used to handle administrative tasks, such as database migrations and console sessions. They can also be used to run occasional background work, as with Heroku Scheduler. For more information, see One-Off Dynos.
Once a web or worker dyno is started, the dyno formation of your app will change (the number of running dynos of each process type) - and subject to dyno lifecycle, Heroku will continue to maintain that dyno formation until you change it. One-off dynos, on the other hand, are only expected to run a short-lived command and then exit, not affecting your dyno formation.
Dyno Types
Heroku provides a number of different dyno types each with a set of unique properties and performance characteristics. Free, Hobby, Standard and Performance dynos are available in the Common Runtime to all Heroku customers. Private Dynos only run in Private Spaces and are available in Heroku Enterprise.
I subscribed a Hobby plan in Heroku.
The details of the plan specifies that it allows up to 10 Process Types.
So I developed an app with the following Procfile:
backend-dev: node ./backend-dev/backend.js
backend-prod: node ./backend-prod/backend.js
Which represents 2 Process Types, right ?
But when I run it with:
heroku ps:scale backend-dev=1
heroku ps:scale backend-prod=1
I end up with two Hobby Dynos...
As the plan also specifies 7€/month/Dyno I am billed 14€/month.
So my questions are:
What is the difference between Process Types and Dynos?
Can I run 2 Process Types within a single Dyno?
Can I run for instance 1 free Dyno (for backend-dev) and 1 Hobby Dyno (for backend-prod)?
Consider this simple example of web application with background worker, so it has web process and worker process. When such app receives a lot of web traffic, but processes very few background jobs, you can increase the number of dynos for your web process, but have only one dyno for worker process. It is also possible to have different dyno size per process. Instead of using more dynos, you can use performance-l dyno for web process and standard-1x for worker process. In other words, Process Types describe different processes that are working together within one application. They are not supposed to be different applications like in your case.
No. You can run one Process Type on multiple dynos.
Technically you can run one process on free dyno and another on hobby, but it won't work in your case. When you upgrade to professional dynos, then all processes must run on professional dynos.
Your Procfile is all wrong. You must have Process Type name web to receive web traffic. If you start your current setup, you will be running two processes, but they will never receive any web requests. It is described in Heroku docs, only web process can receive web traffic and you can only have one such process. So to run two versions of your app, you need to create two different Heroku applications. And ideally you should allow to configure your app via environmental variables so you can deploy the same code to both apps.
I'm a little bit confused about the whole dyno business with heroku . On their site, they define a dyno as:
A dyno is a lightweight Linux container that runs a single
user-specified command. A dyno can run any command available in its
default environment (what we supply in the Cedar stack) or in your
app’s slug (a compressed and pre-packaged copy of your application and
its dependencies).
This (somewhat?) makes sense in my head, but when I think about dynos in the context of multiple dynos running for one web app, my brain gets twisted.
Lets I'm building a web app with a server which runs a very important task only once every 3 hours for all users. If I am running multiple web dynos for this site, does that mean there is a separate server instance running on each dyno? And would that very-important-task that is run every 3 hours be run on each dyno every 3 hours?
Thanks a lot for any clarification!
Each dyno is an LXC container running in one of the heroku instances.
Depending of your dyno size, there might be other containers on the same instance or not.
But the rough idea is that yes, each dyno you have running is a different instance, and a task set to run on any web dyno each 3 hours will run on all of them.
You may want to look into the heroku scheduler addon. It will run a one-off dyno at a specified interval, allowing you to run cron-like tasks.
I have a play 1.2.5 app running on heroku and I want to swap out all jobs into a worker dyno, so they don't scale with the web dynos.
To do that, I need to differentiate, if the application is running on a web or a worker dyno.
Is there any way to accomplish that by passing a command line argument using the procfile?
Currently I see, that by passing custom CLI arguments the JVM fails to be created...
Thanks you in advance!
Heroku uses web as the process type for web dynos.
You need to declare your dynos in your Procfile where you can specify their process types.
You can use any identifier you like, but worker is suggested and seems like a good convention to use.
You can then scale your individual dynos types using:
heroku ps:scale web=1
or
heroku ps:scale worker=1
Also, this post has a good answer that might help you.
Okay, I found it myself:
By adding a -D parameter to the procfile, I can determine the environment play is running in.
So my procfile's going to look like:
web: play run --http.port=$PORT $PLAY_OPTS
worker: play run --http.port=$PORT $PLAY_OPTS -Dprocesstype=worker
By using
System.getProperty("processtype");
I can ensure, that i am on a worker dyno and process my jobs only then.