Out of memory errors during deployment
When you are deploying your stack (particularly in a non-development environment) asset pipeline compilation takes place during the deployment process.
If your server does not have sufficient memory available to perform the asset pipeline compilation you may receive one of the following errors:
- “Cannot allocate memory”
- “Out of memory”
These are more likely on servers with low memory availability. It is possible that your initial deployment succeeds, and subsequent deployments fail, and this is due to the fact that after your initial deployment you have additional memory usage of your web server. You can also use a manifest file to specify a value in MB for reserved_server_memory - this may help with Passenger-based stacks by preventing Cloud 66 from allowing passenger to allocate additional processes.
Irregular vendor issues in memory allocation (like greedy neighbours on the same physical instance) could also cause this issue, though that very vendor/infrastructure specific.
- Compile the assets on your own box and disable asset pipeline compilation on the stack going forward.
- Configure your code not to use asset pipeline pre-compilation and use live compilation (on-demand). More information on Asset Pipeline compilation.
- Resize your box to a bigger box either via a new stack, or vertical scaling if available.
- Setup swap files on your server. This is automatically done for 512MB and 1GB DigitalOcean servers.
- Manually reduce memory usage on your server before deployments (ie. manually stop your webserver).
- Reduce memory usage on your server by limiting Passenger memory usage (using a manifest file to specify a value for reserved_server_memory).