在heroku上发送延迟的电子邮件rails
我的数据库中有一个表,其中包含要发送的电子邮件列表,每封电子邮件都在特定时间(精确到分钟)。
我在heroku上,现在不想花任何东西..有办法做到这一点吗?我想到的唯一方法是在其他地方创建一个守护进程/cron 并使其每分钟调用一个私有 url.. 还有其他想法吗?有什么办法可以有一些后台进程或可以处理这个问题的东西(在 Heroku 上并且无需支付额外的插件费用..)?
谢谢!
I have a table in my database with a list of emails to be sent, each at a specific time (precision down to the minute).
I'm on heroku, and I don't want to spend anything right now.. Is there a way to do this? The only way I thought was to create a deamon/cron somewhere else and make it call a private url every minute.. any other idea? Any way to have some background process or something that can handle this (on Heroku and without paying extra for addons..)?
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Heroku 的免费 cron 插件每天只运行一次,所以它不适合。他们的付费 cron 插件每小时只运行一次,所以它也不适合。在其他地方运行守护进程/cron 是一种很快就会出现问题的黑客行为。这从根本上来说是糟糕的架构。
将 delayed_job 与单个 Heroku Worker 一起使用是有意义的。另外,delayed_job 允许您准确指定每个作业的运行时间,粒度小至 5 秒。是的,执行此操作的费用为 36 美元/月。但它可以让你免于以错误的方式做事。另外,如果您预计大部分时间都不需要 Worker,您可以研究 Heroku 上的自动缩放delayed_job,这样 Worker 仅在您需要时才打开。
Heroku's free cron addon runs only once a day, so it is not suitable. Their paid cron addon runs only once an hour, so it is also not suitable. Running a daemon/cron elsewhere is a hack that will become problematic very quickly. It's fundamentally bad architecture.
Using delayed_job with a single Heroku Worker makes sense. Plus, delayed_job lets you specify exactly when each job should be run, down to a 5-second granularity. Yes, it is $36/mo to do this. But it frees you from doing things the wrong way. Plus, if you expect that you will not need the Worker most of the time, you can look into auto-scaling delayed_job on Heroku so the Worker is only turned on when you need it.
有一大堆免费的在线服务,它们非常乐意按照您设置的时间表请求您的网页。您不需要花费或编写任何代码。只需谷歌:)
There is a whole bunch of free online services that would be more than happy to request your web page on a schedule that you set. You don't need to spend or code anything. Just Google :)