告诉 Merb 不要超时

发布于 2024-08-20 13:14:35 字数 236 浏览 2 评论 0原文

在发布与 nginx 相关的问题后,我进一步进行了调查:问题是,merb 框架在大约 30 秒后超时。如果我告诉底层 nginx 服务器不要超时,merb 就会超时,但我找不到一种方法来告诉它不要超时;我需要执行最多需要几分钟的请求。

有什么提示吗?多谢。

-- 更新 --

似乎 merb 后面的 mongrel 导致了错误。有什么方法可以改变与 merb 一起运行的 mongrel-timeout 吗?

after posting a question related to nginx, I'm a bit further with my investigations: The problem is, that the merb framework timeouts after about 30 seconds. If i tell the underlying nginx-server not to timeout, merb does, and I can't find a way to tell it not to; I need to do requests that take up to some minutes.

Any hints? Thanks a lot.

-- UPDATE --

Seems that mongrel behind merb is causing the error. Is there any way to change the mongrel-timeout running with merb?

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

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

发布评论

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

评论(1

白云悠悠 2024-08-27 13:14:35

也许不同的方法会产生更好的结果 - 与其解决超时问题,不如通过推迟任务的执行来最大化吞吐量?

长时间运行任务的一些方法是使用 run_laterexec 单独的工作进程来完成任务...

def run_in_background(r)
    Thread.new do
        response = IO.popen(r) do |f|
            f.read
        end
    end
end

在这两种情况下,您都应该返回 202 (已接受) 作为状态代码和调用应用程序可以获取状态更新的 URL。

我使用这种方法来处理导致后台批处理执行的请求。每个都将其开始时间、进度和完成时间写入数据库(您可以轻松地使用文件)。当调用 URL 时,我从数据库中获取进度并将其提供回调用进程。

Perhaps a different approach would yield better results - rather than workaround the timeouts, how about maximizing throughput by deferring the execution of the task?

Some approaches for long-running tasks are to either use run_later or exec a separate worker process to complete the task ...

def run_in_background(r)
    Thread.new do
        response = IO.popen(r) do |f|
            f.read
        end
    end
end

In both cases you should return 202 (Accepted) as the status code and a URL where the calling application can get status updates.

I use this approach to handle requests which cause background batch processes to execute. Each writes it's start-time, progress and completion-time to a database (you could easily use a file). When the URL is invoked, I fetch the progress from the database and provide that back to the calling process.

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