官术网_书友最值得收藏!

Comparing the two solutions

Now it's time to test the serial and concurrent servers and see which has a better performance. We have automatized the tests implementing four classes that make queries to the servers. These classes are:

  • SerialClient: This implements a possible client of the serial server. It makes nine requests using the query message and a query using the report message. It repeats the process 10 times, so it request 90 queries and 10 reports.
  • MultipleSerialClients: This class simulates the existence of several clients at the same time. For this, we create a thread per SerialClient and execute them at the same time to see the performance of the server. We have tested from one to five concurrent clients.
  • ConcurrentClient: It is analogue to the SerialClient class, but it calls the concurrent server instead of the serial one.
  • MultipleConcurrentClients: It is analogue to the MultipleSerialClients class, but it calls the concurrent server instead of the serial one.

To test the serial server, you can follow these steps:

  1. Launch the serial server and wait for its initialization.
  2. Launch the MultipleSerialClients class, which launches one, then two, three, four, and finally, five SerialClient classes.

You can follow a similar process with the concurrent server:

  1. Launch the concurrent server and wait for its initialization.
  2. Launch the MultipleConcurrentClients class, which launches one, two, three, four, and finally, five ConcurrentClient classes.

To compare the execution times of both versions, we have implemented a microbenchmark using the JMH framework (http://openjdk.java.net/projects/code-tools/jmh/). We have implemented two executions based in the SerialClient and ConcurrentClient tasks. We have repeated this process 10 times calculating the mean time per number of concurrent clients. We launched the tests in a computer with a processor with four cores, so it can execute four parallel tasks at the same time.

These are the results of all these executions:

The contents of the cells are the mean time of each client in seconds. We can draw the following conclusions:

  • The performance of both kinds of servers is affected by the number of concurrent clients that send requests to our server
  • In all cases, the execution times of the concurrent version are much lower than the execution times of the serial one
主站蜘蛛池模板: 达拉特旗| 招远市| 会昌县| 庄河市| 寿光市| 家居| 木兰县| 乌鲁木齐市| 丽江市| 无锡市| 常德市| 台湾省| 寿宁县| 平塘县| 会泽县| 迭部县| 扎兰屯市| 雷州市| 永州市| 新丰县| 湘潭市| 永和县| 梅河口市| 石首市| 溆浦县| 长岛县| 定远县| 奉贤区| 靖江市| 七台河市| 卢龙县| 盐津县| 安仁县| 定州市| 墨玉县| 江川县| 洛隆县| 溧水县| 富平县| 修水县| 台北市|