Monday, October 14, 2013

Compile maven project for Java 1.4

I had problem with configuring maven. I want to compile some project to Java 1.4. After some I found following configuration which is really working:

<!--
  Strictly speaking, we did not need to generate this for you from
  the prototype, but we use it to illustrate how you can get
  the JDK 6 Java compiler to accept 1.5 or 1.6 targeted source code
  but produce class files that are compatible with JRE 1.4. As
  Michael Caine might not say, "Not a lot of people know that!"
  -->
<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.0.2</version>
    <configuration>
        <source>1.6</source>
        <target>jsr14</target>
        <sourceDirectory>src</sourceDirectory>
    </configuration>
</plugin>

It's not my idea. I wrote down this example long time ago. Now I can't found place where I originally found it. Sorry.

Wednesday, October 2, 2013

Linux server response times

Before few days I had problem with response times on linux server. I use CentOS. There is apache HTTPD covering about 5 tomcat instances. Inside tomcat instances are 7 different application. Main problem was incredibly slow responses from all pages. When I logged in I seen this:
top - 22:37:01 up 104 days,  7:59,  1 user,  load average: 3.59, 5.09, 3.33
Tasks: 103 total,   1 running, 102 sleeping,   0 stopped,   0 zombie
Cpu(s): 15.7%us,  0.1%sy,  0.0%ni, 84.1%id,  0.1%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1018236k total,   988976k used,    29260k free,     1012k buffers
Swap:  2064344k total,  1031440k used,  1032904k free,    20592k cached

meaning of wa is waiting for I/O to complete. I also tried to order processes in top command by used memory "shift + f" and press n and than Enter. After that I run following:

ps axf show among other following problem:

 5627 ?        Ss     0:03 /usr/sbin/httpd
...
10289 ?        D      0:00  \_ /usr/sbin/httpd

It says that HTTPD is waiting for finishing disk IO operation. After checking memory consumption 988976k + 1031440k was clear that all tomcats eat about 2 Gb of memory and there is only 1 Gb of physical memory.

Than it was simple I just reconfigured all tomcats, so now I have just two. One is for critical application and second one contains all resting applications. And after restart response times are again good.