我與Heroku一起在雪松堆疊上,併爲大約30,000張不同的照片重新生成了10張縮略圖。在Heroku上運行多個控制檯進程會減慢其他進程嗎?
我啓動了單獨的控制檯進程,因此每個人都可以處理1000張照片,這樣我就不會遇到超時問題(我之前遇到過問題),並且可以同時生成新的縮略圖(這會理論上使整個過程變得更快)。
我已經掌握了大約12個控制檯進程,並且每個進程都在運行Paperclip的縮略圖再生。
似乎隨着我添加更多流程,其他流程開始放慢速度。這是真的還是我只是想象中的事情?有什麼方法可以確保他們全速跑?
這裏的輸出heroku ps
:
Process State Command
------- ---------- ---------------------------------
run.14 up for 35m bundle exec rails console
run.16 up for 31m bundle exec rails console
run.18 up for 28m bundle exec rails console
run.19 up for 27m bundle exec rails console
run.20 up for 21m bundle exec rails console
run.21 up for 20m bundle exec rails console
run.22 up for 18m bundle exec rails console
run.23 up for 8m bundle exec rails console
run.24 up for 8m bundle exec rails console
run.25 up for 6m bundle exec rails console
run.26 up for 5m bundle exec rails console
web.1 up for 3h bundle exec rails server -p $PORT
我正在做部分獨立的進程,以便我可以同時生成新的縮略圖...意思是如果我有12個進程,我一次可以生成12個進程,而不是每次生成12個進程。所以這就是爲什麼我沒有執行單個rake任務或find_in_batches。 – Shpigford 2012-03-14 01:39:15
您也可以使用此rake任務爲每個對象創建一個延遲的Job。如果您使用heroku,例如在工作時間內將工人人數改爲最大值。它會很快;) – Antoine 2012-03-14 17:13:29