Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

threading issue using java?

Posted on 2013-06-03
3
Medium Priority
?
459 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Verbose logging is used to diagnose garbage collector problems. By default, -verbose:gc output is written to either native_stderr.log or native_stdout.log.   It is also possible to redirect the logs to a user-specified file. This article will de…
This article is about some of the basic and important steps to be used to improve the performance in web-sphere commerce application development. 1) Always leverage the Dyna-caching facility provided by the product 2) Remove the unwanted code …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

730 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