≡ Menu

DevOps

Docker is changing – scratch that – Docker has changed the way applications are built, deployed and run. If you are completely new to Docker, I recommend reading my other post: What is Docker? An absolute beginner’s guide. There, in addition to explaining what Docker is, I walk you through how to create a docker container and run your application in it. In this post, let’s take a step further by creating a distributed service using Docker. In other words, let’s make Docker production-ready. You’ll learn the following

  1. What is docker-compose and how to create your first docker-compose.yml ?
  2. What is a docker swarm and how it provides a robust, scalable container platform ?
  3. How to create a docker swarm and deploy your application in it ?
  4. A working example along the way – end-to-end.

Sounds good ? Let’s jump.

swarm

Read More

What you didn’t know about java.lang.OutOfMemory Error!

Few errors are deadlier than java.lang.OutOfMemory errors. When this happens, you application will run into a very unpredictable state, often hanging up and not processing new requests, coughing up ugly stack traces into users browsers etc. The most popular (and effective in the short run) fix for OutOfMemory error is simply restarting the Application or Application Server.

While running out of java Heap is the most common OutOfMemory error, there are indeed several types of OutOfMemory that can occur. In this post, I will show you these various types of OutOfMemory errors and what they mean.

java.lang.OutOfMemoryError: Java heap space

The most popular one. This is when JVM goes belly up and unable to allocate memory in Heap . Your application might appear hung up and extremely slow to respond to user requests.

For example, let’s say your Java application has 2GB of memory maximum (through -Xmx flag). When the entire 2GB is used up and GC is unable to reclaim any memory, the next memory allocation request for an object will fail with java.lang.OutOfMemory Error.

What causes java.lang.OutOfMemoryError: Java heap space ?

Read More

How to install Docker on Linux?

Are your ready to taste the awesome power of Docker? I hope you are. Because once you get your feet wet in Docker, you will be unstoppable :-). In this blog post, I want to quickly show you how you can install Docker on RedHat Enterprise Linux. The procedure should be similar in other flavors.

  1. First, login as root into your system. If you don’t have root access, you should at least have sudo access to root.
  2. Create a docker repository file as follows
    • Use your favorite text editor to create a file named /etc/yum.repos.d/docker.repo
    • Add the following contents
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

Read More

How to enable colors in shell and vi in Mac?

When working with shells, if your Mac does not show various colors automatically, you can enable them by two easy steps.

First add a line as shown below to your .bash_profile. This file should be under your home directory.

export CLICOLOR=1

Second, add the following line in your .vimrc file. This file should be under your home directory. If it is not there, create one.

Read More

10 Windows Tricks every Java Developer should know

While Unix/Linux is the most popular OS for hosting enterprise java applications, there are still significant amount of applications deployed on Windows Platform. If your application is running on a Windows box, you ought to know how to get around Windows in order to support your application effectively.

In this piece, I’m going to share with you 10 tricks every Java Developer should know. I tested these in Windows 2008 R2. But it should work on most Windows flavors. Let’s get right to it.

1. Find the full command line of your java application

In Unix/Linux, if you need to see the full command line of your application, you can simply use ‘ps –ef’. For example,
ps –ef | grep <my application>
Alas! There is no ‘ps’ in windows. So, how do you do this? Say hello to Windows Task Manager.

Read More

Various JVM flavors and why do you care?

Oracle Hotspot, IBM SDK, HP NonStop Server for Java, Jrockit…. Why so many flavors of JVM? And more importantly, why do you care ?

While it is Sun/Oracle that originally created the Java Virtual Machine, since JVM is basically a set of specifications, any vendor could create their own version of JVM. Several vendors jumped in to create their spin offs. Some are free and open source but some are proprietary. The following JVMs are prominent in the market today

IBM

HP

Sun/Oracle Hotspot

BEA/Oracle Jrockit

OpenJDK

In addition to the above, Apple has their own spin off that is used in MAC.

Sun/Oracle HotSpot is still the market leader (about 60%). Oh, by the way, you will be surprised to know that there are more than 30 JVMs out there. Did you know apache had its own JVM (Apache harmony) ?

Why do you care which JVM is being used?

As an Application Support Engineer, you have to care about the flavor of the JVM for four major reasons

Read More

Where does JVM fit in a JEE Application Server?

In a JEE Application Server such Oracle WebLogic or IBM WebSphere, where exactly does JVM fit in?

In short, each instance of a JEE Application server runs as a JVM that executes one or more JEE Applications deployed. In other words, Application Server is yet another java application (a big one) that executes custom developed JEE Applications.

Earlier we saw how a JVM can be started by using the ‘java’ command and passing the class name as the parameter

java HelloWorld

In a JEE Application Server’s case, it will be something like this:

java –classpath /opt/jboss-as/bin/run.jar com.jboss.Main

The above example starts a Jboss Application Server. Note that there will be several additional Java command line parameters in real world.

Let us understand what a JEE Application Server really is.

Read More

JVM – Basic Operations

A Java application is launched with the java command which starts a JVM and runs the application. As an Application support engineer, there are few basic operations that you will typically perform on the JVM. Here are they:

Starting JVM:

Starting the JVM simply means starting the Java application. A Java application is started using the java command.

For example:

java HelloWorld 

java is the command

HelloWorld is the classfile without the .class extension

Note: Don’t use the .class extension in the java command. If you do, you will get an error

[ec2-user@java]$ java HelloWorld.class
 
Error: Could not find or load main class HelloWorld.class

There are numerous command line options for the java command. Here are some of the main ones you need to know.

Read More

What is Virtualization?

Virtualization is a technique using which you can run multiple Operating Systems (aka Guest) in a physical server (host) by abstracting (or virtualizing) CPU, Memory, Disk and Network resources. The core component of any virtualization solution is Hypervisor – the software that performs the abstraction of bare metal resources.

Here are the primary benefits of using Virtualization:

  1. Save cost on hardware
  2. Centrally manage the infrastructure
  3. Add effective fault tolerance and high availability
  4. Dynamically update the infrastructure

The diagram below shows virtualization at a high level.

Read More

In this part, let’s explore AppDynamics facilities for diagnosing Memory Leaks. AppDynamics provides two powerful tools to hunt down memory leaks.

  1. Automatic Leak Detection
  2. Objet Instance Tracking

Automatic Leak Detection

With Automatic Leak Detection enabled, Appdyanmics can capture objects that live longer than usual period – i.e long lived Collection objects that simply won’t get garbage collected. If your application is leaking memory, it is definitely one of these long-living, never-dying objects that cause the leak. Use the following procedure to make use of this tool.

Read More