You are to write a program to simulate a server which processes incoming requests. The simulation should show the optimum number of threads for this server and this data set. You may use one of the languages Java for the simulation.
Obtain the text data file appropriate to your section. You should save it and edit the file to remove the html tags. The file should look like a list of arrival times of requests and the time the server requires to process the request. Both of these times are in milliseconds.
Suppose the first few lines in the editted file are:
In a single threaded server: at 0 ms a request requiring 11 ms of processing arrives; the next request arrives at 18 ms and requires 74 ms to process; the third request arrives at 29 ms but cannot be started until the second request is finished. This results in a total time to process the three requests is 112 ms and average requests per second is 26.8 [(1/112)*1000].
In a two threaded server: at 0 ms a request requiring 11 ms of processing arrives; the next request arrives at 18 ms and requires 74 ms to process; the third request arrives at 29 ms and causes a second thread to start processing the request for 20 ms. The total processing time is 92 ms for the three requests and an average requests per second of 32.6 [(3/92)*1000].
Additional threads would not result in a better requests per second value. Therefore for this (admittedly small) input set the optimum number of threads is 2.