Rails 并发后台进程

发布于 2024-12-27 17:27:20 字数 270 浏览 0 评论 0原文

我需要在几天内访问多个 API 并从中提取数据。这是流数据,因此该进程将一直运行。每个进程都会提取数据并将其插入到单独的谷歌融合表中。

因为我想在后台运行这个进程并忘记它们,所以只能监视它们是否失败并且不重新启动。

我查看了 Delayed Job、Resque、Beanstalk 等,我的问题是这些进程是否可以同时运行。我不想对进程进行排队,只是在后台运行它们。

我也看了 Spawn,但不完全明白它是如何工作的。

那么我可以选择哪些选项,有人有任何建议吗?

I need to access and pull data from a number of API's over the the course of the a number of days. This is streaming data so the process will be running all the time. Each process will pulling in data and inserting it into a separate google fusion table.

As I want to run this processes in the background and forget about them, just being able to monitor is they fail and don't restart.

I have looked at Delayed Job, Resque, Beanstalk etc and my question is can these run processes concurrently. I don't want to queue processes just run them in the background.

I looked at Spawn as well, but didn't completely understand how it worked.

So what options are available to me, does anybody does have any recommendations?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天赋异禀 2025-01-03 17:27:20

我会使用 whenever gem 来安排 cron 作业来提取数据。

every 2.hours do 
  YourApi.do_whatever
  SecondApi.do_the_thing
end

I would use the whenever gem to schedule cron jobs to pull data.

every 2.hours do 
  YourApi.do_whatever
  SecondApi.do_the_thing
end
只为一人 2025-01-03 17:27:20

也许自定义后台守护进程更适合您,请查看 daemon_generator。但请注意,如果您想同时执行某些操作,则可能需要做一些工作,但仅串行处理操作应该很容易。

Maybe a custom background daemon is a better fit you, take a look at daemon_generator. But note that you probably have to do some work if you want to do things concurrently but just processing things in serial should be quite easy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文