Hello,
is it possible to run MODx on a cluster? If so, what do we have to take care of or customise?
Our plans are basically to set up a cluster of LAMP machines, put a load-balancer (probably round-robin) in front of it, and use the master/slave options of mySQL to synchronise all the databases.
Olaf
-
☆ A M B ☆
- 24,524 Posts
There will be a problem with session files, unless you configure your cluster to use a single /tmp directory.
-
MODX Staff
- 12,272 Posts
Indeed, sessions are the tricky part as are keeping your assets in sync, but it certainly can be done (and we’ve done so successfully at Collabpad).
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
any hints on where to look for and how fix the session thingy? Do we have to fix something in the MODx core? Or set something up on the OS?
Olaf
-
☆ A M B ☆
- 24,524 Posts
Well, you can set the session_path in the config.inc.php file to a path in your web root, but this has its own problems. I do know that other clustered environments set their system’s /tmp file to be on one server only. I have no idea how it’s done, but it is a server/OS thing.
http://www.linux.com/feature/53578
The cookie conundrum and application design
Cookies can be a tricky issue when LAMP applications use this kind of cluster. By default, Apache stores its cookies in the /tmp directory on the server where it is running. If a visitor starts a session on one Web server, but subsequent HTTP requests are handled by a different Web server in the cluster, the cookie won’t be there and things won’t work as expected.
Because the IP address of a Web server is cached locally, this doesn’t happen often, but it is something that must be accounted for, and may require some application programming changes. One solution to the cookie problem is to use a shared cookie directory for all Web servers. Be particularly aware of this issue when using pre-built LAMP applications.
-
MODX Staff
- 12,272 Posts
Cluster configs are really not straightforward; solving the sessions issues completely depends on how your cluster, dns, database and storage is provisioned.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
hi rtrash, any hints on how you have solved this issue? ie what setup, configs etc?
Olaf
-
MODX Staff
- 12,272 Posts
We used a cluster of RightScale-managed EC2 instances backing up to S3. For our deployment, we also set up a couple of instances as NFS servers (Master/Slave) for the cache and assets, and the sessions weren’t that critical. We considered porting DB-based sessions into 0962, but that wasn’t required in the end. We did however create a subdomain for the manager pointing to a single IP address in the cluster of images.
It was a huge pain, took a lot of time to get sorted out, but it did work and did scale well. The shared storage wasn’t optimal, but it was all we had to work with. There are probably better solutions for this type of deployment involving real load balancers that maintain persistent connections for sessions and true high performance network storage (SAN or other).
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
-
☆ A M B ☆
- 24,524 Posts
From what I’ve read on the subject, a shared device to mount as /tmp is as good as it gets.
-
MODX Staff
- 10,725 Posts
That or write your own PHP session handler that uses a database instead of a configured filesystem. This will allow all points in the cluster to access the same sessions.
As for the cache, writing a quick script that you could trigger remotely to reload the cache on demand at each node (or via plugin events when manager actions are taken) is another possibility to consider.