LoginSignup
20
20

More than 5 years have passed since last update.

Heroku free dynoがとうとう24x7じゃなくなったorz(けどクレカ登録すればおk)

Last updated at Posted at 2015-07-29

この記事は古くなりました。

この記事は2016/5/31までの内容です
2016/6/1以降は1アカウント当たり無料で月間550時間使えます。クレジットカード登録をしているとさらに450時間(合計1000時間)使えます。一カ月の延べ時間数は 1 dyno だと最大でも744時間なので、クレジットカード登録をしていれば、以前のように全く時間を気にせず使えます1

Accounts are given a base of 550 hours each month in which your Free dynos can run. In addition to these base hours, accounts which verify with a credit card will receive an additional 450 hours of Free dyno quota.
Usage | Free Dyno Hours | Heroku Dev Center

なお、Heroku から変更が通知されたのは2016/5/18のことでした1

「こんなことがあったのだよ」ということで、以下に記事を残しておきます。


手持ちの Heroku app のうち一部が日本時間2015/7/28に強制的に新しい dyno へ移行されてしまい、6時間強制睡眠モードしかも寝っぱなし状態に入っていましたorz
(追記:2015/8/23頃に移行していなかったものの一部が新しい dyno へ強制移行させられましたorz が、 Heroku からの通知メールが 8/26頃から来なくなり、 app 自体も24x7稼働しています 。なぜ??)

以下は推測が含まれます。

新しいdynoへ強制移行されたapp

  • 一日に数回しか稼働しないスクリプトを走らせている。スクリプト内部で時刻を見て、特定時刻に動く、というようなもの。

(8/23頃に移行された app もやはり比較的稼働頻度が低いものでした)

新しいdynoへ強制移行されていないapp

  • スクリプト内部で時刻を見て、特定時刻に動く、というようなものだが、強制移行された app に比べると格段に稼働頻度が高い。

強制睡眠される log(一例)

Jul 28 12:33:35 myapp heroku/api:  Scale to bot=0 by cedar+cedar-enforcer-eu-west-1-a@heroku.com 
Jul 28 12:33:35 myapp heroku/api:  Scale to console=0 by cedar+cedar-enforcer-eu-west-1-a@heroku.com 
Jul 28 12:33:35 myapp heroku/api:  Scale to rake=0 by cedar+cedar-enforcer-eu-west-1-a@heroku.com 
Jul 28 12:33:35 myapp heroku/bot.1:  State changed from up to down 
Jul 28 12:33:38 myapp heroku/bot.1:  Stopping all processes with SIGTERM 
Jul 28 12:33:40 myapp heroku/bot.1:  Process exited with status 143 

なお bot というのは私が勝手に設定した process type 名です。普通は web とか console とか rake だけかと。

強制移行されると?

こちら(外側)から対応しない限り、 app は寝たままになりますorz
一度起こすと、その時点から18時間起きて、6時間寝て…を繰り返すようです。

今後も24x7にするには?

  • 有料の Hobby dyno ($7/月)に変更
  • AWS なり何なり別のPaaSに引っ越す( Hobby dyno よりは安いよう運用出来るはず)

ひとりごと

Heroku | New Dyno Types and Pricing Public Beta
を見ると

Plan for General Availability, Grandfathering and Migration

The public beta is currently scheduled to run throughout May. The new dynos are scheduled to replace traditional dynos for all new applications in June, 2015.
Paid applications running on traditional dynos on the “general availability” date will be able to migrate between new and traditional dynos at their convenience until the end of January, 2016. At this time, we are scheduled to sunset traditional dynos and migrate all remaining applications.
Applications running a single 1X dyno that don’t accumulate any other dyno charges will be migrated gradually to the new free dynos beginning on July 1.

とあったので、対策は来年からでいいと思っていました。
そうじゃなかった!

追記:Herokuから通知メールが来た

Your Heroku app myapp_name on free dynos needs to recharge

heroku
Hi,
Your app myapp_name is running on free dynos and has been active for more than 18 of the last 24 hours. Normally, your app would recharge for the next 6 hours. Don't worry, your app is still running. Right now we're simply sending notifications. Beginning August 15th, your application will receive up to three warnings per month after which it will need to recharge.

Why are you receiving this and what can you do?

  • Your app is becoming more popular. Upgrade your app to Hobby dynos for $7 per dyno per month so it never sleeps and users can access it 24×7.
  • A monitoring service could unintentionally be keeping your app awake for more than 18 hours a day. Run heroku logs -t to view your app's logs to see if this is the case and remove Pingdom, New Relic or other availability monitoring services that are not required for a free development app.
  • Your application may be receiving traffic from some other automated source. In order to sync up your app's sleep cycle with your own, scale it down before going to bed. In the morning, turn your app back on.
  • Your application may not have a web process at all. Once worker-only apps are started, they run for 18 hours and then recharge for 6 hours. After this your dynos will be started again. You can avoid this by upgrading to a hobby dyno, or by manually scaling down your application for six hours at a time that is convenient for you.

Dyno sleeping lets us provide you and millions of other users with a free tier for experimenting, hacking on personal projects and even low traffic apps that don't require 24×7 access.
We're here to help and would love hear from you or answer any questions at help.heroku.com or pricing-feedback@heroku.com!
Happy coding, Heroku

ですって。
ちなみにこのメールは毎日来ます >_<

対策


  1. ただし複数の app を使いたい場合には注意しましょう。大事なポイントは app の数量ではなく1アカウント当たりで使える時間が決められるということ。 

20
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
20