The setup
I admin the backend for a website that currently exists on a single node using Nginx (webserver), Neo4J (database) and Wildfly (app server). The website is getting enough traffic that we are both storage and memory resource limited on the current 'all-in-one' node, so I instantiated two more VPS nodes (3 in total) that will only run WildFly.
I've successfully configured Nginx to use the 'hash' load-balancing feature across the 3 nodes based on a user-ID contained within the website URI to ensure users are consistently routed to the same VPS node running Wildfly to optimize caching.
Each of the 3 nodes has their own 150GB high-availability block storage (maintained by the VPS provider) that contains a single /images
directory mounted that the Wildfly app will be reading/writing image files from/to on its respective node.
Update
The image files should be write-once/read-many (at least for the nominal case) so new images get created all the time, but existing images rarely get updated. Additionally, because of Nginx's hash load-balancing, each Wildfly node should have all the images it needs for the clients that get routed to it. The need for replication is really two fold:
- It makes adding or removing Wildfly nodes transparent as each node has all the data from the other nodes
- It makes backing up easier as everything is consolidated in one place
Additionally, each of the VPS nodes are a part of a private gigabit VLAN that the VPS provider enables for all nodes in the same datacenter (of which all my nodes are.) It will be this link that the replication data will traverse.
The Problem
Because the app is now distributed, I want each of the /images
directories across the 3 nodes to be fully replicated. Although Nginx's 'hash' load-balancing ensures consistent node usage on a per-user basis, I want the contents of the /images
directory to be a union of all three nodes in case one of the nodes goes down and users need to be redistributed across the other available nodes.
The Question
What is the best way to address the problem above? From my understanding, rsync
is not the appropriate tool for this job. There is this Server Fault Question which is similar in nature but it's 12 years old and i'm sure there have been some advances in data replication since that time.
In my research, I came across GlusterFS which looks promising, but it's unclear how to set this up to address my problem. Would I make each of the high-availability block storage devices on each node a single 'brick' and then combine that into a single Gluster volume? I presume I then create the /images
directory on this single Gluster volume and mount this to each of the nodes via the native FUSE client? My gut says this is not correct because each of the nodes are both clients and server simultaneously as they are both contributing a 'brick' and read/writing to the Gluster volume which seems unconventional.