4

We have a REST based service that is calling external API and get the response back from that API.

I was filing Capacity request here to make sure our boxes can handle the traffic when we host the service.

So the Capacity guys have asked me -

Any idea what is the estimated CPU and IO time for these calls?

Can anyone tell me in simple language what does these terms means? And what approach should I take to get the rough estimate about the calls?

Thanks for the help.

Update:-

Suppose if this is my program.

public class RestLnPTest {

    private final static Logger LOG = Logger.getLogger(NokiaLnPTest.class.getName());
    private static int noOfThreads = 10;

    public static void main(String[] args) {

        ExecutorService service = Executors.newFixedThreadPool(noOfThreads);

        try {

            for (int i = 0; i < 100 * noOfThreads; i++) {
                service.submit(new ThreadTask());
            }

            service.shutdown();
            service.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);

        } catch (InterruptedException e) {

        } catch (Exception e) {

        } finally {
            logHistogramInfo();
        }
    }

    private static void logHistogramInfo() {

     System.out.println(ThreadTask.lookupHistogram);

    }
}

class ThreadTask implements Runnable {

    public static ConcurrentHashMap<Long, AtomicLong> lookupHistogram = new ConcurrentHashMap<Long, AtomicLong>();
    private static final String URL = "SOME_URL";

    @Override
    public void run() {

        RestTemplate restTemplate = new RestTemplate();

        long start = System.nanoTime();

        String result = restTemplate.getForObject(URL, String.class);

        long end = System.nanoTime() - start;

        final AtomicLong before = lookupHistogram.putIfAbsent(end / 1000000, new AtomicLong(1L));

        if (before != null) {
            before.incrementAndGet();
        }
    }
}

Then how can I figure out CPU and IO times? And currently I am working in Unix Environment.

AKIWEB
  • 19,008
  • 67
  • 180
  • 294
  • Open up VisualVM, which comes with the JDK, and profile the REST calls. Alternatively, you can take a look at YourKit, which is a much faster profiler for Java, and do the same thing. – pickypg Mar 15 '13 at 20:25
  • Thanks pickypg for the suggestion. With the `visualvm` or `yourkit` can we find out both IO and CPU time? If yes how can I find out after profiling our REST calls? Means at what component I should look into to find out these things? Thanks for the help. – AKIWEB Mar 15 '13 at 21:41
  • You want to tell us that you do not know what CPU time is? – Ingo Mar 16 '13 at 01:12
  • @lngo, I am trying to figure out how to calculate these things? – AKIWEB Mar 17 '13 at 03:32

1 Answers1

2

I believe that you are required to measure the CPU consumption and IO load caused by your application activity.

If you are on Unix-like system you can use

  1. top command for manual monitoring
  2. vmstat for automatic monitosring of whole machine
  3. ps with appropriate options to monitor specific process.

On Windows start from using Task Manager. You can also implement script in vbs or jscript that gets the same data using WMI.

If you need platform independent way implemented in java you can use JMX. System bean provides limited information at least about CPU consumption.

AlexR
  • 114,158
  • 16
  • 130
  • 208
  • Thanks Alex for the suggestion. In a simple language can you explain me what does IO load means here and CPU consumption as well. I have slight context but wanted to make sure what I know is right or not. Thanks for the help. And I will be working in Windows Environment. – AKIWEB Mar 15 '13 at 20:23