This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Java competing with native code app over resources  RSS feed

Stas Nikso
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have 2 apps running on my server, a native code application, and a Java one.
Java app is communicating with the native code over IPC (shared memory). They both work on same number of resources.

On high loads (about 80% CPU), the native app takes about 100% more of CPU time (the server is multi-cpu, multi-core).

My question is, does it possible to balance the CPU loads between the two apps? Meaning, give the two apps equal priorities?

Thanks for any advice.
Tim Holloway
Posts: 18709
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couldn't quite get a clear picture of what you're looking for, but maybe this will help:

The technical name for scheduling more work on a computer than it can handle is "overcommit". Overcommitting was fairly common back when expensive mainframes were the rule, but these days hardware is so cheap that the usual response to a heavier workload is to just buy more hardware.

However, sometimes that's not sufficient and even after tuning you may still end up overcommitted.

Once that occurs, it's time to sit down and determine who's going to get the short end of the deal. Since resources are finite, then next best thing is to give them to those who can best justify their use - meaning produce more revenue, keep everyone out of trouble, or just plain have the political pull. You then draw up service level agreements that specify how much of the pie each consumer is going to get and what the rules on dividing the pie are going to be.

The original Unix solution for that was in programs like "nice" that maintained a set of CPU dispatcher priority levels. You would mostly adjust the nice levels yourself on a manual basis.

That's only the start, however. On a heavily-used system, you have queues for more than just CPU time, you may also want to load-balance on network and disk resources. Also on how much real memory will back up each process versus how much virtual memory it consumes.

The big-league vendors like IBM and Sun have very elaborate resource management systems. They would allocate general service levels, dynamically bump resources up and down in response to changing conditions - for example, the longer a processs ran, the lower priority it might be given - and do whatever else was necessary. In one IBM shop I worked in, we'd even switch the service level rules 3 times a day as we went from day shift (online users and developers) to night shift (production processing) to early-morning shift (backups and system maintenance).

Ultimately, Java apps are native code as well. The JVM is native code and so is any JIT- or pre-compiled Java code. From the OS's point of view, it's just another native app. Of course, every app has its own ways of using resources. So for optimal performance, you'll want to set some service levels and investigate the load-balancing options that the system(s) you're running on support.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!