告诉 Merb 不要超时
在发布与 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许不同的方法会产生更好的结果 - 与其解决超时问题,不如通过推迟任务的执行来最大化吞吐量?
长时间运行任务的一些方法是使用 run_later 或 exec 单独的工作进程来完成任务...
在这两种情况下,您都应该返回 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 ...
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.