Skip to main content

Posts

Set Up Nginx Load Balancing

About Load Balancing Loadbalancing is a useful mechanism to distribute incoming traffic around several capable Virtual Private servers. By apportioning the processing mechanism to several machines, redundancy is provided to the application -- ensuring fault tolerance and heightened stability. The Round Robin algorithm for load balancing sends visitors to one of a set of IPs. At its most basic level Round Robin, which is fairly easy to implement, distributes server load without implementing considering more nuanced factors like server response time and the visitors’ geographic region. Setup The steps in this tutorial require the user to have root privileges on your VPS. Prior to setting up nginx loadbalancing, you should have nginx installed on your VPS. You can install it quickly with apt-get: sudo apt-get install nginx Upstream Module In order to set up a round robin load balancer, we will need to use the nginx upstream module. We will incorporate the conf
Recent posts

Tomcat Clustering : Session Replication with Backup Manager

Prerequisite Blogs: How To Install Apache Tomcat Multiple Tomcat Instances on Single Machine Tomcat Clustering: Loadbalancing with mod_jk and Apache Tomcat Clustering : Session Affinity    Backup Manager Backup manager usually used clustered environment. Its like delta manger. But it will  replicate to exactly one other instance(backup instance). Its act  like one instance is Primary  and another instance as backup. Steps to make Session Replication in Tomcat Clustering I am continue from exactly where I left in last session affinity post . So check that post and make sure jumRoute all are set properly. Steps are Enable Multicast routing Add <Cluster> Entries in conf/server.xml file for all instances. Enable the Web Application as distributable Step1:  Enable Multicast routing In Linux Environment most of the system kernel is capable to process the multicast address. We need to add route entry in kernel routing table. sudo route add

Tomcat Clustering : Session Affinity

Session affinity/Sticky Session   Session affinity overrides the load-balancing algorithm by directing all requests in a session to a specific tomcat server. So when we setup the session affinity our problem will solved. But how to setup because session values are random value. We need to generate the session value some how identify the which tomcat generate response. Step 1: Tomcat configuration file (conf/server.xml) contain  <Engine> tag have jvmRoute property for this purpose. So edit the config file and update the <Engine > tag like this <Engine name="Catalina" defaultHost="localhost“ jvmRoute=“tomcat1” > Here tomcat1 is worker name of this tomcat. check the workers.properties file in last post .  Change this line to all tomcat instances  conf/server.xml file and change the jvmRoute value according to workers name and restart the tomcat instances. Now all tomcat generate the session-id pattern like thi

Configuring URL Encoding on Tomcat Application Server

Application servers may have different settings for character encodings. We strongly recommend UTF-8 where possible. By default, Tomcat uses ISO-8859-1 character encoding when decoding URLs received from a browser. This can cause problems when Confluence's encoding is UTF-8, and you are using international characters in the names of attachments or pages. To configure the URL encoding in Tomcat: Step 1 - Configure connector: Edit conf/server.xml and find the line where the Coyote HTTP Connector is defined. It will look something like this, possibly with more parameters: < Connector port = "8080" /> Add a URIEncoding="UTF-8" property to the connector: < Connector port = "8080" protocol = "HTTP/1.1"      connectionTimeout = "20000"      redirectPort = "8443"      URIEncoding = "UTF-8" /> If you are using mod_jk you should appl

Java HotSpot VM Settings

The following JVM parameters are recommended: -Djava.awt.headless=true  -Dfile.encoding=UTF-8  -server  -Xms512m  -Xmx1024m  -XX:NewSize=256m  -XX:MaxNewSize=256m  -XX:PermSize=256m  -XX:MaxPermSize=256m  -XX:+DisableExplicitGC -Djava.awt.headless=true Headless mode is a system configuration in which the display device, keyboard, or mouse is lacking. Sounds unexpected, but actually you can perform different operations in this mode, even with graphic data. -server The JDK includes two flavors of the VM -- a client-side offering, and a VM tuned for server applications. These two solutions share the Java HotSpot runtime environment code base, but use different compilers that are suited to the distinctly unique performance characteristics of clients and servers. These differences include the compilation inlining policy and heap defaults. Although the Server and the Client VMs are similar, the Server VM has been specially tuned to maximize peak opera

JavaMelody: Monitoring the Performance of Tomcat Application Server

Javamelody is an opensource (LGPL) application to monitor Java or Java EE application servers in QA and production environments. JavaMelody is mainly based on statistics of requests and on evolution charts. (Extract from the Javamelody home page) It allows to improve applications in QA and production Give facts about the average response times and number of executions Make decisions when trends are bad, before problems become too serious Optimize based on the more limiting response times Find the root causes of response times Verify the real improvement after optimization It includes summary charts showing the evolution over time of the following indicators: Number of executions, mean execution times and percentage of errors of http requests, sql requests, jsp pages or methods of business façades (if EJB3, Spring or Guice) Java memory Java CPU Number of user sessions Number of jdbc connections These charts can be viewed on the current day, week, month, year or cu

Tomcat Clustering: Loadbalancing with mod_jk and Apache

We already see how to run multiple tomcat instance in a single machine in my previous blog ( http://kmlsarwar.blogspot.com/2014/08/multiple-tomcat-instances-on-single.html ). In this post we will see how to configure load balancing with mod_jk and Apache on Ubuntu. Suppose we have two hosts, node1 and node2 . Node1 runs an Apache and a Tomcat instance. On node2 we’ve got another Tomcat. A browser will connect to the host that’s running the Apache. Since the load on a single server running a web application can be pretty severe, we’re going to share the burden of serving servlets with multiple hosts (in our case two hosts). And we’re going to make mod_jk to do that for us. Steps to Implement Virtual Host/Loadbalancer Concept in this Scenario: Install Apache httpd Web Server  Install mod_jk connector  Configure JK Connector  Configure Apache httpd server, apply loadbalancer concepts Step One—Install Apache We can install Apache web server in two way