What is AEM Dispatcher?

AEM Dispatcher is a web server module (provided by Adobe) that sits in front of an AEM instance and caches and delivers content to users. It acts as a proxy server that intercepts requests to AEM and serves cached content whenever possible. AEM Dispatcher can be used to cache both static and dynamic content, and it uses a set of rules and configurations to determine when to serve cached content and when to forward requests to AEM.

Key benefits of using AEM Dispatcher:

Improved performance: AEM Dispatcher minimizes the load on the AEM instance by caching and serving content from the cache. 

Reduced server load: By serving content from the cache, AEM Dispatcher reduces the load on the AEM server, allowing it to handle more requests and users.

Better security: AEM Dispatcher can be configured to provide an additional layer of security for AEM by blocking harmful requests and limiting access to certain resources.

Scalability: The AEM Dispatcher enhances the scalability of AEM by distributing content across numerous servers, simplifying the process of scaling for extensive deployments.

 

How AEM Dispatcher Works?

AEM Dispatcher intercepts requests to AEM and checks whether the requested content is in the cache. If the content is in the cache, AEM Dispatcher serves it directly to the user.
If the content is not in the cache, AEM Dispatcher forwards the request to AEM, which generates the content and sends it back to AEM Dispatcher.
AEM Dispatcher then caches the content and serves it to the user. AEM Dispatcher uses a set of rules and configurations to determine when to serve cached content and when to forward requests to AEM.

Dispatcher setup for AEM as a cloud service in Linux/mac using docker

Prerequisites for Dispatcher Setup
  • Apache 2.2 web server
  • Dispatcher Module
  • Docker setup in local
Installation Instructions
  • Install Apache web server 
Run this command to install the Apache package on Ubuntu:
sudo apt install apache2 -y
  • Install Docker
Run this command to install the latest docker package on Ubuntu 
sudo apt-get install docker-ce docker-ce-cli containerd.io 
docker-buildx-plugin docker-compose-plugin
To verify docker was installed correctly, Run this command
docker --version
  • Execute
aem-sdk-dispatcher-tools-<version>-unix.sh
Run this command to execute script 
chmod +x <fileName>
sudo ./<fileName>
Aem dispatcher
  •  Validate the Dispatcher configuration contained in this SDK
$ sudo ./bin/validator full -d out src

 This validates the configuration and generates deployment information in out

  •  Validate the deployment information by the Dispatcher in a docker image

$ sudo ./bin/docker_run.sh out localhost:4503 test

 This will start the container, run Apache in configuration test mode (httpd -t), dump – processed dispatcher. any config (-D DUMP_ANY) and exit.

  •  Confirm that no immutable config file was changed against a docker image ones

 $ sudo ./bin/docker_immutability_check.sh src

With your AEM publish server running on your computer, listening on port 4503, you can start the dispatcher in front of that server as follows:

$ sudo ./bin/docker_run.sh out host.docker.internal:4503 8888

Sometimes, You may encounter this error “Waiting until host.docker.internal is available”-, to resolve this use  your host ip

bin/docker_run.sh src <HOST IP>:4503 8888
AEM dispatcher two

This will start the container and expose Apache on local port 8888.

AEM dispatcher