Shared network storage now available

Larry Garfield
Documentation Director
17 Apr 2019

Since Platform.sh launched support for worker instances last year, the number-one feature request has been a way to share file mounts between the web application and its workers. We’re happy to announce that it can now be done!

Cool! How?

The solution is the new network-storage service container, which runs like any other service in your cluster and offers up mount points instead of network ports. You can add one to your cluster through services.yaml just this easily:

files:
    type: network-storage:1.0
    disk: 2048

That creates a new network service named files (you can name it anything), with a disk capacity of 2 GB.

Now, in .platform.app.yaml, you can declare file mounts that point at that network service rather than at the local disk.

mounts:
    'web/uploads':
        source: service
        service: files
        source_path: uploads

That creates a mount point in the web/uploads directory, which points at the files service. The source_path is the subdirectory in the service. If you have multiple applications mount the same source_path on the same service, poof, they have access to the same files over the network.

It works for workers

That includes workers, too. A local mount source creates a container-specific mount on each app container—one on the web instance and one on the worker instance. A service mount source, however, inherits to both instances and points to the same directory on the storage service. No extra work needed.

It’s also possible to define custom mounts for the workers and web instance separately, which can be local or network mounts. And you can mix and match local and service mounts however you need. See the Network Storage documentation for more details.