Clustering and shared storage
This page is for application creators and administrators whose site runs on more than one web server. All servers must see the same files and the same database; Exponential's cluster file handlers make the storage shared.
Contents
The file handlers
settings/file.ini [ClusteringSettings] FileHandler:
| Handler | Use |
|---|---|
eZFSFileHandler (shipped) | one server, files on the local disk |
eZDFSFileHandler | several servers: files on a shared mount (NFS) with a database table that knows each file's state |
Setting up DFS
file.ini [eZDFSClusteringSettings] names the shared mount (MountPointPath), the database backend (DBBackend, for
example eZDFSFileHandlerMySQLiBackend), the DFS backend and the cluster database's host, name and user (retries:
DBConnectRetries, DBExecuteRetries). Put the password in settings/override/. Then move existing files into the
cluster with the kernel's tools (bin/php/clusterize.php) and purge with clusterpurge in cron
(see doc/eng-us/examples/commands/ for the commands).
What else must be shared
| Shared thing | How |
|---|---|
| The database | one server or a database cluster |
| Code and settings | the same release deployed to every server |
| Sessions | the database session handler, so any server can read them (Sessions) |
| Content jobs | the job directory shared (Content jobs) |
| Cron | on one server, or with locks |
| Queue workers | any number of servers; expqueue leases jobs to one worker |
| Velocity response caches | per server; clear on every server after a deploy |
| The proxy | the load balancer's address in TrustedProxies[] |
Cluster-safe application code
- Write and read files through
eZClusterFileHandler::instance( $path )(storeContents(),fetchContents(),processCache()), never withfile_put_contents()intovar/(Caching in applications). - Store uploads through the datatypes, which use the cluster handler.
- Do not keep state on one server's disk or in one process's memory.
- Make background work idempotent and locked, so two servers do not do it twice.
Related pages
- Scaling applications
- Multi-site log and cache paths
- Missing files
- Free documentation: this page is free to copy, translate and improve under the GNU FDL 1.3.
Become an Exponential Partner
Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.