{"id":3866,"date":"2025-12-31T22:54:33","date_gmt":"2025-12-31T19:54:33","guid":{"rendered":"https:\/\/www.dchost.com\/blog\/sharing-files-between-multiple-web-servers-nfs-vs-sshfs-vs-rsync\/"},"modified":"2026-11-04T23:42:18","modified_gmt":"2026-11-04T20:42:18","slug":"nfs-sshfs-rsync-file-sharing","status":"publish","type":"post","link":"https:\/\/www.dchost.com\/blog\/en\/nfs-sshfs-rsync-file-sharing\/","title":{"rendered":"NFS vs SSHFS vs rsync for Multi-Server File Sharing"},"content":{"rendered":"<div class=\"dchost-blog-content-wrapper\"><p>When a web application moves to multiple servers, each node must find the correct code, uploads and application state. Without a plan, an image can exist on one node but return a missing-file error on another, or two writers can overwrite each other\u2019s work. <strong>NFS<\/strong> provides a shared network filesystem, <strong>SSHFS<\/strong> exposes remote files through SFTP over SSH, and <strong>rsync<\/strong> copies files into separate targets. This guide compares their permissions, consistency and failure behavior, then applies them to WordPress, Laravel, code releases and backups. These approaches can be considered for deployments using <a href=\"https:\/\/www.dchost.com\/vps\">VPS<\/a>, dedicated or colocation servers; the selected service must support the required access and administration.<\/p>\n<div id=\"toc_container\" role=\"navigation\" aria-label=\"Table of Contents\" data-nosnippet class=\"toc_transparent no_bullets toc_numbered toc_title_center\"><p class=\"toc_title\">\u0130\u00e7indekiler<\/p><ul class=\"toc_list\"><li><a href=\"#What_Problem_Are_We_Really_Solving\"><span class=\"toc_number toc_depth_1\">1.<\/span> What Problem Are We Really Solving?<\/a><\/li><li><a href=\"#Quick_Overview_NFS_SSHFS_and_rsync\"><span class=\"toc_number toc_depth_1\">2.<\/span> Quick Overview: NFS, SSHFS and rsync<\/a><ul><li><a href=\"#NFS_Network_File_System\"><span class=\"toc_number toc_depth_2\">2.1.<\/span> NFS (Network File System)<\/a><\/li><li><a href=\"#SSHFS\"><span class=\"toc_number toc_depth_2\">2.2.<\/span> SSHFS<\/a><\/li><li><a href=\"#rsync\"><span class=\"toc_number toc_depth_2\">2.3.<\/span> rsync<\/a><\/li><\/ul><\/li><li><a href=\"#NFS_Central_Shared_Storage_for_Multiple_Web_Servers\"><span class=\"toc_number toc_depth_1\">3.<\/span> NFS: Central Shared Storage for Multiple Web Servers<\/a><ul><li><a href=\"#How_NFS_Works_in_a_web_hosting_Setup\"><span class=\"toc_number toc_depth_2\">3.1.<\/span> How NFS Works in a web hosting Setup<\/a><\/li><li><a href=\"#Pros_of_NFS_for_Web_Clusters\"><span class=\"toc_number toc_depth_2\">3.2.<\/span> Pros of NFS for Web Clusters<\/a><\/li><li><a href=\"#Cons_and_Pitfalls_of_NFS\"><span class=\"toc_number toc_depth_2\">3.3.<\/span> Cons and Pitfalls of NFS<\/a><\/li><li><a href=\"#When_NFS_Makes_Sense\"><span class=\"toc_number toc_depth_2\">3.4.<\/span> When NFS Makes Sense<\/a><\/li><\/ul><\/li><li><a href=\"#SSHFS_Convenient_Access_Through_SSH\"><span class=\"toc_number toc_depth_1\">4.<\/span> SSHFS: Convenient Access Through SSH<\/a><ul><li><a href=\"#How_SSHFS_Works\"><span class=\"toc_number toc_depth_2\">4.1.<\/span> How SSHFS Works<\/a><\/li><li><a href=\"#Advantages_of_SSHFS\"><span class=\"toc_number toc_depth_2\">4.2.<\/span> Advantages of SSHFS<\/a><\/li><li><a href=\"#Limitations_and_Risks_of_SSHFS_in_Web_Hosting\"><span class=\"toc_number toc_depth_2\">4.3.<\/span> Limitations and Risks of SSHFS in Web Hosting<\/a><\/li><li><a href=\"#When_SSHFS_Is_and_Is_Not_a_Good_Idea\"><span class=\"toc_number toc_depth_2\">4.4.<\/span> When SSHFS Is (and Is Not) a Good Idea<\/a><\/li><\/ul><\/li><li><a href=\"#rsync_Efficient_File_Synchronization_Not_Shared_Storage\"><span class=\"toc_number toc_depth_1\">5.<\/span> rsync: Efficient File Synchronization, Not Shared Storage<\/a><ul><li><a href=\"#How_rsync_Fits_into_Multi-Server_Architectures\"><span class=\"toc_number toc_depth_2\">5.1.<\/span> How rsync Fits into Multi-Server Architectures<\/a><\/li><li><a href=\"#Pros_of_rsync\"><span class=\"toc_number toc_depth_2\">5.2.<\/span> Pros of rsync<\/a><\/li><li><a href=\"#Cons_and_Design_Gotchas_with_rsync\"><span class=\"toc_number toc_depth_2\">5.3.<\/span> Cons and Design Gotchas with rsync<\/a><\/li><li><a href=\"#rsync_for_Code_Deployments_and_Blue-Green_Releases\"><span class=\"toc_number toc_depth_2\">5.4.<\/span> rsync for Code Deployments and Blue-Green Releases<\/a><\/li><li><a href=\"#rsync_for_Upload_Replication\"><span class=\"toc_number toc_depth_2\">5.5.<\/span> rsync for Upload Replication<\/a><\/li><\/ul><\/li><li><a href=\"#Designing_a_Shared_Files_Strategy_for_Your_Web_Cluster\"><span class=\"toc_number toc_depth_1\">6.<\/span> Designing a Shared Files Strategy for Your Web Cluster<\/a><ul><li><a href=\"#Data-Type-Driven_Choices\"><span class=\"toc_number toc_depth_2\">6.1.<\/span> Data-Type-Driven Choices<\/a><\/li><li><a href=\"#Example_Architecture_Small_WordPress_Cluster\"><span class=\"toc_number toc_depth_2\">6.2.<\/span> Example Architecture: Small WordPress Cluster<\/a><\/li><li><a href=\"#Example_Architecture_Static_Asset_Build_rsync_Fan-Out\"><span class=\"toc_number toc_depth_2\">6.3.<\/span> Example Architecture: Static Asset Build + rsync Fan-Out<\/a><\/li><\/ul><\/li><li><a href=\"#Operational_Considerations_Performance_Security_Backups\"><span class=\"toc_number toc_depth_1\">7.<\/span> Operational Considerations: Performance, Security, Backups<\/a><ul><li><a href=\"#Performance_Tuning_for_NFS_and_rsync\"><span class=\"toc_number toc_depth_2\">7.1.<\/span> Performance Tuning for NFS and rsync<\/a><\/li><li><a href=\"#Security_Best_Practices\"><span class=\"toc_number toc_depth_2\">7.2.<\/span> Security Best Practices<\/a><\/li><li><a href=\"#Backups_and_Ransomware_Resilience\"><span class=\"toc_number toc_depth_2\">7.3.<\/span> Backups and Ransomware Resilience<\/a><\/li><\/ul><\/li><li><a href=\"#How_to_Choose_NFS_vs_SSHFS_vs_rsync\"><span class=\"toc_number toc_depth_1\">8.<\/span> How to Choose: NFS vs SSHFS vs rsync<\/a><\/li><li><a href=\"#Choose_by_File_Access_and_Failure_Requirements\"><span class=\"toc_number toc_depth_1\">9.<\/span> Choose by File Access and Failure Requirements<\/a><\/li><\/ul><\/div>\n<h2><span id=\"What_Problem_Are_We_Really_Solving\">What Problem Are We Really Solving?<\/span><\/h2>\n<p>Before choosing NFS, SSHFS or rsync, it helps to be very clear about <strong>what kind of data<\/strong> you are trying to share between web servers. In practice, you almost always deal with one or more of these categories:<\/p>\n<ul>\n<li><strong>Application code<\/strong> (PHP, Node.js, Laravel, WordPress core, theme and plugin files).<\/li>\n<li><strong>User uploads<\/strong> (images, PDFs, videos, avatars, reports, export files).<\/li>\n<li><strong>Generated assets<\/strong> (build artifacts, compiled JS\/CSS, resized thumbnails).<\/li>\n<li><strong>Sessions and cache data<\/strong> (PHP sessions, object cache, queues, temporary files).<\/li>\n<li><strong>Logs<\/strong> (access logs, error logs, application logs).<\/li>\n<\/ul>\n<p>Not all of these should be handled with the same mechanism. For example, file-based sessions shared over NFS can work, while Redis or Memcached can avoid shared-filesystem I\/O. Performance and reliability depend on the session handler, eviction policy and failure-recovery design. We have a separate deep dive on this in our article <a href=\"https:\/\/www.dchost.com\/blog\/en\/php-session-cache-files-redis-memcached\/\">choosing PHP session and cache storage: files vs Redis vs Memcached<\/a>.<\/p>\n<p>User uploads can live on a central file server or in object storage, as discussed in our guide to <a href=\"https:\/\/www.dchost.com\/blog\/en\/s3-minio-media-offload-for-wordpress-woocommerce-and-magento\/\">offloading WordPress and WooCommerce media to S3\/MinIO-compatible storage<\/a>. Separate public media from private reports and exports: a shared directory does not mean every file should be publicly accessible. Identify which data changes frequently, which files are complete and immutable, who may write them, and how soon other nodes must read them.<\/p>\n<h2><span id=\"Quick_Overview_NFS_SSHFS_and_rsync\">Quick Overview: NFS, SSHFS and rsync<\/span><\/h2>\n<h3><span id=\"NFS_Network_File_System\">NFS (Network File System)<\/span><\/h3>\n<p>NFS exposes a directory on one server as a network filesystem that other servers can <strong>mount<\/strong> as if it were a local disk. The NFS client handles remote read\/write operations. Web nodes can mount the export at the same path (for example <code>\/var\/www\/shared<\/code>) and use familiar filesystem operations, but caching and locking behavior can differ from a local filesystem.<\/p>\n<p>This makes NFS a candidate for sharing user uploads, configuration or home directories across web servers. Concurrent writes to the same file still require application-level coordination.<\/p>\n<h3><span id=\"SSHFS\">SSHFS<\/span><\/h3>\n<p>SSHFS is a FUSE-based filesystem that tunnels file operations over <strong>SSH<\/strong>. You need SSHFS and FUSE support on the client and an SSH server with SFTP access on the \u201cstorage\u201d machine. Authentication can use SSH keys, without a separate NFS service or port.<\/p>\n<p>It feels like \u201cNFS over SSH\u201d, but internally it is very different: it lives in userspace, can add overhead, and should not be assumed to provide the same filesystem semantics as NFS.<\/p>\n<h3><span id=\"rsync\">rsync<\/span><\/h3>\n<p>rsync is not a filesystem at all; it is a <strong>file synchronization tool<\/strong>. You run it periodically (or triggered) to push or pull changes between directories. rsync can transfer differences (deltas) rather than entire changed files, can preserve permissions, hardlinks and ownership with suitable options and privileges, and works over SSH.<\/p>\n<p>This is useful for <strong>one-way replication<\/strong>: publishing new code releases to multiple web servers, syncing uploads from a primary node to secondaries, or copying files as part of a backup process. A synchronized copy alone does not provide backup history.<\/p>\n<h2><span id=\"NFS_Central_Shared_Storage_for_Multiple_Web_Servers\">NFS: Central Shared Storage for Multiple Web Servers<\/span><\/h2>\n<h3><span id=\"How_NFS_Works_in_a_web_hosting_Setup\">How NFS Works in a <a href=\"https:\/\/www.dchost.com\/hosting\">web hosting<\/a> Setup<\/span><\/h3>\n<p>Designate a file server and define exactly which clients need access. In this illustrative Linux example, <code>\/srv\/web-uploads<\/code> is the root of a dedicated filesystem on <code>10.0.0.10<\/code>; the two permitted clients are <code>10.0.0.11<\/code> and <code>10.0.0.12<\/code>. Confirm that layout first: exporting an arbitrary subdirectory is not equivalent to filesystem-level isolation. An <code>\/etc\/exports<\/code> entry could be:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">\/srv\/web-uploads 10.0.0.11(rw,sync,root_squash) 10.0.0.12(rw,sync,root_squash)\n<\/code><\/pre>\n<p>Configure and activate the export using the server\u2019s NFS administration procedure, then verify the effective export list. Match the non-root application UID\/GID and server-side directory permissions; <code>root_squash<\/code> maps remote UID\/GID 0 to an anonymous identity, not all users. Restrict network access to the intended clients. Each client needs NFS tools and an existing empty mount point; mounting over a populated directory hides its local contents. With the export reachable, an administrator can mount it:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">mount -t nfs 10.0.0.10:\/srv\/web-uploads \/var\/www\/uploads\n<\/code><\/pre>\n<p>The application uses normal file APIs but must account for latency, I\/O errors and caching. This mount command uses negotiated protocol\/options rather than a universal tuning recipe; verify the effective settings, application-user access and behavior after reboot in your deployment. Default Linux <code>hard<\/code> retries can leave processes waiting during an outage. Choosing <code>soft<\/code> merely to avoid hangs can introduce data-corruption risks. The server-side <code>sync<\/code> export requests stable storage before replies; it is distinct from the client\u2019s <code>sync<\/code> mount option. See the <a href=\"https:\/\/man7.org\/linux\/man-pages\/man5\/exports.5.html\" rel=\"nofollow noopener\" target=\"_blank\">exports manual<\/a> and <a href=\"https:\/\/man7.org\/linux\/man-pages\/man5\/nfs.5.html\" rel=\"nofollow noopener\" target=\"_blank\">Linux NFS manual<\/a>.<\/p>\n<h3><span id=\"Pros_of_NFS_for_Web_Clusters\">Pros of NFS for Web Clusters<\/span><\/h3>\n<ul>\n<li><strong>Shared backing files:<\/strong> An upload does not need a separate replication job for each node. Linux close-to-open behavior flushes changes on close and checks freshness on a subsequent open; already-open handles, directory\/negative-lookup caches and application caches still matter. Do not assume instant visibility everywhere.<\/li>\n<li><strong>Familiar operations:<\/strong> Ownership, permissions, symlinks and locks are available. Align UID\/GID values and test the application\u2019s locking and concurrent-write behavior; NFS does not resolve conflicting writes for you.<\/li>\n<li><strong>Linux support:<\/strong> Client support is widespread, but the chosen image may require installation of NFS utilities.<\/li>\n<li><strong>Measurable LAN performance:<\/strong> Latency, small-file metadata work, caching and storage affect results. A fast port or NVMe device alone does not prove adequate capacity. See <a href=\"https:\/\/www.dchost.com\/blog\/en\/nvme-ssd-vs-sata-ssd-vs-hdd\/\">NVMe, SATA SSD and HDD storage choices<\/a> for the storage side.<\/li>\n<li><strong>Central backup scope:<\/strong> Shared files can be backed up at the file server. Coordinate writes or use an appropriate consistent snapshot, retain separate recovery points, and back up the database and other application state too.<\/li>\n<\/ul>\n<h3><span id=\"Cons_and_Pitfalls_of_NFS\">Cons and Pitfalls of NFS<\/span><\/h3>\n<ul>\n<li><strong>Shared failure dependency:<\/strong> If the NFS service or storage fails, operations needing that share may block or fail. The impact depends on what the application keeps there. Consistent storage, NFS service failover and client lock recovery all need testing; redundant disks, servers or a movable IP alone are insufficient.<\/li>\n<li><strong>Resource bottlenecks:<\/strong> The server and network must handle remote I\/O not satisfied by caches. Uploads, generated files and metadata-heavy access can exhaust capacity even when large-file throughput looks healthy.<\/li>\n<li><strong>Locking and caching:<\/strong> Applications must account for remote visibility and recovery. NFSv3 uses separate locking services; NFSv4 includes locking in the protocol. Do not disable locks as a generic performance tweak.<\/li>\n<li><strong>Security configuration:<\/strong> Limit client addresses and file permissions. Default <code>sec=sys<\/code> does not provide cryptographic user authentication or traffic privacy; <code>root_squash<\/code> does not correct that limitation.<\/li>\n<li><strong>Distance and packet loss:<\/strong> WAN latency and interruptions can make synchronous file operations expensive or leave requests waiting. Test the actual path rather than infer suitability from a network label.<\/li>\n<\/ul>\n<h3><span id=\"When_NFS_Makes_Sense\">When NFS Makes Sense<\/span><\/h3>\n<p>NFS is worth considering in these scenarios:<\/p>\n<ul>\n<li><strong>WordPress\/PHP clusters<\/strong> needing shared uploads, such as a few nodes within one data center. A count such as two to five nodes is illustrative, not an NFS capacity rule.<\/li>\n<li><strong>Shared home directories<\/strong> where identities, permissions and user workloads can be managed consistently.<\/li>\n<li><strong>Legacy applications<\/strong> requiring filesystem APIs that cannot easily use object storage, provided their locking, cache and failure expectations are tested.<\/li>\n<\/ul>\n<p>You should be more cautious using NFS for:<\/p>\n<ul>\n<li><strong>Bursty write workloads:<\/strong> Measure concurrent uploads and metadata activity instead of choosing by traffic category alone.<\/li>\n<li><strong>Sessions:<\/strong> Compare file-based handling with an application-supported Redis, Memcached or database handler; expiry, eviction, locking and recovery matter as much as speed.<\/li>\n<li><strong>Cross-region access:<\/strong> Measure latency and define behavior when the link or remote storage is unavailable.<\/li>\n<li><strong>Database storage:<\/strong> Do not give independent active MySQL\/PostgreSQL servers the same physical data directory. Whether one database instance can use NFS is a separate question from replication between independent instances. PostgreSQL permits NFS with a <code>hard<\/code> mount and correct durability behavior, and strongly recommends a server <code>sync<\/code> export. Client <code>sync<\/code> is not required because PostgreSQL issues its own <code>fsync<\/code> calls. MySQL 8.4 recommends careful testing and NFSv4 or later; each independent instance needs its own data directory. Shared-disk failover must prevent simultaneous active access. Copying a running database directory with rsync is not, by itself, a consistent database backup.<\/li>\n<\/ul>\n<p>Consult <a href=\"https:\/\/www.postgresql.org\/docs\/current\/creating-cluster.html\" rel=\"nofollow noopener\" target=\"_blank\">PostgreSQL\u2019s storage requirements<\/a>, its <a href=\"https:\/\/www.postgresql.org\/docs\/current\/different-replication-solutions.html\" rel=\"nofollow noopener\" target=\"_blank\">replication and shared-disk guidance<\/a>, and <a href=\"https:\/\/docs.oracle.com\/cd\/E17952_01\/mysql-8.4-en\/disk-issues.html\" rel=\"nofollow noopener\" target=\"_blank\">MySQL 8.4\u2019s NFS discussion<\/a> for the database-specific constraints.<\/p>\n<h2><span id=\"SSHFS_Convenient_Access_Through_SSH\">SSHFS: Convenient Access Through SSH<\/span><\/h2>\n<h3><span id=\"How_SSHFS_Works\">How SSHFS Works<\/span><\/h3>\n<p>SSHFS needs client-side SSHFS\/FUSE support and server-side SFTP access. Run it as the intended mounting user, create a mount point that user owns, and check that the remote account can access the source. The following example uses a single SSH identity and is for that mounting user; it does not automatically grant a separate web-server user access:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">sshfs user&#64;10.0.0.20:\/srv\/uploads \/var\/www\/uploads -o IdentityFile=\/home\/user\/.ssh\/id_rsa\n<\/code><\/pre>\n<p>Remote operations pass through SSHFS in user space and SFTP over SSH; caching can avoid some requests. By default only the mounting user can access the mount. <code>allow_other<\/code> expands local access and should be assessed with <code>default_permissions<\/code>, identity mapping and the system\u2019s FUSE policy. The server still sees the remote SSH account, so local user separation does not create independent server-side identities.<\/p>\n<h3><span id=\"Advantages_of_SSHFS\">Advantages of SSHFS<\/span><\/h3>\n<ul>\n<li><strong>Simple server-side setup<\/strong>: SSHFS can reuse an existing SSH service with SFTP access rather than require NFS exports. The client still needs SSHFS and FUSE support.<\/li>\n<li><strong>Encrypted by default<\/strong>: All traffic is wrapped in SSH. You don\u2019t need to add extra encryption layers.<\/li>\n<li><strong>Account-based access with SSH keys<\/strong>: A dedicated SSH user can authenticate with its own key. Filesystem permissions or server-side restrictions, not the key alone, determine which files it can access.<\/li>\n<li><strong>Great for ad\u2011hoc mounts<\/strong>: For one-off maintenance tasks, manual file inspection or quick migrations, SSHFS is very handy.<\/li>\n<\/ul>\n<h3><span id=\"Limitations_and_Risks_of_SSHFS_in_Web_Hosting\">Limitations and Risks of SSHFS in Web Hosting<\/span><\/h3>\n<ul>\n<li><strong>Workload-dependent overhead:<\/strong> SSH encryption and FUSE add work, but the comparison with NFS depends on the files, concurrency, cache and network. Test the intended workload rather than assume a fixed speed ranking.<\/li>\n<li><strong>Connection loss:<\/strong> Network operations can wait indefinitely by default. SSH keepalive settings help detect a broken connection; they do not protect in-flight writes. With <code>reconnect<\/code>, accesses to files opened before reconnection can fail and those files must be reopened.<\/li>\n<li><strong>Filesystem differences:<\/strong> Hardlinks can appear as distinct inodes. Atomic rename depends on the SFTP server; the rename workaround that removes an existing destination first is not atomic. Test application requirements instead of assuming local-filesystem semantics.<\/li>\n<li><strong>Production dependency:<\/strong> If requests, sessions or transactional data depend on the mount, define how the application recovers from blocked or failed I\/O. A forced disconnect does not prove pending writes completed.<\/li>\n<\/ul>\n<p>The <a href=\"https:\/\/github.com\/libfuse\/sshfs\/blob\/master\/sshfs.rst\" rel=\"nofollow noopener\" target=\"_blank\">upstream SSHFS manual<\/a> documents permission, reconnection and filesystem limitations.<\/p>\n<h3><span id=\"When_SSHFS_Is_and_Is_Not_a_Good_Idea\">When SSHFS Is (and Is Not) a Good Idea<\/span><\/h3>\n<p>Where SSHFS can shine:<\/p>\n<ul>\n<li><strong>Temporary admin access<\/strong> to a remote file tree from a management server or engineer\u2019s workstation.<\/li>\n<li><strong>Low-traffic internal tools<\/strong> where convenience is more important than peak performance.<\/li>\n<li><strong>One-off migrations<\/strong> when you want to browse or copy files interactively before switching to rsync or another tool.<\/li>\n<\/ul>\n<p>Workloads requiring additional validation before using SSHFS include:<\/p>\n<ul>\n<li>A primary shared filesystem serving production web requests.<\/li>\n<li>Session\/cache files for a busy PHP or Laravel application.<\/li>\n<li>Databases or other transactional storage with durability and locking requirements that have not been demonstrated on this stack.<\/li>\n<\/ul>\n<p>If SSHFS is already in the application\u2019s critical path, measure its actual limitations before planning a migration. NFS, rsync distribution and object storage have different interfaces and consistency behavior; switching tools requires a tested data and application transition, not just a new mount.<\/p>\n<h2><span id=\"rsync_Efficient_File_Synchronization_Not_Shared_Storage\">rsync: Efficient File Synchronization, Not Shared Storage<\/span><\/h2>\n<h3><span id=\"How_rsync_Fits_into_Multi-Server_Architectures\">How rsync Fits into Multi-Server Architectures<\/span><\/h3>\n<p>rsync synchronizes files between two directories. Examples in multi-web-server setups include:<\/p>\n<ul>\n<li><strong>CI\/CD to application nodes:<\/strong> Transfer a validated build to unpublished release directories.<\/li>\n<li><strong>Single writer to readers:<\/strong> Copy completed uploads or exports to nodes that the application does not write to.<\/li>\n<li><strong>Backup transfer:<\/strong> Copy data into a process that separately provides retained history, consistency, access isolation and restore tests.<\/li>\n<\/ul>\n<p>For code distribution, first prepare a trusted, complete <code>.\/release\/<\/code> tree containing no uploads, secrets or mutable application data. Create the dedicated, unpublished release destination on each host and confirm the account can write it. The following two commands only preview changes. The trailing slash copies the source directory\u2019s contents; verify the exact paths and every proposed deletion:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">rsync -a --dry-run --itemize-changes --delete -e ssh .\/release\/ web1:\/var\/www\/releases\/example-build\/\nrsync -a --dry-run --itemize-changes --delete -e ssh .\/release\/ web2:\/var\/www\/releases\/example-build\/\n<\/code><\/pre>\n<p>After reviewing a preview against a frozen source, remove only <code>--dry-run<\/code> to transfer that release, checking each exit status and target contents. A preview is not a lock against changes between runs. Keep the target outside the live release and outside persistent data; <code>--delete<\/code> removes extra files in the synchronized target tree. These commands do not activate a release, coordinate nodes or guarantee downtime-free deployment. Compression is omitted because already-compressed media or a fast network may not benefit from <code>-z<\/code>.<\/p>\n<h3><span id=\"Pros_of_rsync\">Pros of rsync<\/span><\/h3>\n<ul>\n<li><strong>Conditional bandwidth savings:<\/strong> The default changed-file check uses size and modification time. <code>--checksum<\/code> changes that selection and adds reads; it is distinct from transfer integrity checks. Delta transfers can reduce network traffic, while local-to-local copies normally transfer whole files.<\/li>\n<li><strong>Flexible distribution:<\/strong> One source can feed several targets. For many-to-one log collection, use separate per-source paths and handle rotation; rsync is not a continuous log collector.<\/li>\n<li><strong>Explicit SSH transport:<\/strong> SSH encrypts the transfer and authenticates the endpoint. A direct rsync daemon connection is not automatically SSH-encrypted.<\/li>\n<li><strong>Metadata control:<\/strong> <code>-a<\/code> does not include ACLs, extended attributes or hardlinks. Add <code>-A<\/code>, <code>-X<\/code> or <code>-H<\/code> only where needed and supported, with the required permissions.<\/li>\n<li><strong>Backup generations:<\/strong> <code>--link-dest<\/code> can share unchanged files between separately retained generations using hardlinks. Protect old generations from modification; hardlinks are not independent copies against every failure.<\/li>\n<\/ul>\n<h3><span id=\"Cons_and_Design_Gotchas_with_rsync\">Cons and Design Gotchas with rsync<\/span><\/h3>\n<ul>\n<li><strong>Copy lag:<\/strong> Scheduling every five minutes does not guarantee five-minute freshness; transfer duration, failures and queued work can extend it.<\/li>\n<li><strong>Conflicting writers:<\/strong> Two runs in opposite directions do not make conflict-aware bidirectional sync. Source changes, overwrites and deletions can destroy the other node\u2019s version.<\/li>\n<li><strong>Operational controls:<\/strong> Prevent overlapping jobs and monitor exit status, last successful completion, file age and target readability. Partial-transfer codes such as 23 or 24 require investigation rather than being treated as complete success.<\/li>\n<li><strong>Mixed releases:<\/strong> File and directory updates are not an atomic cluster-wide change. Upload to a separate release directory and coordinate validation and activation.<\/li>\n<\/ul>\n<h3><span id=\"rsync_for_Code_Deployments_and_Blue-Green_Releases\">rsync for Code Deployments and Blue-Green Releases<\/span><\/h3>\n<p>Use one immutable release directory per build. After transfer and validation, a deployment system can atomically replace a symlink on a single host using a supported <a href=\"https:\/\/man7.org\/linux\/man-pages\/man2\/rename.2.html\" rel=\"nofollow noopener\" target=\"_blank\">same-filesystem rename<\/a>. This changes one directory entry; it does not update every server simultaneously or switch already-running PHP\/worker processes. Prepare cache and process handling, health checks, traffic draining and compatible database changes as part of the release.<\/p>\n<p>Our <a href=\"https:\/\/www.dchost.com\/blog\/en\/zero-downtime-ci-cd-to-a-vps-the-friendly-rsync-symlink-systemd-playbook-i-keep-reusing\/\">rsync, symlink and systemd deployment guide<\/a> covers the broader pattern. Returning the code pointer to an older release does not undo database writes, schema changes or external side effects. Retain compatible code and assets and define when rollback remains valid.<\/p>\n<h3><span id=\"rsync_for_Upload_Replication\">rsync for Upload Replication<\/span><\/h3>\n<p>For user uploads, a common pattern is:<\/p>\n<ol>\n<li>Designate one upload writer and route all upload forms\/APIs to it. Define how writes stop or transfer to a new authoritative node when it fails.<\/li>\n<li>Publish only completed files on the source, then copy them to application-read-only targets. Monitor transfer results and confirm the intended targets can read them.<\/li>\n<li>Until a file is confirmed on a target, direct reads to the authoritative source or keep it unpublished there. \u201cBriefly missing\u201d is not a safe guarantee: a failed job or source outage can leave the file unavailable indefinitely.<\/li>\n<\/ol>\n<p>This model can remove the need for a shared filesystem when the application can manage lag and a single writer. Object storage with CDN is another option if the application supports its API and access model. Regional availability, durability, authorization and cache behavior depend on the selected service; no choice removes those design questions.<\/p>\n<h2><span id=\"Designing_a_Shared_Files_Strategy_for_Your_Web_Cluster\">Designing a Shared Files Strategy for Your Web Cluster<\/span><\/h2>\n<p>Instead of asking \u201cWhich is better, NFS, SSHFS or rsync?\u201d, the more useful question is: <strong>Which combination fits the data types and traffic patterns of my application?<\/strong><\/p>\n<h3><span id=\"Data-Type-Driven_Choices\">Data-Type-Driven Choices<\/span><\/h3>\n<ul>\n<li><strong>Application code:<\/strong> Separate release directories on each node can reduce dependence on network storage at request time. Keep code and built assets aligned. OPcache mainly stores bytecode in shared memory and also supports optional disk caching; it is not a shared application-data folder. Whether a PHP request reads source files from NFS depends in part on cache state and configuration.<\/li>\n<li><strong>User uploads:<\/strong> NFS offers shared file APIs with caching and failure constraints. Single-writer rsync offers separate copies with explicitly managed lag. Object storage requires application\/plugin compatibility and access-policy design; compare <a href=\"https:\/\/www.dchost.com\/blog\/en\/object-block-file-storage-web-apps-backups\/\">object, block and file storage<\/a>.<\/li>\n<li><strong>Sessions and cache:<\/strong> Choose a supported handler and define locking, expiry, eviction and failover. Shared files, Redis, Memcached and database-backed sessions have different tradeoffs; see <a href=\"https:\/\/www.dchost.com\/blog\/en\/php-session-cache-files-redis-memcached\/\">PHP session and cache storage choices<\/a>. Installing a cache service does not automatically migrate every session mechanism.<\/li>\n<li><strong>Logs:<\/strong> Local buffering plus a central collector can separate log delivery from request-time shared storage. If using rsync for completed log files, separate source paths and manage rotation. See <a href=\"https:\/\/www.dchost.com\/blog\/en\/multi-server-centralized-logging-elk-loki\/\">centralizing logs with ELK and Loki<\/a>.<\/li>\n<\/ul>\n<h3><span id=\"Example_Architecture_Small_WordPress_Cluster\">Example Architecture: Small WordPress Cluster<\/span><\/h3>\n<p>Consider an illustrative three-node WordPress cluster behind a load balancer. The nodes could use VPS or <a href=\"https:\/\/www.dchost.com\/dedicated-server\">dedicated servers<\/a>, subject to the selected service\u2019s network access and administration capabilities.<\/p>\n<ul>\n<li><strong>Code:<\/strong> Deploy the same core, plugin, theme and asset release to each node, then coordinate the traffic transition.<\/li>\n<li><strong>Uploads:<\/strong> Mount the shared upload area at the installation\u2019s <code>wp-content\/uploads<\/code> path (for example, <code>\/var\/www\/html\/wp-content\/uploads<\/code>) and verify UID\/GID, permissions and new-file visibility. Prevent uploaded files from being executed as application code.<\/li>\n<li><strong>Application state:<\/strong> Use the same production database and compatible application keys\/cookie settings. <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-object-cache-with-redis-or-memcached-step-by-step-for-shared-hosting-and-vps\/\">WordPress object cache with Redis or Memcached<\/a> is separate from the actual WooCommerce cart\/session or plugin PHP-session implementation. Test login, cart and checkout when requests move between nodes.<\/li>\n<li><strong>Backups:<\/strong> Back up files and database state with appropriate consistency, separately retained generations and restricted credentials. Using a copying tool or object-storage destination alone does not supply ransomware-resistant history.<\/li>\n<\/ul>\n<p>Web-node replacement becomes more repeatable when mutable state is deliberately separated. A replacement still needs matching configuration, secrets, permissions, code, storage access and health checks before it rejoins traffic. Mounting NFS and copying code alone does not prove the node is ready.<\/p>\n<h3><span id=\"Example_Architecture_Static_Asset_Build_rsync_Fan-Out\">Example Architecture: Static Asset Build + rsync Fan-Out<\/span><\/h3>\n<p>For a Laravel or SPA frontend project, you might build all assets in CI, then:<\/p>\n<ul>\n<li>Produce a versioned immutable asset build.<\/li>\n<li>Transfer it to a separate versioned path on every node, checking exit status and required files.<\/li>\n<li>Only then publish HTML that references that version. Retain older assets while cached HTML or ongoing sessions may still request them.<\/li>\n<\/ul>\n<p>For these immutable assets, rsync can supply distribution without NFS, provided activation and retention are coordinated. Laravel API\/queue workflows need a different check: both processes must use a disk configuration and permissions that reach the intended file. The public disk defaults to <code>storage\/app\/public<\/code>, exposed through <code>public\/storage<\/code>; private reports should remain on a separate private disk. Finish the file write and required durability steps before queuing processing, use completed names rather than exposing partial files, and make retries safe. Laravel <code>after_commit<\/code>\/<code>afterCommit<\/code> waits for database commits, not for file completion. See the <a href=\"https:\/\/laravel.com\/framework\/docs\/12.x\/filesystem\" rel=\"nofollow noopener\" target=\"_blank\">filesystem<\/a> and <a href=\"https:\/\/laravel.com\/framework\/docs\/12.x\/queues#jobs-and-database-transactions\" rel=\"nofollow noopener\" target=\"_blank\">queue transaction<\/a> documentation.<\/p>\n<h2><span id=\"Operational_Considerations_Performance_Security_Backups\">Operational Considerations: Performance, Security, Backups<\/span><\/h2>\n<h3><span id=\"Performance_Tuning_for_NFS_and_rsync\">Performance Tuning for NFS and rsync<\/span><\/h3>\n<p>Whichever method you pick, you must watch resource usage. We strongly recommend monitoring your servers with tools like <code>htop<\/code>, <code>iotop<\/code>, and a metrics stack. Our article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/vps-resource-monitoring\/\">monitoring VPS resource usage with htop, iotop, Netdata and Prometheus<\/a> walks through a practical setup.<\/p>\n<p>For NFS performance:<\/p>\n<ul>\n<li>Measure storage latency, metadata operations, queue depth and cache behavior under representative concurrent load; faster storage alone does not eliminate network limits.<\/li>\n<li>Size bandwidth and latency from actual workload requirements rather than a universal 1 or 10 Gbps rule.<\/li>\n<li>Read\/write sizes are normally negotiated. Inspect effective <code>rsize<\/code>\/<code>wsize<\/code> and measure before overriding them. Generic <code>noatime<\/code>\/<code>nodiratime<\/code> options have no effect on Linux NFS mounts, and <code>intr<\/code> has been ignored since Linux 2.6.25.<\/li>\n<li>Track blocked operations and retries with <code>hard<\/code> mounts. Do not trade away correctness with <code>soft<\/code>, disabled locking or server <code>async<\/code> exports merely to improve a benchmark.<\/li>\n<\/ul>\n<p>For rsync performance:<\/p>\n<ul>\n<li>Schedule large copies to avoid competing with request traffic and measure scan, CPU, disk and network costs.<\/li>\n<li>Preview <code>--delete<\/code> using <code>--dry-run --itemize-changes<\/code>; validate source contents, trailing-slash semantics and target scope. Keep persistent uploads outside code-release targets.<\/li>\n<li><code>--partial<\/code> retains incomplete transfers; a private <code>--partial-dir<\/code> can separate those files from published data. This helps resumption in suitable modes, not consistency or backup retention.<\/li>\n<li><code>--inplace<\/code> writes into the target during transfer; interruption can leave it inconsistent, and hardlinked backup generations can be changed together. It is not a general optimization for live files or database copies.<\/li>\n<\/ul>\n<p>The <a href=\"https:\/\/download.samba.org\/pub\/rsync\/rsync.1\" rel=\"nofollow noopener\" target=\"_blank\">official rsync manual<\/a> documents selection checks, transfer modes, deletion and partial-file behavior.<\/p>\n<h3><span id=\"Security_Best_Practices\">Security Best Practices<\/span><\/h3>\n<ul>\n<li><strong>NFS access:<\/strong> Restrict exports and firewall rules to the necessary clients. Use non-root application identities, correct ownership and narrow permissions. Keep <code>root_squash<\/code>; do not treat it as cryptographic authentication or complete client isolation.<\/li>\n<li><strong>NFS privacy:<\/strong> A private network does not encrypt <code>sec=sys<\/code> traffic. Where needed, evaluate <code>krb5p<\/code> or supported, enforced RPC-over-TLS on both ends. Merely enabling TLS support does not necessarily forbid plaintext clients.<\/li>\n<li><strong>SSHFS\/rsync over SSH:<\/strong> Verify host keys and use restricted accounts with appropriate file permissions. Authentication keys do not confine an account to a directory.<\/li>\n<li><strong>Restricted rsync accounts:<\/strong> The upstream <a href=\"https:\/\/download.samba.org\/pub\/rsync\/rrsync.1\" rel=\"nofollow noopener\" target=\"_blank\">rrsync wrapper<\/a> can restrict directories and operations. Review alternate shell access and writable startup files as well; a casual <code>command=<\/code> prefix is not proof of a complete sandbox. Validate SSH changes before relying on them for continued access.<\/li>\n<\/ul>\n<h3><span id=\"Backups_and_Ransomware_Resilience\">Backups and Ransomware Resilience<\/span><\/h3>\n<p>Neither a shared NFS export nor a second rsync target supplies independent backup history. Overwrites, ransomware-encrypted files and deletions can propagate to accessible copies. Separate backup permissions and retained recovery points from live distribution, and verify that a restore works without the failed production system.<\/p>\n<p>A robust strategy often follows the 3\u20112\u20111 rule (3 copies of data, 2 different media, 1 off-site). Our article on <a href=\"https:\/\/www.dchost.com\/blog\/en\/rpo-rto-backup-strategies-for-blogs-ecommerce-and-saas\/\">designing a backup strategy with realistic RPO\/RTO<\/a> and our guide to <a href=\"https:\/\/www.dchost.com\/blog\/en\/ransomware-resistant-backup-strategy\/\">ransomware\u2011resistant hosting backups<\/a> provide concrete checklists you can apply on top of your file-sharing design.<\/p>\n<h2><span id=\"How_to_Choose_NFS_vs_SSHFS_vs_rsync\">How to Choose: NFS vs SSHFS vs rsync<\/span><\/h2>\n<p>To wrap the comparison, here is a high-level decision table for multi-web-server setups:<\/p>\n<table>\n<thead>\n<tr>\n<th>Scenario<\/th>\n<th>Option to evaluate<\/th>\n<th>Required checks<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Shared uploads through filesystem APIs<\/td>\n<td>NFS<\/td>\n<td>Permissions, concurrent writes, cache visibility, durable storage and failover<\/td>\n<\/tr>\n<tr>\n<td>Code distribution to several nodes<\/td>\n<td>rsync<\/td>\n<td>Unpublished release directories, validation, coordinated activation and rollback compatibility<\/td>\n<\/tr>\n<tr>\n<td>Temporary remote file access<\/td>\n<td>SSHFS<\/td>\n<td>SFTP\/FUSE prerequisites, mounting user, remote permissions and connection recovery<\/td>\n<\/tr>\n<tr>\n<td>Single-writer upload copies<\/td>\n<td>rsync<\/td>\n<td>Managed lag, read routing, source failover and separate backup history<\/td>\n<\/tr>\n<tr>\n<td>Sessions and cache<\/td>\n<td>Application-supported handler<\/td>\n<td>Actual session mechanism, expiry, locking, eviction and recovery<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>A starting design to test against your workload is:<\/p>\n<ul>\n<li>Local release directories with coordinated code distribution.<\/li>\n<li>NFS or application-compatible object storage for shared uploads, according to access and failure requirements.<\/li>\n<li>An explicitly configured session handler and separate cache policy.<\/li>\n<li>Independent backup generations with access controls and restore tests, using rsync only where it fits the transfer process.<\/li>\n<\/ul>\n<h2><span id=\"Choose_by_File_Access_and_Failure_Requirements\">Choose by File Access and Failure Requirements<\/span><\/h2>\n<p>NFS, SSHFS and rsync solve different parts of multi-server file management. NFS exposes shared files with network, cache and lock behavior to account for. SSHFS is convenient for temporary access, with SFTP permissions and reconnect limitations. rsync distributes separate copies and can support release and backup workflows, but requires explicit handling of lag, deletion and publication. None of these tools automatically resolves concurrent writes or provides a complete backup strategy.<\/p>\n<p>Document the writers, readers, freshness target and acceptable outage behavior for each data type. Then compare DCHost service options with the required mount privileges, network access, capacity and administration responsibilities; verify package-specific capabilities rather than assume them. Before production use, test permissions, concurrent access, interrupted transfers, recovery and a restore from independently retained backups.<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Choose NFS, SSHFS or rsync by file access and failure requirements. Compare shared uploads, permissions, copy lag, code releases and independently retained backups.<\/p>\n","protected":false},"author":1,"featured_media":13218,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[184],"tags":[],"class_list":["post-3866","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3866","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/comments?post=3866"}],"version-history":[{"count":8,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3866\/revisions"}],"predecessor-version":[{"id":13220,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/3866\/revisions\/13220"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media\/13218"}],"wp:attachment":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media?parent=3866"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/categories?post=3866"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/tags?post=3866"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}