Volumes
Understanding Volumes on Klutch.sh
Volumes on Klutch.sh provide persistent storage for your applications and services. Unlike ephemeral storage, which is lost when your app is redeployed or restarted, Volumes retain data across deployments, restarts, and even when scaling your app. This is essential for use cases like file uploads, user-generated content, logs, and databases.
What is a Volume?
A Volume is a persistent storage resource that you can attach (mount) to one or more services on Klutch.sh. Data stored in a Volume is not deleted when your app is redeployed or restarted, making it ideal for storing files, database data, or any information that must persist.
Key Features
- Persistence: Data in Volumes survives app restarts, redeployments, and scaling events.
- Isolation: Each Volume is isolated to your account and can be mounted to one app at a time.
- Flexibility: Use Volumes for uploads, logs, databases, or any persistent data.
- Backups: (Coming soon) You can back up and restore Volumes for disaster recovery.
Common Use Cases
- Storing user uploads (images, documents, etc.)
- Persistent database storage (Postgres, MySQL, MongoDB, etc.)
- Application logs
- Caching and temporary files
Creating a Volume
- During app creation, click on the “Add Volume” button.
- Enter the mount path and select a size.
- Click Create. Your Volume will be provisioned and available for mounting.
- The volume(s) will be created and mounted during the deployment of your app
Mounting a Volume to a Service
- In your app or service settings, find the Volumes section.
- Click Attach Volume and select the Volume you created.
- Specify the mount path (e.g.,
/data
,/var/lib/postgresql/data
). This is where your app will access the Volume’s files. - Save your changes and redeploy your app if required.
Example: Using a Volume for File Uploads
Suppose you have a Node.js app that saves uploaded files to /uploads
. You can:
- Create a Volume named
uploads
. - Attach it to your app at the mount path
/uploads
. - Your app can now read/write files to
/uploads
, and the data will persist across deployments.
Example: Using a Volume for a Database
For a Postgres service, mount a Volume at /var/lib/postgresql/data
to ensure your database files are persistent.
Managing Volumes
- Resize: Increase the size of a Volume from the dashboard if you need more space.
- Delete: Permanently remove a Volume and all its data (be careful—this cannot be undone).
- Backups: (Coming soon) Schedule or trigger backups from the dashboard.
Best Practices
- Always use Volumes for any data that must persist across deployments.
- Regularly back up important Volumes.
- Avoid storing sensitive credentials in Volumes; use environment variables or Klutch.sh secrets instead.
- Monitor your Volume usage and resize as needed.
Limitations
- Volumes are only accessible to services in the same region.
- You can’t add the same volume to multiple apps.
- You are limited to 15 volumes on an app at a time.
- Performance may vary based on the underlying storage and usage patterns.
- Deleting a Volume is irreversible.