簡體   English   中英

heroku獨角獸超時在下載文件時不起作用

[英]heroku unicorn timeout doesn't work when downloading files

我正在與Unicorn一起在Heroku上運行Rails 4應用程序。

這個應用程式會建立一個相當大的xls檔案

為了給它足夠的時間,我通過config / unicorn.rb增加了超時時間:

超時240

當我運行生成xls文件的頁面時,此方法不起作用,3001ms之后發生超時。

為什么?

這是我的日志:

2014-04-29T13:43:27.323190+00:00 app[web.1]: I, [2014-04-29T13:43:27.323084 #8]  INFO -- : Started GET "/live_sales.xls?action=index&controller=live_sales" for 81.244.45.218 at 2014-04-29 13:43:27 +0000
2014-04-29T13:43:27.340252+00:00 app[web.1]: D, [2014-04-29T13:43:27.340190 #8] DEBUG -- : logged in? true
2014-04-29T13:43:27.339294+00:00 app[web.1]: I, [2014-04-29T13:43:27.339181 #8]  INFO -- : Processing by LiveSalesController#index as XLS
2014-04-29T13:43:27.345465+00:00 app[web.1]: D, [2014-04-29T13:43:27.345383 #8] DEBUG -- :   ItemRef Load (3.1ms)  SELECT gamme FROM "item_refs" WHERE (gamme is not null and gamme <> '') GROUP BY gamme
2014-04-29T13:43:28.577687+00:00 app[web.1]: D, [2014-04-29T13:43:28.577526 #8] DEBUG -- :   LiveSale Load (1210.0ms)  SELECT invoice_date, item_refs.item_brand, item_refs.item_label, item_refs.gamme, item_refs.sub_gamme, item_refs.id, item_refs.item_reference, item_refs.date_published, item_refs.date_unpublished, item_refs.price_purchase, item_refs.current_stock, item_refs.item_published,
2014-04-29T13:43:28.577694+00:00 app[web.1]:  sum(price_purchase * current_stock) as stock_value,sum(quantity) as quantity,
2014-04-29T13:43:28.577697+00:00 app[web.1]:  sum(price_purchase * quantity) as total_purchase FROM "live_sales" left join item_refs on item_refs.id = live_sales.item_ref_id and item_refs.item_published is true and item_refs.disabled is false WHERE ((invoice_date between '2014-03-29 13:43:27 +0000' and '2014-04-29 13:43:27 +0000')) GROUP BY invoice_date, item_refs.item_brand, item_refs.item_label, item_refs.gamme, item_refs.sub_gamme, item_refs.id, item_refs.item_reference, item_refs.date_published, item_refs.date_unpublished, item_refs.price_purchase, item_refs.current_stock, item_refs.item_published ORDER BY invoice_date asc, 
2014-04-29T13:43:57.331088+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path=/live_sales.xls?action=index&controller=live_sales host=azzanalytics.herokuapp.com request_id=6e67b74e-3db8-4853-b5c6-c1f884eaa31e fwd="81.244.45.218" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0

謝謝!

建議是:使用后台進程!

沒有其他辦法了! 在網絡應用中,最好的做法是盡快釋放客戶端,因為這樣可以釋放資源。 當您在heroku上僅運行一個dyno且您有多個請求時,它們將因您的超時而被阻止,並且沒有用戶能夠訪問您的頁面。 如果您的流程如此漫長,您很容易拒絕服務案例。 無論您在瘦服務器上覆蓋它,heroku都會在30秒后超時

如果您由於成本而不想執行后台處理,請查看免費增值服務: https : //github.com/phoet/freemiumdelay_job

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM