作业调度 - crontab 最好的解决方案?
我正在开发一个基于 Web 的应用程序,该应用程序在很大程度上依赖于作业调度。这些作业将非常短,例如单个 HTTP 请求。然而,它们将会有很多。每天可能会安排数千个以上的工作,但并非全部同时安排。我的第一个倾向是使用 crontab 来安排这些作业,但我不确定这是否是最好的解决方案。
我发现 crontab 主要用于安排工作密集型管理任务,但不适用于非常短的工作。 crontab 适合吗?它能处理如此大量的工作吗?我应该实施自定义解决方案吗?是否有任何服务可以提供更好的解决方案和服务?表现?
非常感谢!
I am in the middle of developing a web-based application that heavily depends on job scheduling. The jobs will be extremely short, such as a single HTTP request. However, there will be lots of them. More than several thousand jobs may be scheduled every single day, but not all at the same time. My first inclination was use to crontab to schedule these jobs, but I am not sure if this is the best solution.
I see crontab mainly being used to schedule work intensive administrative tasks, but not for very short jobs. Is crontab even suitable for that? Can it handle such a large number of jobs? Should I implement a custom solution? Are there any services out there that may provide a better solution & performance?
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这就是我个人网站所用的。当然,cron 能够运行长时间运行的任务,但它绝不应该仅限于此。
That's what I use for my personal website. Sure, cron has the ability to run long-running tasks, but it should by no means be limited to that.
Cron 的分辨率为一分钟;它每分钟只唤醒一次,看看是否应该运行任何东西。如果您需要更高分辨率的东西,您将需要定制解决方案。
另外,如果您在 OS X 上执行此操作,您将使用 launchd 而不是 cron。 (不过 cron 仍然受支持)。
Cron has a resolution of one minute; it only wakes up once per minute to see if anything should be run. If you need something with tighter resolution, you'll need a custom solution.
Also, if you are doing this on OS X you will be using launchd rather than cron. (cron is still supported, though).
我的公司制作了 CloudQuartz (www.thecloudblocks.com),它允许您通过 API 安排作业并在以下情况下获得回调他们该跑了。
我们做到了这一点,以便我们可以在服务器集群上安排作业,这是使用 CRON 或 Windows 调度程序无法实现的。
My company makes CloudQuartz (www.thecloudblocks.com) which allows you to schedule the jobs through an API and get callbacks when they are due to run.
We made it so we can schedule jobs on a cluster of servers that was not possible using CRON or Windows scheduler.