Sunday, October 28, 2012

Open File Descriptor- Happy Tuning

What is a File Descriptor in Linux?
As per dictionary.com literal meaning of descriptor is an element or term that has the function of describing something specific.
In Linux Operating System a file descriptor stand for an interaction between a process and an opened file, while an open file object has information related to that interaction.
Numerous processes could simultaneously open the same file. In that scenario, the filesystem assigns a separate file descriptor to each file, along with a separate open file object.
Under Linux OS-  fd indicates the file descriptor of the opened file. There is a default limit for maximum number of file descriptors that an individual process could open and in Linux it is 1024.
Kind of less :(
At times this max limit could be a bottle neck for some java apps so we use ulimit to tune it.

ulimit -aS displays the soft limit, and ulimit -aH displays the hard limit

Example:

# su - httpd

# ulimit -Hn

# ulimit -Sn


Tuning Open file descriptor max limits

# echo “fs.file-max=95000″ >> /etc/sysctl.conf

# sysctl –p

 # echo “* hard nofile 95000″ >> /etc/security/limits.conf

# echo “* soft nofile 1024″ >> /etc/security/limits.conf

# echo “session required /lib/security/pam_limits.so” >> /etc/pam.d/login

#ulimit -n unlimited

:) Happy Tuning

Sunday, October 14, 2012

Appdynamics Lite- A free APM

Kind of smitten by Appdynamics Lite, cool features and
it is absolutely free of cost. I just tested Java transactions
for a simple webapp and very much impressed and voila
Appdynamic Lite has a .Net version(Free) as well.
Appdynamic Lite Introduction, it has 2% CPU overhead,
10 MB memory footprint and <5 ms latency for user requests.
 
I need to explore this product more and will share finding.
Watch out for next.
 
 

Thursday, October 11, 2012

Java Thread dump and Heap dump


I found many people in industry assume Java Thread dump and Heap dump as same.

A thread dump is a complete list of Java threads that are presently active in a JVM. This is good for understanding behaviour of a Java application at a given time. Most of the time app developers will request app infra team to get a thread dump for their analysis. (e.g. deadlock).

 

How to take thread dump?

#jstack <pid> >> threaddumps.log

A heap dump is a dump of the Java heap memory. This is useful for analysing what use of memory that Java app is making in JVM, help in diagnosing some memory issues. (e.g. memory leaks)

 

How to take heap dump?

#jmap -dump:format=b pid

 

Oracle JDK on Tata instacompute cloud

Other day I was trying to test the new Iaas cloud offering from Tata Communication- Instacompute.
 After I registered, I launched the cloud console, coming from AWS/Rackspace background I found it quite simple.









I added an UBUNTU10.04 LTS X64 template (kind of old huh!) instance and enabled SSH.
I wanted to deploy a basic java shopping cart app and hit it with Jmeter. But alas there was no
JDK available in the that particular Ubuntu template. I guess instacompute folks have used a strip
down version of Ubuntu. Anyway I used following code to fix the issue.
#add-apt-repository "deb http://archive.canonical.com/ lucid partner"
#apt-get update
#apt-get install oracle-java7-installer
Note that once Oracle JDK 7 installed you don't need to manually perform
update-alternatives, this will be done automatically.


Then I checked the installation 
root@ubuntu:~# java -version

java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)



root@ubuntu:~# jps -l
7639 sun.tools.jps.Jps


My environment looks ready now.