Tuesday, December 13, 2011

Changing the Apache Installation directory in Linux

I am sure there are numerous posts online on how to install Apache in Linux Systems. Almost every post has the detailed steps listed out on how to go about. The basic steps are ./configure, make and make install. But what if there is already a different version of Apache installed in the default location. Then your installation goes for a Toss. Next the question arises "How to install Apache in a different location?". I was in a similar situation sometime ago. I searched online for answers. Almost all posts were inclined towards installation of Apache on Linux but none of them were concentrated on how one can change default installation directory of Apache. I opened the Apache Documentation and then found the solution. So I thought I will write a simple post on how to change the default installation directory so that it will save the user's time which is required to hunt down the solution in Apache documentation.

Well.. this is extremely simple. After downloading the tar.gz file from http://httpd.apache.org/download.cgi#apache22 location, unzip the file using tar -xvf <filename>.tar.gz command. Go inside the unzipped directory and type ./configure --prefix=<directory where apache should be installed>. For example, if you want to install Apache in the etc folder then the command will be ./configure --prefix=/etc/apache2 where Apache will be installed in the above location instead of the usual one. The remaining steps are the same. More details can be found by using the help command ie: ./configure --help.

Hope this post was helpful for some newbies who have started playing around with Apache.

Thursday, November 24, 2011

Measuring Performance in ColdFusion

   Performance is one of the most important criteria for any product or application. If the performance of the Application is low then it is not going to be useful. In this blog post I will discuss the different metrics involved in measuring performance, how to write a test case which will measure the performance accurately and the steps taken to measure ColdFusion performance.

Metrics involved in measuring Performance:

In ColdFusion we mainly concentrate on LOAD testing. There are three main parameters when it comes to LOAD testing. They are:

     1. Performance
     2. Stress
     3. Reliability

When we measure performance then we consider "TIME" taken to execute a test case as the most important factor. In other words the Average Response Time(ART) must be less with a greater throughput(no of requests processed per second).

When we measure Stress, then we are no longer interested in measuring the time taken except that it must be constant. The factors which are of at most importance are:
    a. There should be no exceptions/data loss or crash
    b. The tests should be run with a large number of users.
    c. Here we measure the maximum capacity of the product or tool. In other words, we measure the   maximum limit of the tool. For example, if we are interested in measuring the stress of ColdFusion then we increase the number of users till the point ColdFusion server hangs or stops responding. This is done so that the maximum limit of the product is known.

When we measure Reliability, then we run the tests for a longer period of time with constant users. Here, we are more concerned to see if the throughput is constant and no memory leaks are happening. It is generally run for 2 days.

Steps taken before writing a performance test case:

To write a test case for measuring performance we must adhere to the below rules. They are:
1. The CPU Usage for executing a test case should be around 60% for 10 Virtual users.
2. The xmx and xms value should be high so that the major and minor collections can be avoided. It should preferably be 1024.
3. The ART(Average Response Time) should be around 70-100 milli seconds for a single user or else the Jmeter results will not be reliable.

h3. Steps to be performed before running performance tests:

1. JRE should be the same(ie 64-bit/32-bit) on both machines(the two version which have to be compared). The preferred should be Server JDK since it is faster. The JRE used can be seen in the Administrator under "Settings Summary".
2. The different Admin Settings are:
     a. In Request Tuning -> Maximum number of simultaneous Template requests should be 50 with the remaining set to 1
     b. In caching -> Trusted Cache should be ticked/enabled.
     c. In Debugging & Logging -> Debug Output Settings: the debugging should be turned off.
     d. Ensure that no monitoring services are running
3. In the jvm.config in java.args change the xmx and xms value to 1024. Check for -server in the java args. The -Xbatch should be removed. The -Djava.security.manager should be removed. The disableJSafe option should be set to true.
4. Restart the server.
5. Run the test case few times on the browser for Initial warmup.
6. Launch Jmeter. Specify the required details such as no of users, server, path to test case etc.
7. Run the test case through Jmeter. Stop after 10 seconds.
8. Rerun the test case again for 5 minutes.
9. Record the throughput and ART. Repeat this process 3 times for getting a reasonable consistent reading.



Sunday, October 2, 2011

Creating Virtual Hosts in Apache

I am sure most of what I am writing is available on the Apache Documentation but posting this so that it will be helpful for Users to configure Simple Virtual Hosts easily and faster. 

To start with "What is a VIRTUAL HOST"??
It is a method of Hosting multiple domain names on a server using a Single IP address. This allows sharing of resources of one server such as memory, processor cycles etc which lead to efficient utilization of the resources increasing the efficiency.

Now all of us know Apache is the HTTP Web Server which stores and maintains large number of Websites, It is designed to achieve a very high performance. To configure Virtual Host in Apache is very simple. It involves performing a few steps:

1.Firstly, Install the new Apache Web Server from the http://httpd.apache.org/ site. The downloads for all the OS are available.

