Failover and Load Balancing in Jasper Server

Failover and Load Balancing in Jasper Server

Installing jasper instances

For sample configuration I installed two Jasperserver instances:

  • On two separate application server (2 tomcat servers running on different port), and with
  • Single repository (OracleDB)

For detailed installation steps refer http://helicaltech.com/installing-jasperreports-server-6-0-1-with-oracle-db-in-windows/

I installed jasper server instances on localhost. These jasper servers are running on:

http://localhost:9080/jasperserver-pro

http://localhost:9180/jasperserver-pro

Installing Apache web server

  1. Download the Apache HTTPD Web Server from the Apache web site. Be sure to download the httpd_2.2.22-win32-x86-open_ssl MSI installer here: http://httpd.apache.org/download.cgi.
  2. Double click the MSI file saved on your Windows Desktop.

Apache HTTP server 2.2-Installation wizard will open.

  1. Click on Next button.
  2. Accept the terms in License agreement and click on Next button.
  3. On the next window again click next.
  4. Next,
  • fill in all the text boxes with the following information:

“Network Domain”: localhost

“Server Name”: localhost

“Administrator’s Email Address”: your email address

  • Make sure the radio button “for all users, on port 80, as a service – recommended” is selected.
  • Click on Next.
  1. When asked about the Setup Type, select “Typical” and click next.
  2. Give the Path where you want to install all the packages and scripts. I chose this path E:\Jaspersoft\Apache2.2\

(The ending backslash is important)

Click on OK after providing the installation path.

  1. Click “Install” to begin the installation.
  2. Once the Apache installation software has finished installing all the files on your computer, you will see a final window letting you know the installation was a success. Click the “Finish” button.
  3. To check that the software was in installed successfully, open browser and type “http://localhost/” into the address bar. You should see a page that looks like this or the words It Works!

Installing mod_jk

Mod_jk is an Apache web server module that allows the Apacheweb server to interface with the Tomcat application server. Installing it and configuring it are the keys to getting the web server and the application server working together.

Download the latest version of mod_jk

New versions of mod_jk are released as source packages, and as binary packages for select platforms.  Both are available for download from the Apache Tomcat Connector project download page.Currently, the following platforms receive binary releases: AIX, FreeBSD, iSeries, Linux, Mac OS X, Netware, Solaris, and Windows (32- and 64-bit releases).

Download the most recent release.

I downloaded “tomcat-connectors-1.2.40-windows-i386-httpd-2.2.x”.

Installing mod_jk

  1. Extract the zip file.
  2. Copy mod_jk.so and paste it inside modules directory of Apache web server (E:\Jaspersoft\Apache2.2\modules).

Jasper server configuration for failover

  1. On each jasper server instance, edit the file <web-app>/WEB-INF/web.xml.
  • Locate the listener of class RequestContextListener and replace it with the listener of class TolerantRequestContextListener. The new listener class is given in comments that you need to uncomment as follows:
<listener>

   <!--SESSION REPLICATION-->

                <!--Replace the default spring listener with the Tolerant listener to enable replication-->

                <listener-class>com.jaspersoft.jasperserver.core.util.TolerantRequestContextListener

                </listener-class>

                <!--listener-class>org.springframework.web.context.request.RequestContextListener

                </listener-class-->

</listener>
  • Locate the ClusterFilter that is given in comments and uncomment is as shown below:
<filter>

       <filter-name>ClusterFilter</filter-name>

       <filter-class>com.jaspersoft.jasperserver.war.TolerantSessionFilter</filter-class>

   </filter>

<filter>
  • Locate the corresponding mapping for the ClusterFilter and uncomment it as well. You must also uncomment the <distributable> element as well.
