自从我升级到Rails 6并开始使用webpacker以来,我在启动时的内存消耗(使用heroku(一直是灾难性的。 它的峰值约为1200mb,然后下降并稳定地悬挂在约512mb。 我已经尝试过网络打包器延迟加载和块拆分,但无济于事。 这是我在部署新版本(并重新启动dynos(后第一次获取简单页面时的日志:
2019-11-29T07:28:35+00:00 app[heroku-redis]: source=CACHE_REDIS addon=redis-polished-49634 sample#active-connections=1 sample#load-avg-1m=0.11 sample#load-avg-5m=0.11 sample#load-avg-15m=0.135 sample#read-iops=0 sample#write-iops=0 sample#memory-total=15664216kB sample#memory-free=12118360kB sample#memory-cached=942820kB sample#memory-redis=313912bytes sample#hit-rate=1 sample#evicted-keys=0
2019-11-29T07:29:14+00:00 app[heroku-postgres]: source=HEROKU_POSTGRESQL_RED addon=postgresql-metric-77832 sample#current_transaction=79756157 sample#db_size=134809762951bytes sample#tables=38 sample#active-connections=7 sample#waiting-connections=0 sample#index-cache-hit-rate=0.97867 sample#table-cache-hit-rate=0.93505 sample#load-avg-1m=0 sample#load-avg-5m=0 sample#load-avg-15m=0 sample#read-iops=0 sample#write-iops=0.083333 sample#tmp-disk-used=2376790016 sample#tmp-disk-available=70602002432 sample#memory-total=4044932kB sample#memory-free=153736kB sample#memory-cached=3543852kB sample#memory-postgres=21172kB
2019-11-29T07:29:49.838066+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/academy/lessons" host=app.makerspro.io request_id=75fae01f-ebe6-49f0-9635-ac92f64430da fwd="77.137.95.95" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 protocol=https
2019-11-29T07:29:53.946177+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=app.makerspro.io request_id=b2d726c1-7742-4556-9302-b3e88f699adb fwd="77.137.95.95" dyno=web.1 connect=0ms service=11ms status=200 bytes=207 protocol=https
有什么想法吗?或者至少没有超时请求?
在webpacker.yml中为生产设置compile: false
。
compile: true
意味着:在请求周期中运行 webpack 编译,这是您很可能不想在生产中做的事情,因为您将预编译您的资产。