Solved

threading issue using java?

Posted on 2013-06-03
3
388 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 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 26

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now