mav
mav

Reputation: 137

Moving to Heroku free: dynos, sleeps and quartz

I have a small java spring web app hosted in openshift starter (free plan) but they are going to make free accounts expire after 60 days https://blog.openshift.com/changes-to-openshift-online-starter-tier/

I’m trying to find a free platform to host my app and I have found Heroku, but I don’t know if it fits well (please, don’t be hard, I’m just trying to know how heroku works!) .

Currently I have a wildfly server and a mysql database running in 1 pod each one. Heroku free plan (https://www.heroku.com/free) says that you have 1 web dyno per app. Does the web dyno covers the web server and the database? I haven’t found anything about dynos when using a database https://devcenter.heroku.com/articles/getting-started-with-java#use-a-database

Also, my app have a quartz job running each hour. It basically calls a webservice, takes the info and generate statistics in the bbdd. I have seen that Heroku apps sleep automatically after 30 mins of inactivity. How does this affect to my app? Seems that apps wake with web request, but what about background task? Do I need to move the quartz job to a worker dyno? Seems that worker dynos don’t sleep, but… are they consuming dyno hours only while they are being executed (3 mins each hour) or they consume dyno hours while they are idle too (24/7)?

If verified accounts have 1000 hours / month and the app consumes only 1 web dyno then there is no need to let the app sleep, right? One month should be less than 750 hours using only 1 dyno. Is there any way to keep the app alive?
Also, what involves when an app sleeps? It changes the app IP everytime it wakes up?

Sorry if some of them are newbie questions and thanks in advance!

Upvotes: 0

Views: 740

Answers (1)

Mavi Domates
Mavi Domates

Reputation: 4521

I'll try to go through your questions one by one.

Heroku free plan (https://www.heroku.com/free) says that you have 1 web dyno per app. Does the web dyno covers the web server and the database?

No - it doesn't. Heroku has add-ons which you can provision for your app though, see here for MySQL add-ons. See how you can add / use them here.

Also, my app have a quartz job running each hour. It basically calls a webservice, takes the info and generate statistics in the bbdd. I have seen that Heroku apps sleep automatically after 30 mins of inactivity. How does this affect to my app?

That means if you receive a single request (and the server isn't warm already) to serve you'll be burning 30 minutes of dyno hours. Waking up the server for just 1 request per 30 minutes is not very efficient, but that's the system.

Seems that apps wake with web request, but what about background task? Do I need to move the quartz job to a worker dyno?

You should move your job to a worker dyno. See more: https://devcenter.heroku.com/articles/free-dyno-hours

Seems that worker dynos don’t sleep, but… are they consuming dyno hours only while they are being executed (3 mins each hour) or they consume dyno hours while they are idle too (24/7)?

This is not correct. Computing usage is calculated from the wall-clock time and not CPU time - so long as your worker role is running (which it will be) - you will be burning dyno hours.

If verified accounts have 1000 hours / month and the app consumes only 1 web dyno then there is no need to let the app sleep, right? One month should be less than 750 hours using only 1 dyno. Is there any way to keep the app alive?

You are talking about 2 dynos there now, 1 web and 1 worker. With this configuration free tier wouldn't be enough if you wanted to keep them running 24/7 even if you are a verified account.

Upvotes: 2

Related Questions