How to Configure Dispatcher in aem

In my first part of the Dispatcher how to setup Dispatcher for AEM in window we discussed about the basics which is needs to up and run the Dispatcher in window.


Today in this post we will learn about the cache and load balancing in dispatcher, how we can implement these.

There are some default configurations/conditions which cached the default resources if these conditions meet.

  1. Http Request is GET request.
  2. Resource has extension like .xml and .html
  3. Request has no query parameter.
  4. Request has no Authorization header.

All these kinds of settings are configured in the dispatcher configuration file name Conf/diapatcher.any file. We will see the single and multiple value with in dispatcher.any file rules / means we have single value configured and {} means we have multiple values specified in the rule. Something like this.



#/0001
   #  {
       #  /glob “127.0.0.1”
       #  /type “allow”
        #  } 
         }

And # is used to make comment to the line.

Environment Variables-

WE can use the environment variable as string-value pair properties in the dispatcher.any file instead of hard-coding the values. To include the value of an environment variable, which are very helpful to pass the value dynamically rather than hard code. We can follow the format as: ${variable_name}.

For Example-

/docroot “${PWD}/cache”

For Example, if we create a environment variable for PUBLISH_IP which store the hostname of the AEM publish instance, then we can configure them by using the environment variable as of the /renders property which can be used:

/renders {
/0001 {
/hostname “${PUBLISH_IP}”
/port “8443”}}

How to use Naming conventions for the Dispatcher Instance?



We can use the /name property to specify the unique name  in order to identify the Dispatcher instances. The /name property should be the top-level property in the configuration structure.

For example, if the dispatcher.any file is located in the same directory as the cache directory, the following value for the docroot property can be used:

/farms –

This first thing you will see the /farms in the dispatcher.any file which specify the server means every AEM instance has at least one /farm specified. Each farm configures a set of load balanced renders.

For example-

/farms
{ $include “myFarm.any”  }

We can include any number of different different farm file which contains the different different configuration by using the asterisk (*) as wildcard to specify the range of farms which needs to be include for example:-



if we have the  5 farm files from  farm_1.any  to farm_5.any which Contains the configuration of farms from one to five, we can include them together as follows:

/farms
{$include “farm_*.any”}

Defining Farms-

The /farms property will defines the Dispatcher behaviors which can be one or more sets of Dispatcher Behaviors, where each set can be associated with different web sites or URLs.
The /farms property may be include as a single farm or multiple farms together.
And we should use single farm  entry when you want that the dispatcher to handle all of the web pages or web sites in the same way. Otherwise we can create different farms to manage the websites based on different Dispatcher behavior or required different Dispatcher behavior.


The /farmname property we can keep it as a multi-valued due to its multi-valued behavior, and contains other properties that define Dispatcher behavior. We can specify the properties by using the below notes.

    1. It will contain the URLs of the pages that the farm applies to.
    2. One or more service URLs (typically of AEM publish instances) to use for rendering documents.



  1. The statistics to use for load-balancing multiple document renderers.
  2. Several other behaviors, such as which files to cache and where.
  3. And the value can contain any alphanumeric (a-z, 0-9) characters.

Here is the Example:-

#contains the name of dispatcher
/name “my sites”
#The farms section defines a list of farms or sites
/farms
{/daycom
{..}
/docdaycom
{…}}

And Each farm property can contain the child properties such as:


/homepage – It will contain the default homepage

/clientheaders – This specify the headers from the client HTTP request to pass through.

/virtualhosts – This will contain the information about the virtual hosts for this farm.

/sessionmanagement – This will support for session management and authentication.

/renders – The servers that provide rendered pages (typically AEM publish instances).

/filter – It will define the URLs to which Dispatcher enables access.

/vanity_urls – This entry contains the configures access to vanity URLs.

/propagateSyndPost – It will support for the forwarding of syndication requests.

/cache – This Configures the caching behavior.


/statistics – Defining statistical categories for load-balancing calculations.

/stickyConnectionsFor -This folder will contain the sticky documents (if any).

/health_check -This will be the URL which will be used to determine server availability.

/retryDelay – This will specify the connection timeout behavior. Means the delay before retrying a failed connection.

/unavailablePenalty – Penalties that affect statistics for load-balancing calculations.

/failover – Resend requests to different renders when the original request fails.

/auth_checker – For permission-sensitive caching.

/website – This is the first entry of the /farm in your dispatcher file.

Here is the Dispatcher.any file for reference-



# name of the dispatcher
/name “internet-server”
# each farm configures a set off (loadbalanced) renders
/farms {
# first farm entry (label is not important, just for your convenience)
/website{
/clientheaders{
# List of headers that are passed on       }
/virtualhosts {
# List of URLs for this Web site       }
/sessionmanagement{
# settings for user authentification       }
/renders       {
# List of AEM instances that render the documents       }
/filter      {
# List of filters}
/vanity_urls{
# List of vanity URLs      }
/cache       {
# Cache configuration
/rules         {
# List of cachable documents}

       /invalidate{
# List of auto-invalidated documents         }}
/statistics       {
/categories{
# The document categories that are used for load balancing estimates}       }
/stickyConnectionsFor “/myFolder”
/health_check
{
# Page gets contacted when an instance returns a 500   }
/retryDelay “1”
/numberOfRetries “5”
/unavailablePenalty “1”
/failover “1”}}



This information is based on Adobe Documentation please refer that for more information regarding rhe Dispatcher in aem .  In my next post I will explain these properties in details one by one, how we can use these properties. Also check another post about multifield in AEM 6.X

If you really find this post useful, you can help me to keep this alive by buying me a cup of Coffee.




Stay Safe
                Happy Learning & Coding