Clustering with DDEV¶
Caution
Don't use this procedure in production. A staging environment for validation before production should exactly replicate the production environment. This is meant for development environment only.
This guide follows Install with DDEV and helps to extend the previous installation to locally replicate a production cluster.
In contrast to a production cluster, this setup has only one front app server. But the data sharing needed by a cluster of several servers can still be emulated.
The ddev config --php-version option should set the same PHP version as the production servers.
Tip
ddev describedisplays a cluster summary that include accesses from inside and outside DDEV servicesddev sshopens a terminal inside a serviceddev execexecutes a command inside a service
Discover more commands in DDEV documentation.
To run an Ibexa Cloud project locally, you may refer to DDEV and Ibexa Cloud instead.
Install search engine¶
A search engine can be added to the cluster.
Elasticsearch¶
The following sequence of commands:
- Adds the Elasticsearch container.
- Sets Elasticsearch as the search engine.
- Restarts the DDEV cluster and clears application cache.
- Injects the schema and reindexes the content.
1 2 3 4 5 6 7 | |
You can now check whether Elasticsearch works.
For example, the ddev exec curl -s "http://elasticsearch:9200/_count" command checks whether the web server can access the elasticsearch server and displays the number of indexed documents.
For more information on topics such as memory management, see ddev/ddev-elasticsearch README.
See Elasticsearch REST API reference for more request options, like, for example:
_count, as seen above_cluster/health(don't mind the "yellow" status which is normal in the absence of replicas in the DDEV container)_search?size=0", which is another way to get document count
Tip
You can use jq to format and colorize Elasticsearch REST API outputs.
Solr¶
To simplify the installation of Solr, you can use the ibexa/ddev-solr add-on:
1 2 | |
You can now check whether Solr works.
For example, the ddev exec curl -s http://solr:8983/api/cores/ command:
- checks whether the
webserver can access thesolrserver - checks whether
collection1exists and its status - displays
collection1'snumDocsthat shouldn't be zero if indexing worked correctly
You can access the Solr admin UI from the host by using port 8983 on the same .ddev.site subdomain as the front. Use ddev describe to get that URL.
Share cache and sessions¶
You can add a persistence cache pool and a session handler to the cluster.
In the following examples:
- the same service is used to store both persistence cache and sessions
- the session handler is set on Symfony side, not on PHP side
Install Redis¶
The following sequence of commands:
- Adds the Redis container.
- Set Redis as the cache pool.
- Sets Redis as the session handler.
- Changes
maxmemory-policyfrom defaultallkeys-lfuto a value accepted by theRedisTagAwareAdapter. - Restarts the DDEV cluster and clears application cache.
1 2 3 4 5 6 7 8 | |
You can now check whether Redis works.
For example, the ddev redis-cli MONITOR command returns outputs, for example, "SETEX" "ezp:, "MGET" "ezp:, "SETEX" "PHPREDIS_SESSION:, or "GET" "PHPREDIS_SESSION:, while navigating into the website, in particular the back office.
See Redis commands for more details such as information about the MONITOR command used in the previous example.
Install Memcached¶
First, if not already there, append the following new service to config/services.yaml:
1 2 3 4 5 | |
Second, install and set up the add-on. The following sequence of commands:
- Adds the Memcached container.
- Sets Memcached as the cache pool.
- Sets Memcached as the session handler.
- Restarts the DDEV cluster and clears application cache.
1 2 3 4 5 6 7 | |
You can now check whether everything went right.
For example, the watch 'ddev exec netcat -w1 memcached 11211 <<< "stats" | grep "cmd_.et "' command checks whether the web service can access the memcached service, and displays the increase of cmd_get and cmd_set while navigating into the website.