为 MongoDB 调度 MapReduce 作业
这更多的是一个实现问题,但是使用 cron 这样简单的东西来调度 MongoDB 的 mapreduce 这样的任务有什么缺点吗?说需要每小时执行一次,这似乎是一个合适的方法......但我想我只是问因为所有流行的作业排队系统,如 Resque 和其他系统。
我想我的问题更像是, cron 是否提供了足够可靠和可靠的解决方案?想法?
This is more of an implementation question, but are there any shortcomings to using something simple like cron to schedule tasks like mapreduce for MongoDB? Say something needs to be executed every hour, it seems like a suitable way to do this... But I guess I'm just asking because of all the popular job queuing systems out there like Resque and others.
I suppose my question is more like, does cron provide solid and reliable enough solution? Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Cron 已经使用了几十年,相当可靠和稳定;如果您的 cron 不可靠,那么我建议您与操作系统供应商进行严肃的讨论。此外,MongoDB 文档讨论了 cron 作业(例如 google“site:mongodb.org cron”),因此,大概 MongoDB 会出现 cron 作业。
也就是说,如果您已经为另一个调度系统设置了一堆基础设施,那么可能没有理由将 cron 用于 MongoDB 并使用其他东西来执行其他任务。
无论如何,如果您的 cron 作业可能需要足够长的时间才能重叠,并且您一次只希望运行一个,您可能需要分层使用简单的 PID 文件锁定系统:
atexit
处理程序或您的环境支持的任何类似功能)。Cron has been used for decades and is quite reliable and solid; if your cron isn't reliable then I'd suggest that a stern discussion with your OS vendor is in order. Also, the MongoDB documentation talks about cron jobs (google "site:mongodb.org cron" for examples) so, presumably, cron jobs are to be expected with MongoDB.
That said, if you already have a bunch of infrastructure set up for another scheduling system then there's probably no reason to use cron for MongoDB and something else for other tasks.
In any case, you'll probably want to layer on a simple PID file locking system if your cron jobs might take long enough to overlap and you only want one running at a time:
atexit
handler or whatever similar feature your environment supports).