Episerver load balancing example - Configuring events over WCF with TCP/IP

Last update: May 24 2017

Episerver load balancing can be used to improve both security and performance. This KB article shows a common load-balancing configuration with one content authoring (CA) server and two content delivery (CD) servers. 

In this example, content authors publish on the CA server which, in turn, broadcasts events to a listening service on the two Content Delivery (CD) servers. Next, a "publish is made" event is generated on CA, which expires the cache on CD1 and CD2. The cache on CD1 and CD2 is then regenerated by pulling the updated content from the database (shared by all three servers). At this point, the published content should be the same on all three servers.

 

Below is how you can configure events for such a configuration. 

Note that the below example may not apply to your circumstances. Please see the additional resources at the bottom if you have further questions about configuring WCF events with Episerver. Also note that this was configured in Episerver CMS 10 and may not work in other versions.

  1. Configure the web.config of the broadcasting server, in this case CA. Perhaps counterintuitively, you are configuring CA as a client even though it is broadcasting events to the CD servers. If content updates are not made on the CD servers, you do not need to configure a service section on the CA servers
    1. Locate the system.serviceModel section and then the serviceHostingEnvironment tag within that. See step 1.e for what this looks like.
    2. There should be a client tag inside the serviceHostingEnvironment section. If not, add one like the one below. The endpoints in the client tag should have the IP addresses of the CD servers. You need to open a port on the CD servers and include that port in the endpoints as well. If CD1 had an IP address of 192.168.1.2 with port 5000 open, and CD2 had an IP address of 192.168.1.3 also with port 5000 open, the client section on CA would look like this.
      <client>
            <endpoint name="192.168.1.2:5000"
               address="net.tcp://192.168.1.2:5000/RemoteEventService"
               binding="netTcpBinding"
               bindingConfiguration="RemoteEventsBinding"
               contract="EPiServer.Events.ServiceModel.IEventReplication" />
            <endpoint name="192.168.1.3:5000"
               address="net.tcp://192.168.1.3:5000/RemoteEventService"
               binding="netTcpBinding"
               bindingConfiguration="RemoteEventsBinding"
               contract="EPiServer.Events.ServiceModel.IEventReplication" />
      </client>
    3. After the client section, add a behaviors section.
      <behaviors>
          <serviceBehaviors>
            <behavior name="DebugServiceBehaviour">
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
    4. Next is a bindings section. You may have an indexing service binding here as well, so adjust as needed.
      <bindings>
              <netTcpBinding>
              <binding name="RemoteEventsBinding" portSharingEnabled="true">
                <security mode="None" />
              </binding>
            </netTcpBinding>
        </bindings>
    5. When all said and done, your CA web.config's system.ServiceModel section would look like this.
      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
          <client>
            <endpoint name="192.168.1.2"
               address="net.tcp://192.168.1.2:5000/RemoteEventService"
               binding="netTcpBinding"
               bindingConfiguration="RemoteEventsBinding"
               contract="EPiServer.Events.ServiceModel.IEventReplication" />
            <endpoint name="192.168.1.3"
               address="net.tcp://192.168.1.3:5000/RemoteEventService"
               binding="netTcpBinding"
               bindingConfiguration="RemoteEventsBinding"
               contract="EPiServer.Events.ServiceModel.IEventReplication" />
          </client>
        <behaviors>
          <serviceBehaviors>
            <behavior name="DebugServiceBehaviour">
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
              <netTcpBinding>
              <binding name="RemoteEventsBinding" portSharingEnabled="true">
                <security mode="None" />
              </binding>
            </netTcpBinding>
        </bindings>
      </system.serviceModel>
  2. Now that the CA server is configured, you need to configure the CD servers to be listening services to the CA server. There is no client section needed in the CD servers. On the CD servers, WCF only needs to listen on its service address.
    1. Again locate the <system.serviceModel> section and then the serviceHostingEnvironment tag within that.
    2. There should be a service tag inside the serviceHostingEnvironment section. If not add one like the one below. The CD server's IP address and port you wish to listen on for cache expiring events are listed in this section. If CD1 is 192.168.1.2, its service would look like this.
          <services>
          	<service name="EPiServer.Events.Remote.EventReplication">
      	      <endpoint
      	      name="RemoteEventServiceEndPoint"
      	      contract="EPiServer.Events.ServiceModel.IEventReplication"
      	      bindingConfiguration="RemoteEventsBinding"
      	      address="net.tcp://192.168.1.2:5000/RemoteEventService"
      	      binding="netTcpBinding" />
      	    </service>
          </services>
    3. If CD2 is 192.168.1.3, its service would look like this. 
          <services>
          	<service name="EPiServer.Events.Remote.EventReplication">
      	      <endpoint
      	      name="RemoteEventServiceEndPoint"
      	      contract="EPiServer.Events.ServiceModel.IEventReplication"
      	      bindingConfiguration="RemoteEventsBinding"
      	      address="net.tcp://192.168.1.3:5000/RemoteEventService"
      	      binding="netTcpBinding" />
      	    </service>
          </services>
    4. Add the behaviors section.
        <behaviors>
          <serviceBehaviors>
            <behavior name="DebugServiceBehaviour">
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
    5. Add the bindings section.
        <bindings>
              <netTcpBinding>
              <binding name="RemoteEventsBinding" portSharingEnabled="true">
                <security mode="None" />
              </binding>
            </netTcpBinding>
        </bindings>
    6. Once finished, your CD1 config should look like this. CD2 would be identical except the endpoint would have a different IP address.
      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
          <services>
          	<service name="EPiServer.Events.Remote.EventReplication">
      	      <endpoint
      	      name="RemoteEventServiceEndPoint"
      	      contract="EPiServer.Events.ServiceModel.IEventReplication"
      	      bindingConfiguration="RemoteEventsBinding"
      	      address="net.tcp://192.168.1.2:5000/RemoteEventService"
      	      binding="netTcpBinding" />
      	    </service>
          </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="DebugServiceBehaviour">
              <serviceDebug includeExceptionDetailInFaults="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <bindings>
              <netTcpBinding>
              <binding name="RemoteEventsBinding" portSharingEnabled="true">
                <security mode="None" />
              </binding>
            </netTcpBinding>
        </bindings>
      </system.serviceModel>

Test by modifying and publishing a page on CA and verifying CD1 and CD2 received the change.

This is just one load-balancing example so modify it to suit your needs. See the below resources for more information on configuring events over WCF.

You need to be logged in with your Episerver World account to rate articles.

Top