Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

threading issue using java?

Posted on 2013-06-03
3
Medium Priority
?
530 Views
Last Modified: 2013-06-10
We have a java application that' running in a linux centos.

I think there's a java app design flaw - I've allocated 2 CPU and 4 CPU and the Java application seems to only consume a weight of 10 queries per second and it will bog down. This means it doesn't matter how much memory and cpu I allocate - it will slow down as the algorithm can't take it.

Fact.
1. I have 2 cpu allocated and each one is utilizing 50%  => the Java  app was at 100% when watching TOP (linux)
2.  I have 4 cpu allocated and each one is utilizing 25%  => the Java  app was at 100% when watching TOP (linux)

http://snag.gy/4YHBZ.jpg


The link shows 4 CPU but the java application could not utilized all 4 CPU with 100% each? I don't have the source code but would like to inquire from the experts on how do you think this is and how can we have each core to utilize 100%?
0
Comment
Question by:gsmith888
  • 2
3 Comments
 
LVL 32

Accepted Solution

by:
phoffric earned 1600 total points
ID: 39217991
You should look at your code and see how many threads are designed to run, and how much contention there is associated with synchronization, with query locks if DB is involved, with disk I/O, with caching, and with shared memory data. Even if multiple threads are just reading the same shared memory, a CPU core can stall while waiting for access, and in this case the CPU utilization will rise even though the stalled core is not doing anything useful. If you can provide the code, we may be able to better assist you.

Here's a quote from this link: http://www.devx.com/Java/Article/35087/0/page/2 

A large part of the application server execution time is spent transmitting data back and forth across components, taking out locks, or waiting for locks to be released. Spending some quality time with a profiler can show you just how much time your application spends on these tasks, which cannot benefit from a faster CPU.
Here are additional links which discuss at length some of the issues which may be plaguing your program:
how do I optimize for multi-core
Java thread affinity
0
 
LVL 32

Expert Comment

by:phoffric
ID: 39218013
This link introduces important Java parallel application profiling tools: highly scalable java programming for multicore system

More profilers and the contention issues monitored:
http://pic.dhe.ibm.com/infocenter/isa/v4r1m0/index.jsp?topic=%2Fcom.ibm.msdk.help.isa%2Fhtml%2Fmaintopic.html
0
 
LVL 28

Assisted Solution

by:dpearson
dpearson earned 400 total points
ID: 39218066
If you're not getting full CPU utilization, the first place to look is at the database.  The vast majority of web applications are bottlenecked by database throughput, not CPU throughput since most of the work they do is retrieving data.  There's usually not a lot of complex calculations involved.

Take for example this web site - experts exchange.  Almost everything you see on the page here will live in the database.  All the web server has to do is retrieve that data, format it for HTML and send it over the network.  The only way to get a system like this to 100% CPU across multiple cores is if the database can keep up - which means looking at the number of connections that are being opened and whether they are blocking, waiting for the database to respond or not.  If this turns out to be the case, then increasing the max number of db connections may increase overall throughput and allow the CPU utilization to rise.

Doug
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Configure Web Service (server application) I. Configure security for Web Services methods First, we need to protect Session bean which implements the service: 1. Open EJB deployment descriptor (ejb-jar.xml) in the EJB project that contains you…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question