I'm using New Relic for server analytics of a Heroku app. The app uses the Puma web server and MAX_THREADS is set to 1.
Why does New Relic says that I've got 4 app instances on each Heroku dyno rather than just 1?
web.1
4 app instances
web.2
4 app instances
worker.1
1 app instance
I'm thinking that an "app instance" on New Relic is the same as a thread. Or does it refer to something else?
App instance means worker. this worker is different with heroku worker. it is process that is forked.
If you set 1 max thread, there are 4 processes(workers) and each process has 1 thread.
Check your puma's thread and worker configuration
Related
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 want to add scheduled jobs in Openshift, which would be getting added dynamically to my application. I had tried the cron service on Openshift, but it stops after certain amount of time. I want to add a service similar to Iron workers or heroku workers, but these services seem to be costly. Also is it possible to implement such a service on our own in Openshift?
First off, I'm guessing your Cron service is stopping when your application idles. Idling occurs when your app doesn't receive web traffic for 24 hours. Just upgrade to the Bronze plan to remove idling (it's free).
Second off, you can add IronWorker as an Add-on Service through the OpenShift Marketplace: https://hub.openshift.com/addons/10-ironworker
If you're using Ruby you could also just run Resque with Redque Scheduler along with the downloadable Redis cartridge:
Resque/Resque Scheduler: https://github.com/resque
Redis: https://hub.openshift.com/addons/34-redis
Is it possible to run 2 different web process in one instance, like
for /url1/ some process
and
for /url2/ another
or some port manipulation?
Heroku has the concept of Dynos. They can roughly be thought of as processes.
It is possible for multiple processes to run under each Dyno. Requests are load balanced by Heroku. No special configuration is required.
For example, the Unicorn web server can be configured to spawn "worker" processes. Each "worker" serves a HTTP request. So, if you configure Unicorn to have 3 workers, 2 Dynos would give you 6 processes to serve HTTP requests.
These articles should help you understand how Heroku works:
Dynos and the Dyno Manifold
The Process Model
I've got an Express Web app running as my main app on Heroku Cedar. I need to run a worker job periodically. I know I can specify a worker: in my Procfile, but that seems to be for a forever running kind of job. Perhaps there is a way to have the event mechanism of nodeJS caus e the worker to Idle, and use Cron to poke it alive periodically??
to keep your process alive you can try using an external service which will "ping" your application, you can use the newrelice free addon on heroku for that.
I am currently experimenting and it seems that even with this the application is still put in idle mode but it restarts on the next "ping" so it is still up most of the time.
I don't known node.js but I do my worker with Ruby+EventMachine inside a ruby on rails application and it works fine, you just need something to work in the background aside of your web requests.