Design pattern to scale relational database horizontally

Database scalability is one of the critical factor in designing scalable web application. All the four major cloud vendors (Amazon, Microsoft, Google and Oracle) offers relational database as service which abstracts several complexities for developers to setup and manage database servers that helps developers focus on core application development. Even with cloud vendors’ service based offering scaling database horizontally (or scale out) still a challenge which developers can resolve at application level. In this post I would like to talk about the challenges and possible solution for same.

Read more of this post

Monitoring HttpSession memory leak during JavaEE development

In my previous post I have provided a sample servlet filter to monitor non-serializable objects in HttpSession to make the JavaEE application compatible for clustered environment. We have enhanced the same servlet filter to log HttpSession object size which is helping us to find the memory leak during the development.

Here is the Java code
Read more of this post

Java: Sample Active Directory authentication code

Here is a sample Java code to authenticate against Windows Active Directory server.

  • The code finds all available active directory servers in your network.
  • It uses one of the available active directory server for authentication.
  • If an active directory server is down then it starts using next available server if any.
  • This class is thread-safe, you can create one instance and re-use them multiple times.
  • I tested this code from Linux and Windows box.

You can find the below source code in GitHub as well.
Read more of this post

JavaEE – Clustering support in JSF, Wicket, ZK, etc.

When a seasoned MVC framework developer starts writing code in component based framework like JSF, Wicket, ZK, etc. they fail to understand the basic differences between MVC and component based framework because they could write code which can work in non-clustered environment i.e. in single JVM deployment. When the same application is deployed in a clustered environment they start realizing the difference which will require lots of effort revisit all the code and make it compatible for clustering. I am going to talk about a few guidelines on making development (on top of component based framework ) cluster aware.
Read more of this post

Capture Heap dump from Tomcat Windows Service

Add the following options into Tomcat >> Java >> Java Options

  • Goto JAVA_HOME/bin directory and launch jconsole.exe application
  • In the remote process box enter localhost:8086 and click Connect button
  • Switch to the MBeans tab
  • select – HotSpotDiagnostic – Operations – dumpHeap in the tree on the left
  • Pressing the dumpHeap button creates the heap dump. The parameter called p0 allows you to specify into which target file the heap is dumped.

Alternative to JPA / Hibernate

Ours is a legacy application, we are migrating from desktop to JavaEE web based application. Since it is desktop application database triggers, functions and procedures are heavy used to do lots important functionality. Some of our team members were proposing JPA to move trigger, function and procedure logic to Java layer but many of us (including me) felt is too risky for our business, time to market and lots of data needs to be migrated.

I started looking for a simple alternative framework for JPA which can help us to retain database objects at the same time simplify our Java code like JPA . Here are my findings Read more of this post

Java vs. JavaScript coding

In today’s web programming many Java developers write JavaScript coding hence they tend to follow Java best practice and coding style in JavaScript as well. But there is huge amount of difference in both the coding style and best practices.

Read more of this post