File Storage

CloudCaptain instances are strictly ephemeral. Not only are they completely destroyed once the are terminated, but their file system also lives exclusively in RAM.

Persistent files

Apps that need to store files durably and persistently should do so off-instance.

S3

We recommend using an S3 bucket for this. Not only is it cost effective, but you can also serve large files directly to clients either via unsecured buckets or pre-signed URLs.

EFS

Alternatively you can also consider mounting an Elastic File System. This comes with trade-offs though. The clear advantage is that from an application's perspective this is just a regular NFS directory. However not only is this service not currently available in all all AWS regions, but you also lose the advantage of being able to offload large file up- and downloads as you can with S3.

You can mount an elastic file system, by adding these statements to the start of your main method:

new File("/efs").mkdir();
Runtime.getRuntime().exec("mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 <your-efs-id>.efs.<your-aws-region>.amazonaws.com:/ /efs").waitFor();

The elastic file system is now mounted at /efs and is ready for you to use.

Temporary files

If your application needs to temporarily store files it can afford to lose should the instance die, then the /tmp directory in your instance is the perfect place for this. It is a separate fully encrypted filesystem that resides on disk (unlike the other directories in your CloudCaptain instance which reside in RAM).

With the -tmp=... parameter CloudCaptain can automatically provision between 0 and 16384 GB of space, with 1 GB being the default.

Every application (and its JVM) are automatically configured by CloudCaptain to use the /tmp directory for creating temporary files. There is no manual configuration necessary on your part.

Tip: Check out our blog post about temporary files support for more info and examples.

Debugging