Pitfalls of Handling Large String Objects in Java

Most Java developers know to be careful about String concatenation. But some argue that it is less important nowadays with improved JVM garbage collection efficiency. That might be true for small objects, but for large String objects, which is common when dealing with web services and xmls, developers need to be even more careful with String operations in general, and not just concatenation.

OOM in Production, Why?


I recently looked into an OutOfMemory exception in production and the culprit turned out to be the following code.


Log4j Behaviour in Tomcat and WebSphere

Logging is the interface between developers and system admin. Developers need to know how their logging code behave in a server envrionment. Admins need to know how to configure and turn on/off logging. This series inspects how two most common logging methods, Java Util Logging and Log4j, behave in Tomcat and WebSphere.

Java Util Logging Behaviour in WebSphere

Logging is the interface between developers and system admin. Developers need to know how their logging code behave in a server envrionment. Admins need to know how to configure and turn on/off logging. This series inspects how two most common logging methods, Java Util Logging and Log4j, behave in Tomcat and WebSphere.

Java Util Logging Behaviour in Tomcat

Logging is the interface between developers and system admin. Developers need to know how their logging code behave in a server envrionment. Admins need to know how to configure and turn on/off logging. This series inspects how two most common logging methods, Java Util Logging and Log4j, behave in Tomcat and WebSphere.

Java Util Logging and Log4j Behaviour in Tomcat and WebSphere

Logging is the interface between developers and system admin. Developers need to know how their logging code behave in a server envrionment. Admins need to know how to read logging.properties and log4j.properties, configure them and turn on/off logging. This series inspects how two most common logging methods, Java Util Logging and Log4j, behave in Tomcat and WebSphere.

Step-by-Step : How logging caused big performance problem for a JAX-WS web service

This article is about how a small piece of code can cause big performance trouble and how hard it is to figure out the root cause.


What's the Number 1 Java Coding Best Practice?

There are some common known Java coding best practices: use StringBuffer for string concatenation, don't create large objects, cache expensive objects such as DateFormatter, etc.. How important are they? How much performance can you improve by following these practices? 5%, 10%, or 20%?

Then, even the most dilligent developers can not claim that they follow all the best practices all the time, especially with so many 'new' frameworks and standards being adopted. Could you have missed anything?

Tutorial : Building EJB3 Stateless Session Bean and JAX-WS web service In One Class Using RAD 7.5 - Developing JAX-WS Client

This series is about building an empty shell application that contains an EJB3 stateless session bean, a JAX-WS web service, and a web application that acts as the EJB and web service clients. I personally built it for performance testing purpose; so I can plug-in "in-doubt" java code to oberve how they handle concurrency in a server environment. But this will serve as a tutorial for those who are interested.

Part 1 : Project Setup
Part 2 : EJB3 and JAX-WS Implementation
Part 3 : Develop EJB3 client
Part 4 : Develop JAX-WS client

Tutorial : Building EJB3 Stateless Session Bean and JAX-WS web service In One Class Using RAD 7.5 - Developing EJB3 Client

This series is about building an empty shell application that contains an EJB3 stateless session bean, a JAX-WS web service, and a web application that acts as the EJB and web service clients. I personally built it for performance testing purpose; so I can plug-in "in-doubt" java code to oberve how they handle concurrency in a server environment. But this will serve as a tutorial for those who are interested.

Part 1 : Project Setup
Part 2 : EJB3 and JAX-WS Implementation
Part 3 : Develop EJB3 client
Part 4 : Develop JAX-WS client


Client Web Project Setup

I will create a web project to host servlets that will call the EJB3 Stateless Session Bean and the JAX-WS web service.

From Java EE perspective, Click New -> Dynamic Web Project.

Tutorial : Building EJB3 Stateless Session Bean and JAX-WS web service In One Class Using RAD 7.5 - Implementation

This series is about building an empty shell application that contains an EJB3 stateless session bean, a JAX-WS web service, and a web application that acts as the EJB and web service clients. I personally built it for performance testing purpose; so I can plug-in "in-doubt" java code to oberve how they handle concurrency in a server environment. But this will serve as a tutorial for those who are interested.

