Note that there are some explanatory texts on larger screens.

plurals
  1. POhttp load generator in java
    primarykey
    data
    text
    <p>This is more of design question; how would you design a http load generator in java for which you can specify number of concurrent users, the amount of time to run the test, and a list of urls to hit. </p> <pre><code>some_load_generator -users n1 -time n2 -urls some_file_name.txt </code></pre> <p>The program starts up, creates number of threads as specified by number of users, every thread reads a random url from the url file and makes a GET request. For every request, each thread records the time it took to complete the entire GET request. Every 5 seconds this program prints out the minimum, maximum, and the average time across all the requests made so far by all the threads. </p> <p>How would you go about creating threads, storing the min, max, and average information and printing that information every 5 seconds.</p> <p>Here is what I have thought so far:</p> <ol> <li><p>The program will create a new fixed thread pool executor which corresponds to the number of users. This takes of threads life cycle management.</p></li> <li><p>The Runnable implementation reads a line from the file makes a GET request and records the time it took.</p></li> <li><p><strong>My main issue</strong> is how to calculate min, max, and average, across all threads, efficiently since we will need to synchronize access to these variables.</p></li> <li><p>For printing the statistics every 5 seconds, I will use a timer task that wakes up, displays the statistics and goes back to sleep. The main issue here is, how to efficiently schedule the timer task, since there are a lot of threads that are trying to update the state of the statistics while this thread is trying to print it. May be I can increase the priority of this thread as compared to others so it gets preference while execution.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload