PHP Sessions Clustering
PHP Sessions Clustering with Memcached
PHP sessions clustering improves application availability by storing session backups in Memcached. When one Apache application server fails, another server can retrieve the session and continue serving the user without interruption.
Create the Clustered Environment
Open the environment wizard
Sign in to the platform account and click Create environment.
Add the required nodes
Choose two or more Apache application-server instances and add a Memcached node. Enter the environment name and click Create.

Memcached acts as a distributed caching engine for the application-server layer. Sticky sessions keep a user on the original server while it is available, and Memcached stores a backup that can be retrieved during failover.

How Session Failover Works
NGINX distributes HTTP traffic across the application-server cluster. If the original server becomes unavailable, another server continues the session using the Memcached backup.
Configure PHP Sessions in Memcached
Open Apache configuration
Locate the environment in the dashboard and click Config beside the Apache application-server layer.
Open php.ini
Navigate to etc → php.ini.
Enable the Memcached extension
Add the following line under Dynamic Extensions:
extension=memcached.so

Configure session storage
Find the [Session] section and set Memcached as the session handler:
session.save_handler = memcached session.save_path = "<server>:11211"
Memcached address
Replace <server> with the Memcached node’s internal IP address or URL. Open the node’s Info panel in the dashboard to find it.

Save and restart Apache
Save the changes and restart the Apache application-server nodes.
Expected Result
PHP sessions are backed up to Memcached. If one Apache instance fails, the load balancer sends users to another instance, which retrieves the stored session and continues serving the application without a visible interruption.
Important Notes
- Use at least two Apache application-server instances.
- Add a Memcached node to the same environment.
- Use the Memcached node’s internal IP address or URL and port
11211. - Apply the same PHP session settings to all Apache nodes.
- Restart the Apache nodes after updating
php.ini. - Test session continuity by stopping one application-server instance.
Common Issues and Solutions
php.ini settings for all application-server instances and restart the full layer.