Solved

threading issue using java?

Posted on 2013-06-03
3
432 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 400 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 100 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

627 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