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

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
主站蜘蛛池模板: 苏尼特左旗| 石楼县| 南皮县| 滁州市| 赤城县| 什邡市| 宿迁市| 桃园市| 易门县| 政和县| 平果县| 建湖县| 张家川| 柘荣县| 潼关县| 灵宝市| 黎平县| 绥宁县| 莱阳市| 祁阳县| 贵阳市| 凤山市| 专栏| 寿阳县| 石狮市| 左贡县| 元氏县| 大同市| 扶风县| 右玉县| 广西| 肥乡县| 石阡县| 黄石市| 宁津县| 郁南县| 广宁县| 云安县| 兴和县| 临潭县| 天柱县|