<filter-mapping>

       <filter-name>ClusterFilter</filter-name>

       <url-pattern>/*</url-pattern>

</filter-mapping>

<distributable/>

2. On each jasper server instance, enable session replication in your app server or web container.

For example, to enable session replication on Apache Tomcat 6.x, edit the file <tomcat>/conf/server.xml as follows:

  • Within the Engine tag add jvmRoute property as shown below:
<Engine name="Catalina" defaultHost="localhost" jvmRoute="node2">
  • Add the Cluster definition within the <Engine name=”Catalina” defaultHost=”localhost” jvmRoute=”node2″> configuration. This example uses Delta Manager.
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8">
    <Manager     className="org.apache.catalina.ha.session.DeltaManager"
                expireSessionsOnShutdown="false"
                notifyListenersOnReplication="true"/>
    
    <Channel className="org.apache.catalina.tribes.group.GroupChannel">
        <Membership className="org.apache.catalina.tribes.membership.McastService"
                    address="228.0.0.4"
                    port="45564"
                    frequency="500"
                    dropTime="3000"/>

        <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
            <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
        </Sender>
            
        <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
                    address="auto"
                    port="4001"
                    autoBind="100"
                    selectorTimeout="5000"
                    maxThreads="6"/>
                    
        <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
        
        <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>
        
    </Channel>
    
    <Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>
    
    <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>
    
    <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>
    
    <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
    
</Cluster>

3. On each jasper server instance, locate the following two files and uncomment the same two sections in each file:

  • web-app>/WEB-INF/ehcache.xml
  • web-app>/WEB-INF/ehcache_hibernate.xml
<cacheManagerPeerProviderFactory
       class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
        properties="peerDiscovery=automatic,multicastGroupAddress=224.0.0.1,multicastGroupPort=4446,timeToLive=1"/>
                   
    <cacheManagerPeerListenerFactory
        class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"
        properties="hostName=localhost,port=40111,remoteObjectPort=40112,socketTimeoutMillis=120000"/>


<cache name=...
            ...>
        <cacheEventListenerFactory
            class="net.sf.ehcache.distribution.RMICacheReplicatorFactory"
            properties="replicateAsynchronously=true, replicatePuts=true, replicateUpdates=true,
                        replicateUpdatesViaCopy=false, replicateRemovals=true"/>
        <bootstrapCacheLoaderFactory
            class="net.sf.ehcache.distribution.RMIBootstrapCacheLoaderFactory"
            properties="bootstrapAsynchronously=true, maximumChunkSizeBytes=5000000"/>
    </cache>

Load Balancer configuration

The following changes configure the Apache HTTP server (httpd) as a load balancer.

1. Locate httpd.conf file in E:\Jaspersoft\Apache2.2\conf
2. Add following line to the end of the httpd.conf file

Include conf/mod-jk.conf

3. Create the following two files in the /conf folder of your httpd server.

4. Create the following two files in the /conf folder of your httpd server.

  • mod_jk.conf
# Load mod_jk module
# Specify the filename of the mod_jk lib
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs and memory
JkLogFile logs/mod_jk.log
JkLogFile logs/mod_jk.shm
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
# JkOptions indicates to send SSK KEY SIZE
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat
JkRequestLogFormat "%w %V %T"
# Mount your applications
#JkMount /* loadbalancer
JkMount /jasperserver-pro loadbalancer
JkMount /jasperserver-pro/* loadbalancer
# You can use external file for mount points.
# It will be checked for updates each 60 seconds.
# The format of the file is: /url=worker
# /examples/*=loadbalancer
#JkMountFile conf/uriworkermap.properties
# Add shared memory.
# This directive is present with 1.2.10 and
# later versions of mod_jk, and is needed for
# for load balancing to work properly
JkShmFile logs/jk.shm
#JkShmFile /var/log/httpd/mod_jk.shm
# Add jkstatus for managing runtime data
<Location /jkstatus>
JkMount status
Order deny,allow
Allow from all
</Location>

  • workers.properties
 # Define list of workers that will be used
# for mapping requests
worker.list=loadbalancer,status
# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=9009
worker.node1.host=localhost
worker.node1.type=ajp13
worker.node1.lbfactor=1
# Define Node2
# modify the host as your host IP or DNS name.
worker.node2.port=9109
worker.node2.host=localhost
worker.node2.type=ajp13
worker.node2.lbfactor=1
# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1,node2
worker.loadbalancer.sticky_session=True
worker.list=loadbalancer
# Status worker for managing load balancer
worker.status.type=status

Working with Virtual Servers on Talend Administration Center (TAC)

 

Working with Virtual Servers on Talend Administration Center (TAC)

Virtual Server Configuration :

A virtual server is a group of physical servers from which the best rated server will automatically get preferred at Job execution time. In Talend Administration Center, simply select physical servers and group them into a virtual server. Then set the execution task onto this virtual server as for any execution server, in order to automatically select the best server to execute the task onto.
Accessing the list of virtual servers
To access the list of virtual servers from Talend Administration Center as well as the execution servers that are assigned accordingly:
In the Menu tree view, expand Conductor and then click Virtual Servers to access the list of virtual servers.

The Virtual servers page is divided into two views:
• The Servers view on the left which regroups the physical servers you have configured in the Servers page. These execution servers can be either JobServers or Talend Runtime servers.
• The Virtual servers on the right which regroups the virtual servers and their assignments.
When you access this list for the first time, the existing physical servers are displayed on the view, but no virtual server is available.
From this page, you can create, edit and delete virtual servers and assign physical servers to them.

Adding a virtual server:

To add a virtual server from the Talend Administration Center home page:
1. From the toolbar on the Virtual servers view of the Virtual servers page, click Add a virtual server to open the [Virtual server] dialog box.

 

Add Virtual Server

 

Note: Cellar cluster: (Optional) Name of the cluster group.
Virtual servers without Cellar (Option 1): the features are deployed on all physical servers that are assigned to the virtual server.
Virtual servers with Cellar (Option 2): the features are deployed on one of the physical servers of the Cellar group that are assigned to the virtual server. Cellar then distributes the features to all runtime containers that have the same group, and ensures failover between servers.

Assigning one or several physical server(s) to a virtual server:

To group various execution servers in one virtual server, read the procedure below.
If you want to add clustered Runtime servers to your virtual servers, you must have previously installed clustered Runtime containers and created cluster groups.
1. On the Virtual servers page, select one or more server(s) in the Job servers view.
2. Drag and drop the selected server(s) onto a virtual server where you want to regroup or add the server(s).

 

select job servers

Failover and Load balance approach:

Failover: Failover redirects requests to alternate servers if the originally requested server is unavailable or too slow.

Load Balance:  Load balancing distributes request processing (work load) across multiple servers

Talend provides an alternate approach to handle this scenario using Talend Administration Center web application.

Load balancing process can be achieved using virtual servers concept and in order to handle this issue we need to configure virtual server as execution server in the task execution section.

execution server list

 

 

In the same way, Failover process can be achieved using ‘On unavailable JobServer’ option in the task execution window.

failover actions

 

This option allows you to decide what action you want to take on the selected task when the server is unavailable during a predetermined period of time (defined in the section called “Adding an execution server”).

Select one of the following from the list:

Wait: if the Job has an unknown status, usually caused by server problems, this option puts the task on hold throughout the period of time during which the server is inaccessible. When the server is accessible again, the task will restore the status it held prior to encountering the problem.

Reset task: if the Job has an unknown status, usually caused by server problems, this option puts the task status back to Ready to run when the predetermined period of time relating to the Job status elapses. However, the Job itself could continue running depending on the initial problem.

– Restart task: if the Job has an unknown status, usually caused by server problems, this option will automatically start the task in its original state when the predetermined period of time relating to the Job status elapses.

Note: The Restart task option is only useful when you are using virtual servers.

 – Recover task: if the Job has an unknown status, usually caused by server problems, this option will automatically recover the Job execution from the last validated checkpoint.

Note: The context parameters used when the task is reset, restarted or recovered, are the same as those used during the last execution

We can test both failover and load balancing process by scheduling multiple jobs on virtual servers or any one of the physical server.

 

Implement Load Balancing in Jaspersoft and Pentaho and Designing a Cluster

Load Balancing in Jaspersoft and Pentaho and Designing a Cluster

 

Load balancing is often done in BI infrastructure to have good scalability and availability. There can be a number of methods of implementing the same, one of the method is by using Load balancer and the BI server (jasper report server or Pentaho Server) can run behind the same. One very important factor to be kept in mind is the versions of the BI server should be the same (either both Community edition or both Enterprise edition). It’s also preferable that the BI suite version number is also the same in both the instances and the configurations are also exactly the same.

Jaspersoft Pentaho Load Balancing

A cluster is a group of server and a properly designed cluster can support many users and organizations, avoid downtime, fail-over, load balancing  and plan for future growth as well. This type of architecture can also take care of any future enhancement. An end user is not aware of this architecture and he will access the same URL.

 

Jaspersoft works on sticky session mechanism i.e. if switching happens from one server to another user sessions are lost.

 

Load Balancer: It’s a hardware or software to spread traffic between the cluster of servers. To an end user he will access the application via the same web URL, the load balancer will gauge the load on the different servers, and thus accordingly will spread the requests so that end user will have the best speed and response time. Its recommended that the Pentaho or the Jaspersoft server hardwares are exactly the same, which can thus lead to more effective work of load balancing by load balancer.

Different algorithms can be used at the time of load balancing like round-robin or load based or anything else.

 

 

Shared repository database:

This is having all the reports, folders, role, user, security and other resources. Whatever operations are done in the repository they are thread-safe, which means many operations can run simultaneously. Also there are internal locks present which prevents conflicting operations.

 

Job Scheduler:

Job scheduler is responsible for accessing and executing jobs at predefined schedule. These job schedulers also have locking mechanish, to make sure that simultaneous triggering dosent happen.

Also all the nodes need to be clock synced.

 

 

Session Management and Failover

Client session information is stored in –memory. After a user logs in or a web services clien’t sends a request with credentials, the session contains the user profile such as organization and role membership for use in enforcing permissions. For browser users, the session also stores information about the state of the web interface, for example the last folder viewed in the repository, the last search term, or the data entered in a wizard…..  In commercial editions with the Ad Hoc Editor and Dashboard Designer, the user session also stores the on-screen state of the report or dashboard that the browser user creates interactively.

 

There are two types of session management which can happen, and each of them handles the failover in a different way

–  Replicated or persistent sessions: Instantaneous session information of the sessions are continuously stored at a shared location. Whenever any failure happens, load balancer automatically redirects to another server node. Since the other server also has access to all the information, this happens seam-lessly without end user experience getting affected.

 

–  Sticky or Pinned session: Here the sessions are managed and accessed by private servers, hence at the time of failure sessions are lost. After load balancer connects to other server, a new session is initiated.

 

 

For more information about Jaspersoft BI suite or Pentaho BI suite, get in touch with us at nikhilesh@helicaltech.com