If you have a high-traffic website backed by multiple Drupal instances, you may want to have a dedicated file server that hosts sites/default/files, and somehow share that between all those Drupal instances. One approach that's commonly mentioned is to simply use NFS among all those Drupal instances to have their local sites/default/files point to that dedicated file server.

You could then set that file server to be accessible at files.yoursite.com and have Varnish cache the media getting served from it so the file server isn't getting too much load from reads (only writes, coming from the Drupal instances).

Conceptually this is very simple, and very simple to set up in practice. But is this unsafe to do when all those Drupal instances are making writes to the files directory at the same time, or does Drupal somehow mitigate this? There's a detailed description of how NFS is considered harmful at http://www.time-travellers.org/shane/papers/NFS_considered_harmful.html. It describes problems related to locking and more.

For a high-traffic media site with many Drupal instances all modifying the files directory all the time, could this lead to inconsistencies, corruption, or other problems that could eventually arise? Does it become more problematic as the number of Drupal instances increases (e.g. 5, 10, 20 or more NFS clients)?

With image styles, wouldn't the problem become even more likely to appear? For example, let's suppose 2 different requests go to 2 Drupal instances, both requesting the 'mobile' image style of a particular image at the exact same time, and that image style hasn't been created yet. Both of these would then want to write out that styled image at the exact same time, how would NFS handle this?

How are sites with multiple Drupal servers serving files? I know there's options like Amazon S3 and there's good Drupal support for that, but if you'd rather host the files yourself what options are there?

I see there's no way to upload files from Drupal instances directly to a central server using SFTP or SCP or anything like that. There is the CDN module https://drupal.org/project/cdn but that requires installing FileConveyor which is some custom application on all the Drupal instances and then there's some minor delay in syncing to the central server. This is an undesirable solution, when what you'd really want is a way for file uploads to go directly to the central file server (NFS, SFTP, etc).

  • Interesting question, but I fear it's going to eventually be closed as too broad/slightly off-topic as you're really asking how NFS works under high load, it's not actually a Drupal issue. If you have a high-performance Symfony app running on the same technology, for example, the answer can't really change all that much - NFS is what it is. If you can break all of this down into single, individual questions, that would be much more useful for the site, and would help you get better, more specific answers. Just a thought – Clive Mar 14 '14 at 11:35
  • I think this can be salvaged with a rewrite to give it focus. There are way better solutions that NFS for handling this situation, but I don't have personal experience using them with Drupal. – mpdonadio Mar 14 '14 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.