Part 1 : Project Setup
Part 2 : EJB3 and JAX-WS Implementation
Part 3 : Develop EJB3 client
Part 4 : Develop JAX-WS client


Implement the Interface. 

Before we make changes to it, here is the generated class.

package
com.appinf;

import javax.ejb.Remote;
@Remote
public
        interface TestHarnessRemote {
}

Tutorial : Building EJB3 Stateless Session Bean and JAX-WS web service In One Class Using RAD 7.5 - Project Setup

This series is about building an empty shell application that contains an EJB3 stateless session bean, a JAX-WS web service, and a web application that acts as the EJB and web service clients. I personally built it for performance testing purpose; so I can plug-in "in-doubt" java code to oberve how they handle concurrency in a server environment. But this will serve as a tutorial for those who are interested.

Part 1 : Project Setup
Part 2 : EJB3 and JAX-WS Implementation
Part 3 : Develop EJB3 client
Part 4 : Develop JAX-WS client



Keep Connections Alive : Browser - Load Balancer - Web Server - mod jk - Tomcat : Part 4

This series is about how connections are kept alive between different components along the route.
 Browser - Load Balancer - Web Server - mod jk - Tomcat 

Part 1 : Browser - Load Balancer.
Part 2 : Load Balancer - Apache HTTP Server
Part 3 : Apache HTTP Server - Mod jk
Part 4 : Mod jk - Tomcat

Keep Connections Alive : Browser - Load Balancer - Web Server - mod jk - Tomcat : Part 3


This series is about how connections are kept alive between different components along the route.
 Browser - Load Balancer - Web Server - mod jk - Tomcat

Part 1 : Browser - Load Balancer.
Part 2 : Load Balancer - Apache HTTP Server
Part 3 : Apache HTTP Server - Mod jk
Part 4 : Mod jk - Tomcat

Apache Web Server - Mod jk


Does mod_jk changes how Apache web server handles its connection with the clients?

Mod jk is a module that runs within the Apache web server. Apache web server will manage the connections between itself and the clients, usually web browsers or a load balancer, and pass the request to a chain of modules.

Using the example described in an Apache module tutorial, a module will register a hook with the web server and the web server will pass a request_rec to the module.

Keep Connections Alive : Browser - Load Balancer - Web Server - mod jk - Tomcat : Part 2

 

This series is about how connections are kept alive between different components along the route.
 Browser - Load Balancer - Web Server - mod jk - Tomcat 

Part 1 : Browser - Load Balancer.
Part 2 : Load Balancer - Apache HTTP Server
Part 3 : Apache HTTP Server - Mod jk
Part 4 : Mod jk - Tomcat

Load Balancer -> Apache Web Server


How is the connection between web server and load balancer maintained? 

There is usually a seperate load balancer TCP profile for the connection between load balancer and the web servers. As described here, the default "Idle Timeout" is 5 minutes and default "Keep Alive Interval" is 30 minutes.

When a request comes in for a page that takes a long time to render, a connection is established between the load balancer and the web server and can be observed by the netstat command. 

> netstat -an | grep :81 |grep EST
tcp  0  0 ::ffff:111.111.111.11:81    ::ffff:111.111.111.12:55789  ESTABLISHED

After 5 minutes, netstat will show that the connection is gone, dropped by the load balancer even if the request is still being processed by downstream servers. So doesn't Apache web server send keep alive signals to the load balancer to maintain the connection, just as Google Chrome does? The answer is no.

Keep Connections Alive : Browser - Load Balancer - Web Server - mod jk - Tomcat : Part 1

This series is about how connections are kept alive between different components along the route.
 Browser - Load Balancer - Web Server - mod jk - Tomcat

Part 1 : Browser - Load Balancer.
Part 2 : Load Balancer - Apache HTTP Server
Part 3 : Apache HTTP Server - Mod jk
Part 4 : Mod jk - Tomcat