elysch
elysch

Reputation: 1976

Why does one Java process on Linux is working at the same speed as when starte twice?

I have a Java Soap Client that send some xml files to a remote server to be processed.

It uses java 1.7's java.nio.file.WatchEvent<Path> (almost just like it's explained here) to monitor new files added to a directory.

It is processing about 2 or 3 files per minute.

Looking for a way to increase the speed of files sent and processed I decided to start the same jar twice, monitoring different directories of course.

I can't explain why both processes are still processing about 2 or 3 files per minute. I doubt the problem is in the remote server, since I have a log showing the moment when each file begins and ends it's processing, and it shows almost the same behavior when using only one linux process than when using two.

Any ideas about why is this happening?

P.S.1 Don't know exactly what information should I add here. Feel free to ask.

P.S.2 The server is a virtual one and is using:

java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) Server VM (build 23.3-b01, mixed mode)

Thnx.

Update 1

I mean the total throughput is the same when using only one linux process than when using two.

Update 2

 vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 5  0      0 1716872      0      0    0    0  1874  1960    0    6 17  7 74  2  0

Update 3

Ok, there should be a bottleneck somewhere other than cpu.

Any suggestions on what tool or tools should I use to find it? (Remember, it's a Java application)

Upvotes: 3

Views: 136

Answers (1)

ash
ash

Reputation: 5165

Divide-and-conquer is the best approach to solving this question.

For example, create one process that only finds the files and prints that it has found each, then measure the rate at which that runs. If it's slow, then the inbound file scanning is the slow point - whether that's due to the speed at which files are added, filesystem slowness, or other needing to then be diagnosed.

Create a second process that continually performs the file processing using some fixed content. Record when the processing stops and starts.

Once you have the smallest code that reproduces the problem, you'll have a much better idea where to find the source of the slowness.

Upvotes: 1

Related Questions