AEM Dispatcher Setup
Dispatcher helps us to cache data an load balancing on dispatcher.
According to Adobe, dispatcher version 4.2.3 was the last version supporting Apache 2.2. Adobe has dropped support for Apache 2.2 after December 2017 and recommends upgrading to Apache 2.4.
Dispatcher has two major advantages:
- Caching helps us to cache data on dispatcher which helps us to reduce overall response time. Every request first reaches out to dispatcher. Dispatcher will first investigate cache and return the response in case data found on the server. If data not found on dispatcher for that request will hit publish instance to get data.
- Load Balancing helps us to reduce load on the server(AEM instance). If site is getting a greater number of hits what we were not expecting. Dispatcher will divide number of requests in between multiple publish instance.
Dispatcher Flow
Below is the overall AEM dispatcher flow:
- As shown in below inline diagram, end user or any third-party service hit site URL.
- On first place request will reach out to CDN. CDN will return required data if found in cache.
- Request will reach out to dispatcher if required response not found on CDN. Dispatcher will return required data if found in cache.
- Dispatcher will look for required data in one of the AEM publish instance which can also be called as renderers if not found in dispatcher cache.
Setup Dispatcher
Follow below step by step process to setup dispatcher for AEM publish instance:
- Open URL and download below highlighted .msi file highlighted red in color to setup Apache Web Server.
2. Go to download folder and double click on httpd-2.2.25-win32-x86-no_ssl.msi file to install the same.
Click on Next button as shown below
3. Select option I accept the terms in the license agreement and click on Next button.
4. Click on Next button as no changes are required.
5. Click on Next button as no changes are required.
6. Select Typical and click on Next button.
7. Select folder to install Apache server if want to install in required folder or else leave it as it is.
8. Click on Install button to start installation.
9. Installation will take 2 to 3 min. It will show below in progress screen:
10. It will show below screen once installation is done.
Click on Finish button once installation is done.
11. Hit http://localhost URL in browser and check if dispatcher setup is successful or not.
12. Open URL and download required file. For current setup we are going to have OpenSSL as none as highlighted below red in color.
13. Unzip downloaded folder and verify below files:
14. Navigate to Apache download folder and looks for httpd.conf file
C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/httpd.conf
15. Add below line to load AEM dispatcher module at line number 130
LoadModule dispatcher_module modules/disp_apache2.2.dll<IfModule disp_apache2.c># location of the configuration file. eg: 'conf/dispatcher.any'
DispatcherConfig conf/dispatcher.any
# location of the dispatcher log file. eg: 'logs/dispatcher.log'
DispatcherLog logs/dispatcher.log
# log level for the dispatcher log, can be either specified
# as a string or an integer (in parentheses)
# error(0): Errors
# warn(1): Warnings
# info(2): Info
# debug(3): Debug
# trace(4): Trace
DispatcherLogLevel warn
# if turned on, the dispatcher looks like a normal module
DispatcherNoServerHeader Off
# if turned on, request to / are not handled by the dispatcher
# use the mod_alias then for the correct mapping
DispatcherDeclineRoot Off
# if turned on, the dispatcher uses the URL already processed
# by handlers preceeding the dispatcher (i.e. mod_rewrite)
# instead of the original one passed to the web server.
DispatcherUseProcessedURL Off
# if turned to 1, the dispatcher does not spool an error
# response to the client (where the status code is greater
# or equal than 400), but passes the status code to
# Apache, which e.g. allows an ErrorDocument directive
# to process such a status code.
#
# Additionally, one can specify the status code ranges that should
# be left to web server to handle, e.g.
#
# DispatcherPassError 400-404,501
DispatcherPassError 0#
# DispatcherKeepAliveTimeout specifies the number of seconds a
# connection to a backend should be kept alive. If not set or
# set to zero, connections are not kept alive.
#
#DispatcherKeepAliveTimeout 60</IfModule>
16. Replace below lines at line number 394 with inline lines to allow all incoming requests.
Before
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
After
<Directory />
<IfModule disp_apache2.c>
ModMimeUsePathInfo On
# enable dispatcher for ALL request. if this is too restrictive,
# move it to another location
SetHandler dispatcher-handler
</IfModule>
Options FollowSymLinks
AllowOverride None
</Directory>
17. Paste downloaded disp_apache2.2.dll file inside modules folder
18. Copy downloaded dispatcher.any file from downloads folder and paste it inside to C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf folder.
19. Open dispatcher.any file and navigate to line number 65. Just for testing with publish AEM instance, update deny to allow keyword for all request URL’s as shown below:
20. Copy DocumentRoot path from httpd.conf on line number 181 to paste it inside dispatcher.any file at line number 115 as shown below
21. Update port number from 8080 to your AEM publish post, in my case it is 4503
22. Setup publish instance to load on dispatcher. Double click on cq65-publish-p4503.jar file.
23. By default, AEM publish instance will have /content/we-retail site. Use below publish and dispatcher URL’s to load AEM page.
AEM Publish instance URL
http://localhost:4503/content/we-retail/us/en/men.html
Dispatcher URL
http://localhost/content/we-retail/us/en/men.html
Both AEM publish and dispatcher URL’s will show the same page. One will be via dispatcher and other by hitting direct AEM publish instance URL using 4503 port.
Imran Khan, Adobe Community Advisor, AEM certified developer and Java Geek, is an experienced AEM developer with over 11 years of expertise in designing and implementing robust web applications. He leverages Adobe Experience Manager, Analytics, and Target to create dynamic digital experiences. Imran possesses extensive expertise in J2EE, Sightly, Struts 2.0, Spring, Hibernate, JPA, React, HTML, jQuery, and JavaScript.