alexleonard's avatar

Local filesystem on load balanced servers

I have load balancing set up to split a Laravel site between multiple servers and have been running into issues using local file storage.

For compliance reasons we can't use a remote Flysystem adapter (eg AWS), and I haven't worked out the best way to handle user uploads (eg image uploaded to Server A, but not available Server B). At the moment we just have a scheduled rsync to keep Server A and B public disks in sync, but it's not instant.

I believe we could set up some form of folder watching to trigger sync between the servers but I was wondering is there an easy way to set up the local flysystem adapter/public disk to actually store files on a single server shared between load balanced web server? Thus Server Z would be just Laravel 'local' storage, and Server A and B would read/write to Server Z?

DevOps is not entirely my forte... ;)

0 likes
5 replies
ohffs's avatar
ohffs
Best Answer
Level 50

You could make 'server Z' export the filesystem to A & B using NFS? The config is pretty easy - but annoyingly slightly different between Linux distro's :-/

1 like
ohffs's avatar

Yep - that's the kind of thing :-) It's pretty easy to set up - just a bit of fiddling about depending if you're wanting to use (or the OS defaults to) NFSv4 rather than NFSv3 :-)

ohffs's avatar

No worries - glad to help :-)

Please or to participate in this conversation.