单个测功机如何消耗数小时?

How does a single dyno consume hours?

dynos 如何消耗时间?

The documentation 说:

Every Heroku account is allocated a pool of free dyno hours. An app actively consumes free dyno hours if the app is set to use free dynos and any of the following are true:

  • It has a web dyno that is receiving traffic (i.e., not sleeping)
  • It has a worker dyno running
  • It has a one-off dyno running. For example, one started via the CLI or Scheduler.

如果你只有一个测功机,你一个月应该不能超过 744 小时(24 小时/天 × 一个月最多 31 天)。但是,如果您还使用 worker 或一次性工具(例如通过 Heroku Scheduler),则可以。

当您的空闲测功机 sleeps after 30 minutes of inactivity 下一个请求将需要更长的时间才能收到响应。这是因为 Heroku 需要唤醒你的测功机。

是的,您可以托管 JSON 文件以供任意 HTTP 客户端请求。但是,您应该注意 Heroku's filesystem is ephemeral. Any changes you make to the filesystem (like saving a file) will be lost whenever your dyno restarts. This happens frequently(每天至少一次)。

更好的解决方案是使用客户端-服务器数据库来存储您的数据并根据该数据动态构建 JSON 响应。 Heroku Postgres is a simple option with a free starter tier, but there are other options 也是。