Move the Scrivito SDK cache to /srv/www
Using the default settings, the Scrivito SDK stores caches of CMS objects as files in the #{Rails.root}/tmp/scrivito_cache
directory. These files are not very large but there are lots of them. The OpsWorks deployment recipe runs chown -R
multiple times over the directory containing all your apps (including the previous app releases). This process takes longer from deployment to deployment since the amount of cache files adds up on every new release. Deployment duration can then amount to minutes or even hours.
In order to solve this issue, cache files should be stored completely outside the app directory, for example in /srv/www
:
Scrivito.configure do |config|
# ...
config.cache_path = "/srv/www/scrivito_cache"
end
By doing this, the cache directory is no longer rotated on deployments. Please ensure that the ownership of and the permissions for the cache directory have been properly set. Also, for best caching behaviour, we recommend to not place your Scrivito cache onto a file system for which noatime
has been set.
It is important to collect the garbage from your cache regularly using rake scrivito:cache:gc
to prevent your file system from running out of inodes. For scheduling, we recommend to use whenever
:
# config/schedule.rb
every :
day do
rake 'scrivito:cache:gc'
end
This installs a crontab entry that runs the garbage collector rake task once a day.
Speed up rake assets:precompile
Install turbo-sprockets-rails3. It speeds up rake assets:precompile
by only recompiling changed files.
Prevent the repo from being cloned on every deployment
The OpsWorks deployment recipe uses a cached copy of the repo which it updates and which it copies into the new release directory. Unfortunately, it deletes the repo prior to updating it, resulting in a fresh clone. But since the cached repo is never changed, it is safe to reuse it with all deployments.
Append the following configuration to the stack settings:
"deploy": {
"YOUR-APP-NAME": {
"delete_cached_copy": false
}
},
By applying all these improvements, a typical deployment should take about a minute.