0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

railsでサーバーサイドキャッシュ使うときに気をつけること

Posted at

要約

  • rails + elasticbeanstalk環境でデプロイ時にたまにErrno::ENOSPC: No space left on deviceになる
  • diskはまだ空いている
  • 結局、inodeが枯渇していた
  • railsでキャッシュを使っていて、:file_storeにしているとファイル数が多くなりすぎる

現象

  • デプロイ時にErrno::ENOSPC: No space left on deviceになる
eb deploy xxx
...
rake aborted!
Errno::ENOSPC: No space left on device @ dir_s_mkdir - /var/app/ondeck/tmp/cache/assets
/opt/rubies/ruby-2.5.0/bin/bundle:23:in `load'
/opt/rubies/ruby-2.5.0/bin/bundle:23:in `<main>'
Tasks: TOP => assets:precompile
  • disk容量はまだあるけど、inodeが枯渇していた
> df -T -i
ファイルシス   タイプ   Iノード  I使用   I残り I使用% マウント位置
devtmpfs       devtmpfs 2052009    452 2051557     1% /dev
tmpfs          tmpfs    2054250      1 2054249     1% /dev/shm
/dev/xxxxx     ext4      524288 524286       2   100% /

  • 各ディレクトリのinode数を見てみると、railsプロジェクト直下のtmpディレクトリのinodeが異様に多かった
> for dir in `find . -maxdepth 1 -type d`; do echo `find "${dir}" -true | wc -l` "${dir}"; done | sort -nr
210363 .
163091 ./tmp
43890 ./node_modules
1486 ./app
1266 ./public
261 ./spec
235 ./db
74 ./config
...
  • tmpの中身を見てみると、railsの(サーバーサイド)キャッシュのファイルだった。ファイルストアにしていた

  • キャッシュごとにファイルが作成されるので、運用していくと多くなりすぎて、inodeが足りなくなっていた

  • キャッシュストアをmem_cache_storeにして解決

config.cache_store = :mem_cache_store, url, {namespace: "xxx"}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?