≡ Menu

Linux

The most important JVM memory tuning parameter- and how to ace it.

One of the deadliest errors you can encounter in your Java application is ‘OutOfMemory’ error. The impact this error can have in your application and your business can be enormous. I have seen organizations spend countless hours struggling to fix this error while continuing to have degraded end-user experience (a sure-fire way to lose credibility). One company was actually restarting their application every three hours just to avoid an ugly hang due to OOM. How sad?

In this article, I would like to point out the most important tuning parameter in your Java application. If you get this wrong, no matter how much tuning you put in, you will end up with an OOM sooner or later. Note that there are tons of tuning parameters available to tune the memory. Most of these may not have any effect at all, and some have game-changing effect. The parameter I’m about to reveal is of later kind and the mother of all parameters. This should be the first parameter you should be analyzing to zero-in.

Without further due, here it is.

Read More

Video – Important things you need to know about shellshock

Download Free Poster – Important Java command line options

Hi all !

I have put together a one page poster showing the important Java command line options. Download it, print it and stick it in your cube. It will come in handy.

Enjoy !!

PS: It may take about 30 seconds to load

java_options

 

 

 

How to determine if my Unix Hardware is 64 bit ?

Use the following commands to determine the Hardware Architecture

AIX

bootinfo -y

SOLARIS

isainfo -vk

HP-UX

getconf HW_CPU_SUPP_BITS

or

getconf HW_32_64_CAPABLE

If the above command returns 1, hardware supports both 32 and 64 bit binaries

LINUX

grep flags /proc/cpuinfo

If the output of the above command contains the string “lm”, Hardware is 64 bit.

Example:

grep flags /proc/cpuinfo

flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht

tm pbe nx lm constant_tsc pni monitor ds_cpl est cid cx16 xtpr lahf_lm

Note: 64 bit capable Hardware does not mean your OS is 64 bit. Generally, for backward compatibility, 64 bit capable Hardware can run 32 bit Software.

Very simple.

Add “–color” to your command

Example:

grep –color localhost /etc/hosts

127.0.0.1               loopback localhost   # loopback (lo0) name/address

 

The string “localhost” will appear in RED.

Note:

1. You need GNU ‘grep’ for this to work

2. Don’t use “GREP_OPTIONS” environment variable in your shell startup scripts to accomplish this. It can break several scripts.

More information can be found in this link: http://www.gnu.org/software/grep/manual/grep.html#Environment-Variables

You can greatly increase your productivity and efficiency as a Middleware Administrator when you master just a very few critical Unix/Linux commands.

Here are 10 awesome Unix/Linux commands you should master if your infrastructure is unix based.

1. ps -ef

How can this command help me ?

“ps -ef” shows *all* the processes running on your System. It shows good information such as process id, the user running the program, the command line being used to run the program etc. When coupled with grep (ps -ef | grep <my application>), this command can instantly show you whether your application is alive or not.

Example:

karun.subramanian>ps -ef | grep bash

karun.su 5956 9796 pty0 14:06:32 /usr/bin/bash

karun.su 5740 5956 pty0 14:30:49 /usr/bin/bash

karun.subramanian>

 2. netstat

How can this command help me ?

netstat shows information about the network sockets. It can be extremely useful as it can instantly show the network activity of your application server.

Example:

netstat -an

-a: Displays all connections and listen ports

-n: Displays numerical IP instead of host names (without this flag, the server will try to resolve the IP to host name and this can be slow)

One powerful option is “-p” where the output will show the process id associated with the socket. For example, if you want to find out which process is using port 8088, you would run the following command

netstat -anp | grep 8088

3. df -k

How can this command help me ?

Shows all the File Systems and their usage in Kilo Bytes. Useful when dealing with ‘File System’ capacity issues.

Example:

df -k

Note: Another useful command when dealing with disk space usage is ‘du‘. I regularly use the command “du -sk *” to find out which directories are reponsible for disk space utilization.

4. traceroute

How can this command help me ?

Shows the network path being taken to reach the given server. Can be useful to find out the network devices present enroute to the destination server.

Example:

traceroute <my host>

5. tcpdump

How can this command help me ?

Captures network packets for analysis. Can be handy to troubleshoot ssl handshake issues, connection resets or connection failure type issues. The output of this command can be analyzed using tools like Microsoft Network Monitor or Wireshark

Example:

tcpdump host <myserver> -w <output file>

6. vmstat

How can this command help me ?

There was a time where I could just glimpse the output of vmstat and tell what’s the problem with the system. vmstat (virtual memory statistics) shows critical Server performance info such as CPU runqueue, Memory pages scan rate, IO waits etc

Example:

vmstat 2 20

(Take vmstat at 2 seconds interval for 20 minutes.)

7. find

How can this command help me ?

Find is a powerful command to search File system for files/directories.

Example:

find .     – Displays all the files and directories from the current directory onwards (traverses sub directories)

find /mydir -name “*.dmp”     – Displays all the files and directories whose names end with “.mp” under /mydir

8. kill

How can this command help me ?

Terminates processes. For example, when the Application Server does not respond to the usual shutdown commands, you will have to terminate it forcefully and ‘kill’ is the command you would need.

Example:

kill -9 <process id>

-9 will forcefully terminate the process – it is ugly but sometimes you will have to do this.

9. top

How can this command help me ?

Extremely useful performance monitoring tool. ‘topas’ in IBM AIX. For example, if you want to find out if you are running out of CPU or Memory, you would launch top.

Example:

top

10. vi

How can this command help me ?

Either you love it or hate it. The truth is ‘vi’ is a very versatile text editor –  once you learn few basic things, and with some practice, vI will become second nature to you.

Examples:

vi

Esc i  – Start typing text

Esc k – Move cursor one line down

Esc j – Move cursor one line up

Esc l – Move cursor one character right

Esc h – Move cursor on character left

(Note: Esc key toggles between input mode and command mode)

Esc :wq  – Save and exit

Esc : q!  –  Exit without saving

There you have it. While Unix commands are numerous and their switches/options are countless, mastering just above commands will take you a long way.

To learn more about these commands, use the man page:

man <command>

Enjoy