I have a PHP container, I am getting my media from an S3 bucket but resizing them locally and then the container uses them from local. I don't care about persistence or about sharing between containers, but there is a fair amount of I/O. Do I need an emptydir volume or am I ok just creating the files inside the container... basically I'm asking does a volume do anything apart from adding persistence and shareability.
Generally, working inside a container filesystem will be slower than a localhost volume, as inside a container you have to deal with overlay filesystem overhead.
Use volumes for write-heavy workloads: Volumes provide the best and most predictable performance for write-heavy workloads. This is because they bypass the storage driver and do not incur any of the potential overheads introduced by thin provisioning and copy-on-write. Volumes have other benefits, such as allowing you to share data among containers and persisting your data even if no running container is using them.
https://docs.docker.com/storage/storagedriver/overlayfs-driver/#performance-best-practices.
In practice, of course, it may depend a) on your workloads, b) on what exactly storage backs your volume (is it actually a local disk or, say, some network drive? how fast is it?).
Also note that overlay file systems may lack support for some file operations.
Say, overlay2 does not actually support renaming directories.
https://docs.docker.com/storage/storagedriver/overlayfs-driver/#modifying-files-or-directories.
So, general advice would be to stick with some kind of local volume.
A Persistent Volume is a way to have data persisted even when the container is disposed, e.g. terminated and replaced by a new version.
An EmptyDir volume might work for you, in some configurations it is using the memory of the Pod instead of disk.
What choice you do, depend on your requirements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With