2.After installation the Apache will be present in the following directory by default in case of Windows:  "C:\Program Files\Apache Software Foundation\Apache2.X" or "C:\Program Files (x86)\Apache Software Foundation\Apache2.X" in case if 64-bit machines.The httpd.conf file is present under the "conf" folder.
To create Virtual hosts define the following entries in the httpd.conf file which is present under "C:\Program Files\Apache Software Foundation\Apache2.X\conf" directory.

3.Open the file.In the beginning of the file there will be an entry to Listen on a particular port. By default the port is 80.
To create Virtual Hosts which run on port 81 and 82, include the lines after the Listen 80 line ie:            
    Listen 80 
    Listen 81                
    Listen 82
4.Now go to the bottom of the file and search for the entry:
         # Virtual hosts
         #Include conf/extra/httpd-vhosts.conf
5.Add the following under the entry:
          NameVirtualHost *:81
          NameVirtualHost *:82

         <VirtualHost *:81>
         DocumentRoot "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs1"
         ServerName www.example1.com

         # Other directives here


         <VirtualHost *:82>
        DocumentRoot "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs2"
        ServerName www.example2.org

        # Other directives here

    Note: The directory htdocs1 and htdocs2 should be created.
 6.Edit the hosts file located under the System32/drivers/etc/ directory. Add the two entries:
           <ip_address of the machine> www.example1.com         
           <ip_address of the machine> www.example2.com

 7.Save the file and close it. restart the Apache Web server either from Services or console.
 Access the link : http://www.example1.com:81/. It should redirect the control to the htdocs1 directory.Place few files in this directory. It must be served.
 Similary, accessing http://www.example2.com:82/ should be redirected to htdocs2 directory. To access the htdocs folder http://localhost:80/ will do.

Thus, We have setup a dedicated Virtual Host setup in Apache. 

Thursday, September 22, 2011

Caching in ColdFusion-Brief Overview

Well... Am sure most of us will be aware of what a Cache does.It is nothing but a component that temporarily stores data so that it can be referenced when future requests to the same data are made at a faster rate. Thus, it saves the time required to access the data from the disk or any other location improving the efficiency. The various advantages of caching are:

1. Enables accessing of the data at a faster rate.
2. Improves performance
3. In case of Web based applications, caching reduces the load on the Web server or Application server.
4. Increases reliability.(If the main server goes down, then data can be retrieved from the cache or vice-versa)

Adobe ColdFusion is an application server which enables developers to build, deploy and maintain large Internet based applications which store large amount of data. Since large amount of data transactions will be carried out, caching is a very important requirement. In case of ColdFusion a Web cache sits in between one ore more Web servers and one or more clients. This Web cache stores the data and can be accessed when the request for that data is made. This avoids the call to the Web Server to fetch the data thus reducing Latency. As the data is reused it reduces the representations used by the client which reduces the amount of bandwidth used by the client.  This lowers Network Traffic. Since the load is borne both by the Web cache and the Web Server's Database or the App server's database, the memory is efficiently managed which reduces the Garbage collection and the load is efficiently distributed. This makes the data more reliable since data is present in both the places and if server goes down data can still be retrieved from the cache.


We all know that ColdFusion makes use of ehcahe as the cache provider for caching data. By default, the ehcache is stored within the CF address space. The different Caching architectures which are used are:

  1. In-Process Architecture : Operates in the same JVM as the application server. It has limited scalability for 32-bit systems as memory constraint must be considered. The data access is faster in this architecture as data/object serialization is not required.                                                                                             
  2. Out-of-Process Architecture : Operates in its own process outside the application server's JVM. It is highly scalable on both 32-bit and 64-bit platforms. It is generally slower than In-Process architecture as data/objects must be serialized/deserialized. 

The different types of Cache regions present in ColdFusion by default are:
  1.     Object Cache: It is the most flexible way to cache data. it can cache anything put in a ColdFusion variable.It has granular control over cache functions.It has access to the various cache item meta data such as cache_hitcount,cache_misscount,hitcount,idletime etc. It uses ehcache as cache provider.
  2.     Template Cache :  It can be used to cache a whole page by placing a <cfcache> tag at the top for the page. It can cache page fragments by placing the <cfcache> tag in between pages which have to be cached. It is useful when part of the page should be dynamic. It uses ehcache as cache provider
ColdFusion had caching in the <cfquery> tags in the previous versions. Query cache does not use ehcache as cache provider. In version 9, there were many enhancements added. Some of them were:
  1. Disk based and Memory based Caching
  2. Cfcache to use ehcache as default cache provider. This ehcache.xml is present under     <coldfusion_home>/lib directory
  3. Caching Page Fragements
  4. Introduced new functions such as
    Refer to http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec1b05d- 7fe1.html for detailed explanation.
 5. New attributes are added to the <cfcache> tag . Refer
http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d5a.html for detailed explanation.