diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/HttpServerImpl.java b/src/main/java/ru/vk/itmo/test/volkovnikita/HttpServerImpl.java new file mode 100644 index 000000000..fe68618e7 --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/HttpServerImpl.java @@ -0,0 +1,105 @@ +package ru.vk.itmo.test.volkovnikita; + +import one.nio.http.HttpServer; +import one.nio.http.HttpServerConfig; +import one.nio.http.HttpSession; +import one.nio.http.Param; +import one.nio.http.Path; +import one.nio.http.Request; +import one.nio.http.RequestMethod; +import one.nio.http.Response; +import one.nio.server.AcceptorConfig; +import ru.vk.itmo.ServiceConfig; +import ru.vk.itmo.dao.BaseEntry; +import ru.vk.itmo.dao.Dao; +import ru.vk.itmo.dao.Entry; +import ru.vk.itmo.test.reference.dao.ReferenceDao; + +import java.io.IOException; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.ValueLayout; +import java.util.Set; + +public class HttpServerImpl extends HttpServer { + + private final Dao> dao; + + static final Set METHODS = Set.of( + "GET", + "PUT", + "DELETE" + ); + + public HttpServerImpl(ServiceConfig config, ReferenceDao dao) throws IOException { + super(createServerConfig(config)); + this.dao = dao; + } + + private static HttpServerConfig createServerConfig(ServiceConfig config) { + HttpServerConfig serverConfig = new HttpServerConfig(); + AcceptorConfig acceptorConfig = new AcceptorConfig(); + acceptorConfig.port = config.selfPort(); + acceptorConfig.reusePort = true; + + serverConfig.acceptors = new AcceptorConfig[]{acceptorConfig}; + serverConfig.closeSessions = true; + return serverConfig; + } + + @Path(value = "/v0/status") + public Response status() { + return Response.ok("It's okay (c) Tinkoff"); + } + + @Path(value = "/v0/entity") + @RequestMethod(Request.METHOD_GET) + public Response getEntry(@Param(value = "id", required = true) String id) { + if (isIdUncorrect(id)) { + return new Response(Response.BAD_REQUEST, Response.EMPTY); + } + MemorySegment key = MemorySegment.ofArray(id.toCharArray()); + Entry entry = dao.get(key); + return entry == null ? new Response(Response.NOT_FOUND, Response.EMPTY) : + new Response(Response.OK, entry.value().toArray(ValueLayout.JAVA_BYTE)); + } + + @Path(value = "/v0/entity") + @RequestMethod(Request.METHOD_PUT) + public Response up(@Param(value = "id", required = true) String id, Request request) { + if (isIdUncorrect(id)) { + return new Response(Response.BAD_REQUEST, Response.EMPTY); + } + MemorySegment key = MemorySegment.ofArray(id.toCharArray()); + MemorySegment value = MemorySegment.ofArray(request.getBody()); + dao.upsert(new BaseEntry<>(key, value)); + return new Response(Response.CREATED, Response.EMPTY); + } + + @Path(value = "/v0/entity") + @RequestMethod(Request.METHOD_DELETE) + public Response deleteEntry(@Param(value = "id", required = true) String id) { + if (isIdUncorrect(id)) { + return new Response(Response.BAD_REQUEST, Response.EMPTY); + } + MemorySegment key = MemorySegment.ofArray(id.toCharArray()); + dao.upsert(new BaseEntry<>(key, null)); + return new Response(Response.ACCEPTED, Response.EMPTY); + } + + @Override + public void handleDefault(Request request, HttpSession session) throws IOException { + Response response; + if (METHODS.contains(request.getMethodName())) { + response = new Response(Response.BAD_REQUEST, Response.EMPTY); + session.sendResponse(response); + } else { + response = new Response(Response.METHOD_NOT_ALLOWED, Response.EMPTY); + session.sendResponse(response); + } + session.sendResponse(response); + } + + private boolean isIdUncorrect(String id) { + return id == null || id.isEmpty() || id.isBlank(); + } +} diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/Server.java b/src/main/java/ru/vk/itmo/test/volkovnikita/Server.java new file mode 100644 index 000000000..51e1b3ae4 --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/Server.java @@ -0,0 +1,30 @@ +package ru.vk.itmo.test.volkovnikita; + +import ru.vk.itmo.ServiceConfig; +import ru.vk.itmo.dao.Config; +import ru.vk.itmo.test.reference.dao.ReferenceDao; + +import java.io.IOException; +import java.nio.file.Files; +import java.util.List; + +public final class Server { + + public static final long FLUSH_THRESHOLD_BYTES = 4 * 1024L; + + private Server() { + + } + + public static void main(String[] args) throws IOException { + ServiceConfig config = new ServiceConfig( + 8080, + "http://localhost", + List.of("http://localhost"), + Files.createTempDirectory(".") + ); + ReferenceDao dao = new ReferenceDao(new Config(config.workingDir(), FLUSH_THRESHOLD_BYTES)); + HttpServerImpl server = new HttpServerImpl(config, dao); + server.start(); + } +} diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/ServiceImpl.java b/src/main/java/ru/vk/itmo/test/volkovnikita/ServiceImpl.java new file mode 100644 index 000000000..95e11b034 --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/ServiceImpl.java @@ -0,0 +1,46 @@ +package ru.vk.itmo.test.volkovnikita; + +import ru.vk.itmo.Service; +import ru.vk.itmo.ServiceConfig; +import ru.vk.itmo.dao.Config; +import ru.vk.itmo.test.ServiceFactory; +import ru.vk.itmo.test.reference.dao.ReferenceDao; + +import java.io.IOException; +import java.util.concurrent.CompletableFuture; + +public class ServiceImpl implements Service { + public static final long FLUSH_THRESHOLD_BYTES = 4 * 1024L; + + private HttpServerImpl server; + private final ServiceConfig config; + private ReferenceDao dao; + + public ServiceImpl(ServiceConfig config) { + this.config = config; + } + + @Override + public synchronized CompletableFuture start() throws IOException { + dao = new ReferenceDao(new Config(config.workingDir(), FLUSH_THRESHOLD_BYTES)); + server = new HttpServerImpl(config, dao); + server.start(); + return CompletableFuture.completedFuture(null); + } + + @Override + public synchronized CompletableFuture stop() throws IOException { + server.stop(); + dao.close(); + return CompletableFuture.completedFuture(null); + } + + @ServiceFactory(stage = 1) + public static class Factory implements ServiceFactory.Factory { + + @Override + public Service create(ServiceConfig config) { + return new ServiceImpl(config); + } + } +} diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/Histogram_get_2000.png b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/Histogram_get_2000.png new file mode 100644 index 000000000..35c610180 Binary files /dev/null and b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/Histogram_get_2000.png differ diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/get_result_2000 b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/get_result_2000 new file mode 100644 index 000000000..dbd17ffd7 --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/get_result_2000 @@ -0,0 +1,81 @@ +Value Percentile TotalCount 1/(1-Percentile) + + 0.289 0.000000 1 1.00 + 0.608 0.100000 4007 1.11 + 0.827 0.200000 8017 1.25 + 1.020 0.300000 12022 1.43 + 1.216 0.400000 16038 1.67 + 1.401 0.500000 20050 2.00 + 1.515 0.550000 22028 2.22 + 1.709 0.600000 24031 2.50 + 2.026 0.650000 26035 2.86 + 2.627 0.700000 28035 3.33 + 3.503 0.750000 30038 4.00 + 4.019 0.775000 31043 4.44 + 4.555 0.800000 32049 5.00 + 5.139 0.825000 33042 5.71 + 5.931 0.850000 34046 6.67 + 6.775 0.875000 35046 8.00 + 7.187 0.887500 35548 8.89 + 7.655 0.900000 36045 10.00 + 8.147 0.912500 36552 11.43 + 8.767 0.925000 37050 13.33 + 9.647 0.937500 37550 16.00 + 10.087 0.943750 37800 17.78 + 10.695 0.950000 38052 20.00 + 11.367 0.956250 38299 22.86 + 12.367 0.962500 38550 26.67 + 13.207 0.968750 38799 32.00 + 13.767 0.971875 38925 35.56 + 14.263 0.975000 39051 40.00 + 15.031 0.978125 39174 45.71 + 15.999 0.981250 39300 53.33 + 17.263 0.984375 39428 64.00 + 17.647 0.985938 39490 71.11 + 18.303 0.987500 39551 80.00 + 19.311 0.989062 39612 91.43 + 20.591 0.990625 39675 106.67 + 22.159 0.992188 39739 128.00 + 22.895 0.992969 39769 142.22 + 23.839 0.993750 39800 160.00 + 25.023 0.994531 39831 182.86 + 26.191 0.995313 39864 213.33 + 27.615 0.996094 39894 256.00 + 28.399 0.996484 39910 284.44 + 28.767 0.996875 39927 320.00 + 28.927 0.997266 39942 365.71 + 29.167 0.997656 39957 426.67 + 29.599 0.998047 39972 512.00 + 30.191 0.998242 39980 568.89 + 30.415 0.998437 39988 640.00 + 30.735 0.998633 39996 731.43 + 31.711 0.998828 40004 853.33 + 32.495 0.999023 40011 1024.00 + 32.991 0.999121 40015 1137.78 + 33.471 0.999219 40019 1280.00 + 33.631 0.999316 40023 1462.86 + 33.695 0.999414 40027 1706.67 + 33.727 0.999512 40033 2048.00 + 33.727 0.999561 40033 2275.56 + 33.759 0.999609 40035 2560.00 + 33.791 0.999658 40037 2925.71 + 33.823 0.999707 40040 3413.33 + 33.855 0.999756 40043 4096.00 + 33.855 0.999780 40043 4551.11 + 33.855 0.999805 40043 5120.00 + 33.887 0.999829 40045 5851.43 + 33.887 0.999854 40045 6826.67 + 33.919 0.999878 40046 8192.00 + 33.919 0.999890 40046 9102.22 + 33.951 0.999902 40048 10240.00 + 33.951 0.999915 40048 11702.86 + 33.951 0.999927 40048 13653.33 + 33.951 0.999939 40048 16384.00 + 33.951 0.999945 40048 18204.44 + 34.015 0.999951 40049 20480.00 + 34.015 0.999957 40049 23405.71 + 34.015 0.999963 40049 27306.67 + 34.015 0.999969 40049 32768.00 + 34.015 0.999973 40049 36408.89 + 34.079 0.999976 40050 40960.00 + 34.079 1.000000 40050 inf \ No newline at end of file diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/profile-2000-get-alloc.html b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/profile-2000-get-alloc.html new file mode 100644 index 000000000..bf56e821c --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/profile-2000-get-alloc.html @@ -0,0 +1,389 @@ + + + + + + + +

Flame Graph

+
  
+
Produced by async-profiler
+ +
+

+

Matched:

+ diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/profile-2000-get-cpu.html b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/profile-2000-get-cpu.html new file mode 100644 index 000000000..9740674a1 --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/get/profile-2000-get-cpu.html @@ -0,0 +1,518 @@ + + + + + + + +

Flame Graph

+
  
+
Produced by async-profiler
+ +
+

+

Matched:

+ diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/Histogram_put_6000.png b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/Histogram_put_6000.png new file mode 100644 index 000000000..f7f319d1f Binary files /dev/null and b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/Histogram_put_6000.png differ diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/profile-6000-alloc.html b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/profile-6000-alloc.html new file mode 100644 index 000000000..88e689329 --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/profile-6000-alloc.html @@ -0,0 +1,502 @@ + + + + + + + +

Flame Graph

+
  
+
Produced by async-profiler
+ +
+

+

Matched:

+ diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/profile-6000-cpu-put.html b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/profile-6000-cpu-put.html new file mode 100644 index 000000000..987de80ef --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/profile-6000-cpu-put.html @@ -0,0 +1,783 @@ + + + + + + + +

Flame Graph

+
  
+
Produced by async-profiler
+ +
+

+

Matched:

+ diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/put_result_6000.txt b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/put_result_6000.txt new file mode 100644 index 000000000..9767d1584 --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/data/stage1/put/put_result_6000.txt @@ -0,0 +1,84 @@ +Value Percentile TotalCount 1/(1-Percentile) + + 0.028 0.000000 1 1.00 + 0.368 0.100000 12018 1.11 + 0.600 0.200000 24040 1.25 + 0.827 0.300000 36044 1.43 + 1.047 0.400000 48023 1.67 + 1.297 0.500000 60021 2.00 + 1.518 0.550000 66006 2.22 + 1.936 0.600000 71989 2.50 + 2.751 0.650000 77986 2.86 + 3.735 0.700000 83984 3.33 + 4.831 0.750000 89995 4.00 + 5.463 0.775000 92992 4.44 + 6.191 0.800000 95983 5.00 + 6.855 0.825000 98989 5.71 + 7.607 0.850000 101987 6.67 + 8.567 0.875000 104986 8.00 + 9.143 0.887500 106480 8.89 + 9.783 0.900000 107976 10.00 + 10.631 0.912500 109480 11.43 + 11.951 0.925000 110981 13.33 + 13.327 0.937500 112481 16.00 + 13.967 0.943750 113224 17.78 + 14.799 0.950000 113977 20.00 + 15.663 0.956250 114727 22.86 + 16.767 0.962500 115476 26.67 + 18.415 0.968750 116228 32.00 + 19.583 0.971875 116600 35.56 + 20.127 0.975000 116978 40.00 + 21.151 0.978125 117352 45.71 + 22.175 0.981250 117724 53.33 + 23.647 0.984375 118102 64.00 + 24.671 0.985938 118285 71.11 + 26.543 0.987500 118474 80.00 + 32.495 0.989062 118660 91.43 + 40.799 0.990625 118848 106.67 + 46.207 0.992188 119035 128.00 + 49.119 0.992969 119130 142.22 + 51.551 0.993750 119223 160.00 + 52.639 0.994531 119316 182.86 + 53.055 0.995313 119412 213.33 + 54.111 0.996094 119505 256.00 + 54.783 0.996484 119551 284.44 + 55.999 0.996875 119598 320.00 + 56.831 0.997266 119645 365.71 + 57.631 0.997656 119691 426.67 + 58.303 0.998047 119742 512.00 + 58.591 0.998242 119762 568.89 + 58.719 0.998437 119788 640.00 + 58.783 0.998633 119810 731.43 + 58.911 0.998828 119832 853.33 + 59.263 0.999023 119856 1024.00 + 59.487 0.999121 119867 1137.78 + 59.711 0.999219 119882 1280.00 + 59.775 0.999316 119890 1462.86 + 59.871 0.999414 119907 1706.67 + 59.967 0.999512 119916 2048.00 + 60.031 0.999561 119920 2275.56 + 60.095 0.999609 119928 2560.00 + 60.127 0.999658 119934 2925.71 + 60.159 0.999707 119942 3413.33 + 60.191 0.999756 119948 4096.00 + 60.191 0.999780 119948 4551.11 + 60.223 0.999805 119955 5120.00 + 60.223 0.999829 119955 5851.43 + 60.223 0.999854 119955 6826.67 + 60.255 0.999878 119959 8192.00 + 60.255 0.999890 119959 9102.22 + 60.287 0.999902 119962 10240.00 + 60.287 0.999915 119962 11702.86 + 60.319 0.999927 119966 13653.33 + 60.319 0.999939 119966 16384.00 + 60.319 0.999945 119966 18204.44 + 60.351 0.999951 119967 20480.00 + 60.351 0.999957 119967 23405.71 + 60.383 0.999963 119968 27306.67 + 60.415 0.999969 119969 32768.00 + 60.415 0.999973 119969 36408.89 + 60.447 0.999976 119970 40960.00 + 60.447 0.999979 119970 46811.43 + 60.447 0.999982 119970 54613.33 + 60.479 0.999985 119972 65536.00 + 60.479 1.000000 119972 inf \ No newline at end of file diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/lua/stage1/get.lua b/src/main/java/ru/vk/itmo/test/volkovnikita/lua/stage1/get.lua new file mode 100644 index 000000000..7f9312f79 --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/lua/stage1/get.lua @@ -0,0 +1,7 @@ +id = 0 +function request() + headers = {} + headers["Host"] = "localhost:8080" + id = id + 1 + return wrk.format("GET", "/v0/entity?id=" .. id, headers) +end diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/lua/stage1/put.lua b/src/main/java/ru/vk/itmo/test/volkovnikita/lua/stage1/put.lua new file mode 100644 index 000000000..b5fb6cd2b --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/lua/stage1/put.lua @@ -0,0 +1,8 @@ +id = 0 +function request() + headers = {} + headers["Host"] = "localhost:8080" + id = id + 1 + body = math.random(1, 555555) + return wrk.format("PUT", "/v0/entity?id=" .. id, headers, body) +end \ No newline at end of file diff --git a/src/main/java/ru/vk/itmo/test/volkovnikita/report/stage1.md b/src/main/java/ru/vk/itmo/test/volkovnikita/report/stage1.md new file mode 100644 index 000000000..bfcef763c --- /dev/null +++ b/src/main/java/ru/vk/itmo/test/volkovnikita/report/stage1.md @@ -0,0 +1,526 @@ +## Нагрузочное тестирование с wrk2 + +### PUT +С использованием виртуальной машины была выявленна точка разладки при 10000 RPS для PUT запроса: + +### 10000 RPS + +wrk -d 30 -c 1 -t 1 -R 10000 -L -s /home/ravenhub/IdeaProjects/2024-highload-dht/src/main/java/ru/vk/itmo/test/volkovnikita/lua/stage1/put.lua http://127.0.0.1:8080 +Running 30s test @ http://127.0.0.1:8080 +1 threads and 1 connections +Thread calibration: mean lat.: 826.002ms, rate sampling interval: 2967ms +Thread Stats Avg Stdev Max +/- Stdev +Latency 3.30s 924.83ms 4.93s 60.52% +Req/Sec 8.37k 106.99 8.45k 83.33% +Latency Distribution (HdrHistogram - Recorded Latency) +50.000% 3.28s +75.000% 4.07s +90.000% 4.64s +99.000% 4.91s +99.900% 4.93s +99.990% 4.93s +99.999% 4.93s +100.000% 4.93s + +Detailed Percentile spectrum: +Value Percentile TotalCount 1/(1-Percentile) + + 1691.647 0.000000 41 1.00 + 1998.847 0.100000 16923 1.11 + 2322.431 0.200000 33564 1.25 + 2646.015 0.300000 50426 1.43 + 2963.455 0.400000 67176 1.67 + 3282.943 0.500000 83779 2.00 + 3436.543 0.550000 92198 2.22 + 3581.951 0.600000 100622 2.50 + 3766.271 0.650000 109231 2.86 + 3921.919 0.700000 117478 3.33 + 4069.375 0.750000 126219 4.00 + 4147.199 0.775000 129999 4.44 + 4184.063 0.800000 134178 5.00 + 4272.127 0.825000 138363 5.71 + 4374.527 0.850000 142540 6.67 + 4493.311 0.875000 146927 8.00 + 4587.519 0.887500 148728 8.89 + 4640.767 0.900000 150802 10.00 + 4726.783 0.912500 153101 11.43 + 4767.743 0.925000 155196 13.33 + 4800.511 0.937500 157382 16.00 + 4804.607 0.943750 158932 17.78 + 4808.703 0.950000 159320 20.00 + 4849.663 0.956250 160233 22.86 + 4874.239 0.962500 161324 26.67 + 4886.527 0.968750 162542 32.00 + 4890.623 0.971875 163020 35.56 + 4894.719 0.975000 163745 40.00 + 4898.815 0.978125 164198 45.71 + 4902.911 0.981250 164915 53.33 + 4907.007 0.984375 165733 64.00 + 4907.007 0.985938 165733 71.11 + 4907.007 0.987500 165733 80.00 + 4907.007 0.989062 165733 91.43 + 4915.199 0.990625 166022 106.67 + 4927.487 0.992188 166683 128.00 + 4927.487 0.992969 166683 142.22 + 4927.487 0.993750 166683 160.00 + 4927.487 0.994531 166683 182.86 + 4931.583 0.995313 167557 213.33 + 4931.583 1.000000 167557 inf +#[Mean = 3304.008, StdDeviation = 924.826] +#[Max = 4927.488, Total count = 167557] +#[Buckets = 27, SubBuckets = 2048] +---------------------------------------------------------- +250697 requests in 30.00s, 16.02MB read +Requests/sec: 8356.63 +Transfer/sec: 546.77KB + + +Проанализируем работу про 6000 и 7000 RPS: + +### 6000 RPS + +wrk -d 30 -c 1 -t 1 -R 6000 -L -s /home/ravenhub/IdeaProjects/2024-highload-dht/src/main/java/ru/vk/itmo/test/volkovnikita/lua/stage1/put.lua http://127.0.0.1:8080 +Running 30s test @ http://127.0.0.1:8080 +1 threads and 1 connections +Thread calibration: mean lat.: 6.447ms, rate sampling interval: 29ms +Thread Stats Avg Stdev Max +/- Stdev +Latency 3.96ms 6.72ms 60.45ms 91.31% +Req/Sec 6.11k 0.90k 10.25k 73.44% +Latency Distribution (HdrHistogram - Recorded Latency) +50.000% 1.30ms +75.000% 4.83ms +90.000% 9.78ms +99.000% 37.34ms +99.900% 59.20ms +99.990% 60.29ms +99.999% 60.48ms +100.000% 60.48ms + +Detailed Percentile spectrum: +Value Percentile TotalCount 1/(1-Percentile) + + 0.028 0.000000 1 1.00 + 0.368 0.100000 12018 1.11 + 0.600 0.200000 24040 1.25 + 0.827 0.300000 36044 1.43 + 1.047 0.400000 48023 1.67 + 1.297 0.500000 60021 2.00 + 1.518 0.550000 66006 2.22 + 1.936 0.600000 71989 2.50 + 2.751 0.650000 77986 2.86 + 3.735 0.700000 83984 3.33 + 4.831 0.750000 89995 4.00 + 5.463 0.775000 92992 4.44 + 6.191 0.800000 95983 5.00 + 6.855 0.825000 98989 5.71 + 7.607 0.850000 101987 6.67 + 8.567 0.875000 104986 8.00 + 9.143 0.887500 106480 8.89 + 9.783 0.900000 107976 10.00 + 10.631 0.912500 109480 11.43 + 11.951 0.925000 110981 13.33 + 13.327 0.937500 112481 16.00 + 13.967 0.943750 113224 17.78 + 14.799 0.950000 113977 20.00 + 15.663 0.956250 114727 22.86 + 16.767 0.962500 115476 26.67 + 18.415 0.968750 116228 32.00 + 19.583 0.971875 116600 35.56 + 20.127 0.975000 116978 40.00 + 21.151 0.978125 117352 45.71 + 22.175 0.981250 117724 53.33 + 23.647 0.984375 118102 64.00 + 24.671 0.985938 118285 71.11 + 26.543 0.987500 118474 80.00 + 32.495 0.989062 118660 91.43 + 40.799 0.990625 118848 106.67 + 46.207 0.992188 119035 128.00 + 49.119 0.992969 119130 142.22 + 51.551 0.993750 119223 160.00 + 52.639 0.994531 119316 182.86 + 53.055 0.995313 119412 213.33 + 54.111 0.996094 119505 256.00 + 54.783 0.996484 119551 284.44 + 55.999 0.996875 119598 320.00 + 56.831 0.997266 119645 365.71 + 57.631 0.997656 119691 426.67 + 58.303 0.998047 119742 512.00 + 58.591 0.998242 119762 568.89 + 58.719 0.998437 119788 640.00 + 58.783 0.998633 119810 731.43 + 58.911 0.998828 119832 853.33 + 59.263 0.999023 119856 1024.00 + 59.487 0.999121 119867 1137.78 + 59.711 0.999219 119882 1280.00 + 59.775 0.999316 119890 1462.86 + 59.871 0.999414 119907 1706.67 + 59.967 0.999512 119916 2048.00 + 60.031 0.999561 119920 2275.56 + 60.095 0.999609 119928 2560.00 + 60.127 0.999658 119934 2925.71 + 60.159 0.999707 119942 3413.33 + 60.191 0.999756 119948 4096.00 + 60.191 0.999780 119948 4551.11 + 60.223 0.999805 119955 5120.00 + 60.223 0.999829 119955 5851.43 + 60.223 0.999854 119955 6826.67 + 60.255 0.999878 119959 8192.00 + 60.255 0.999890 119959 9102.22 + 60.287 0.999902 119962 10240.00 + 60.287 0.999915 119962 11702.86 + 60.319 0.999927 119966 13653.33 + 60.319 0.999939 119966 16384.00 + 60.319 0.999945 119966 18204.44 + 60.351 0.999951 119967 20480.00 + 60.351 0.999957 119967 23405.71 + 60.383 0.999963 119968 27306.67 + 60.415 0.999969 119969 32768.00 + 60.415 0.999973 119969 36408.89 + 60.447 0.999976 119970 40960.00 + 60.447 0.999979 119970 46811.43 + 60.447 0.999982 119970 54613.33 + 60.479 0.999985 119972 65536.00 + 60.479 1.000000 119972 inf +#[Mean = 3.956, StdDeviation = 6.715] +#[Max = 60.448, Total count = 119972] +#[Buckets = 27, SubBuckets = 2048] +---------------------------------------------------------- +179990 requests in 30.00s, 11.50MB read +Requests/sec: 5999.66 +Transfer/sec: 392.56KB + +![Histogram_put_6000.png](..%2Fdata%2Fstage1%2Fput%2FHistogram_put_6000.png) + +[cpu-put](..%2Fdata%2Fstage1%2Fput%2Fprofile-6000-cpu-put.html) + +[alloc-put](..%2Fdata%2Fstage1%2Fput%2Fprofile-6000-alloc.html) + + +### 7000 RPS +Приведён просто для доп. статистики + +wrk -d 30 -c 1 -t 1 -R 7000 -L -s /home/ravenhub/IdeaProjects/2024-highload-dht/src/main/java/ru/vk/itmo/test/volkovnikita/lua/stage1/put.lua http://127.0.0.1:8080 +Running 30s test @ http://127.0.0.1:8080 +1 threads and 1 connections +Thread calibration: mean lat.: 7.968ms, rate sampling interval: 42ms +Thread Stats Avg Stdev Max +/- Stdev +Latency 9.84ms 11.55ms 70.08ms 85.92% +Req/Sec 7.07k 1.26k 10.34k 65.89% +Latency Distribution (HdrHistogram - Recorded Latency) +50.000% 5.76ms +75.000% 14.69ms +90.000% 25.41ms +99.000% 51.97ms +99.900% 67.14ms +99.990% 69.89ms +99.999% 70.14ms +100.000% 70.14ms + +Detailed Percentile spectrum: +Value Percentile TotalCount 1/(1-Percentile) + + 0.076 0.000000 1 1.00 + 0.553 0.100000 13959 1.11 + 0.934 0.200000 27909 1.25 + 1.375 0.300000 41868 1.43 + 3.045 0.400000 55796 1.67 + 5.763 0.500000 69748 2.00 + 7.107 0.550000 76717 2.22 + 8.711 0.600000 83693 2.50 + 10.335 0.650000 90661 2.86 + 12.287 0.700000 97647 3.33 + 14.695 0.750000 104619 4.00 + 15.903 0.775000 108119 4.44 + 17.263 0.800000 111603 5.00 + 18.799 0.825000 115087 5.71 + 20.655 0.850000 118564 6.67 + 22.767 0.875000 122056 8.00 + 24.015 0.887500 123791 8.89 + 25.407 0.900000 125536 10.00 + 26.911 0.912500 127272 11.43 + 28.623 0.925000 129024 13.33 + 30.495 0.937500 130769 16.00 + 31.743 0.943750 131636 17.78 + 33.119 0.950000 132524 20.00 + 34.751 0.956250 133383 22.86 + 36.063 0.962500 134258 26.67 + 38.591 0.968750 135122 32.00 + 40.639 0.971875 135556 35.56 + 42.783 0.975000 135992 40.00 + 44.543 0.978125 136436 45.71 + 46.335 0.981250 136869 53.33 + 47.967 0.984375 137302 64.00 + 49.247 0.985938 137519 71.11 + 50.303 0.987500 137736 80.00 + 51.231 0.989062 137958 91.43 + 52.863 0.990625 138169 106.67 + 54.751 0.992188 138388 128.00 + 55.935 0.992969 138496 142.22 + 58.271 0.993750 138606 160.00 + 59.679 0.994531 138715 182.86 + 61.663 0.995313 138825 213.33 + 62.783 0.996094 138933 256.00 + 63.359 0.996484 138988 284.44 + 64.063 0.996875 139042 320.00 + 64.671 0.997266 139095 365.71 + 65.503 0.997656 139152 426.67 + 66.047 0.998047 139205 512.00 + 66.367 0.998242 139232 568.89 + 66.623 0.998437 139267 640.00 + 66.815 0.998633 139292 731.43 + 66.943 0.998828 139313 853.33 + 67.135 0.999023 139340 1024.00 + 67.263 0.999121 139358 1137.78 + 67.327 0.999219 139373 1280.00 + 67.391 0.999316 139381 1462.86 + 67.583 0.999414 139399 1706.67 + 67.775 0.999512 139408 2048.00 + 68.031 0.999561 139420 2275.56 + 68.095 0.999609 139430 2560.00 + 68.095 0.999658 139430 2925.71 + 68.479 0.999707 139436 3413.33 + 68.799 0.999756 139442 4096.00 + 69.375 0.999780 139446 4551.11 + 69.567 0.999805 139450 5120.00 + 69.631 0.999829 139455 5851.43 + 69.695 0.999854 139457 6826.67 + 69.759 0.999878 139460 8192.00 + 69.887 0.999890 139462 9102.22 + 69.951 0.999902 139464 10240.00 + 70.015 0.999915 139470 11702.86 + 70.015 0.999927 139470 13653.33 + 70.015 0.999939 139470 16384.00 + 70.015 0.999945 139470 18204.44 + 70.015 0.999951 139470 20480.00 + 70.079 0.999957 139474 23405.71 + 70.079 0.999963 139474 27306.67 + 70.079 0.999969 139474 32768.00 + 70.079 0.999973 139474 36408.89 + 70.079 0.999976 139474 40960.00 + 70.079 0.999979 139474 46811.43 + 70.079 0.999982 139474 54613.33 + 70.079 0.999985 139474 65536.00 + 70.143 0.999986 139476 72817.78 + 70.143 1.000000 139476 inf +#[Mean = 9.840, StdDeviation = 11.552] +#[Max = 70.080, Total count = 139476] +#[Buckets = 27, SubBuckets = 2048] +---------------------------------------------------------- +209508 requests in 30.00s, 13.39MB read +Requests/sec: 6983.61 +Transfer/sec: 456.94KB + + +### GET +Прогнав по значениям в диапазоне от 250 до 10000 RPS получилось найти точку разладки +в 2300 RPS, стабильно работает при 2000 RPS, связи с профилированием в виртуалке, +RPS не очень большие. + +Прогонял до 10000 потому что выявил что в Linux-ubuntu при длительном нахождении Idea ultimate +в пассивном режиме(не открывал среду разработки) любое количество RPS в среднем давало Latency 4s, +пока не понял с чем связано + +### 2300 RTS +wrk -d 30 -c 1 -t 1 -R 2300 -L -s /home/ravenhub/IdeaProjects/2024-highload-dht/src/main/java/ru/vk/itmo/test/volkovnikita/lua/stage1/get.lua http://127.0.0.1:8080 +Running 30s test @ http://127.0.0.1:8080 +1 threads and 1 connections +Thread calibration: mean lat.: 563.172ms, rate sampling interval: 2071ms +Thread Stats Avg Stdev Max +/- Stdev +Latency 677.80ms 465.36ms 1.22s 48.91% +Req/Sec 2.44k 149.57 2.69k 66.67% +Latency Distribution (HdrHistogram - Recorded Latency) +50.000% 856.06ms +75.000% 1.14s +90.000% 1.18s +99.000% 1.20s +99.900% 1.21s +99.990% 1.22s +99.999% 1.22s +100.000% 1.22s + +Detailed Percentile spectrum: +Value Percentile TotalCount 1/(1-Percentile) + + 0.255 0.000000 2 1.00 + 0.998 0.100000 4866 1.11 + 3.049 0.200000 9717 1.25 + 327.679 0.300000 14576 1.43 + 602.111 0.400000 19439 1.67 + 856.063 0.500000 24310 2.00 + 902.143 0.550000 26728 2.22 + 941.055 0.600000 29154 2.50 + 1022.975 0.650000 31584 2.86 + 1119.231 0.700000 34120 3.33 + 1138.687 0.750000 36526 4.00 + 1154.047 0.775000 37787 4.44 + 1160.191 0.800000 38984 5.00 + 1167.359 0.825000 40099 5.71 + 1173.503 0.850000 41460 6.67 + 1177.599 0.875000 42917 8.00 + 1178.623 0.887500 43471 8.89 + 1179.647 0.900000 44028 10.00 + 1180.671 0.912500 44409 11.43 + 1182.719 0.925000 45173 13.33 + 1184.767 0.937500 45680 16.00 + 1185.791 0.943750 45973 17.78 + 1186.815 0.950000 46254 20.00 + 1187.839 0.956250 46464 22.86 + 1189.887 0.962500 46789 26.67 + 1192.959 0.968750 47083 32.00 + 1193.983 0.971875 47224 35.56 + 1196.031 0.975000 47454 40.00 + 1197.055 0.978125 47526 45.71 + 1199.103 0.981250 47673 53.33 + 1201.151 0.984375 47853 64.00 + 1202.175 0.985938 47950 71.11 + 1203.199 0.987500 48038 80.00 + 1204.223 0.989062 48131 91.43 + 1204.223 0.990625 48131 106.67 + 1206.271 0.992188 48227 128.00 + 1207.295 0.992969 48253 142.22 + 1209.343 0.993750 48331 160.00 + 1209.343 0.994531 48331 182.86 + 1210.367 0.995313 48392 213.33 + 1211.391 0.996094 48435 256.00 + 1211.391 0.996484 48435 284.44 + 1211.391 0.996875 48435 320.00 + 1212.415 0.997266 48468 365.71 + 1213.439 0.997656 48487 426.67 + 1214.463 0.998047 48537 512.00 + 1214.463 0.998242 48537 568.89 + 1214.463 0.998437 48537 640.00 + 1214.463 0.998633 48537 731.43 + 1214.463 0.998828 48537 853.33 + 1214.463 0.999023 48537 1024.00 + 1215.487 0.999121 48566 1137.78 + 1215.487 0.999219 48566 1280.00 + 1215.487 0.999316 48566 1462.86 + 1215.487 0.999414 48566 1706.67 + 1215.487 0.999512 48566 2048.00 + 1215.487 0.999561 48566 2275.56 + 1215.487 0.999609 48566 2560.00 + 1215.487 0.999658 48566 2925.71 + 1216.511 0.999707 48582 3413.33 + 1216.511 1.000000 48582 inf +#[Mean = 677.805, StdDeviation = 465.358] +#[Max = 1215.488, Total count = 48582] +#[Buckets = 27, SubBuckets = 2048] +---------------------------------------------------------- +68997 requests in 30.00s, 4.46MB read +Requests/sec: 2299.92 +Transfer/sec: 152.28KB + + +### 2000 RTS +wrk -d 30 -c 1 -t 1 -R 2000 -L -s /home/ravenhub/IdeaProjects/2024-highload-dht/src/main/java/ru/vk/itmo/test/volkovnikita/lua/stage1/get.lua http://127.0.0.1:8080 +Running 30s test @ http://127.0.0.1:8080 +1 threads and 1 connections +Thread calibration: mean lat.: 125.520ms, rate sampling interval: 429ms +Thread Stats Avg Stdev Max +/- Stdev +Latency 3.03ms 3.98ms 34.05ms 88.28% +Req/Sec 2.00k 33.36 2.14k 82.61% +Latency Distribution (HdrHistogram - Recorded Latency) +50.000% 1.40ms +75.000% 3.50ms +90.000% 7.66ms +99.000% 20.05ms +99.900% 32.37ms +99.990% 33.92ms +99.999% 34.08ms +100.000% 34.08ms + +Detailed Percentile spectrum: +Value Percentile TotalCount 1/(1-Percentile) + + 0.289 0.000000 1 1.00 + 0.608 0.100000 4007 1.11 + 0.827 0.200000 8017 1.25 + 1.020 0.300000 12022 1.43 + 1.216 0.400000 16038 1.67 + 1.401 0.500000 20050 2.00 + 1.515 0.550000 22028 2.22 + 1.709 0.600000 24031 2.50 + 2.026 0.650000 26035 2.86 + 2.627 0.700000 28035 3.33 + 3.503 0.750000 30038 4.00 + 4.019 0.775000 31043 4.44 + 4.555 0.800000 32049 5.00 + 5.139 0.825000 33042 5.71 + 5.931 0.850000 34046 6.67 + 6.775 0.875000 35046 8.00 + 7.187 0.887500 35548 8.89 + 7.655 0.900000 36045 10.00 + 8.147 0.912500 36552 11.43 + 8.767 0.925000 37050 13.33 + 9.647 0.937500 37550 16.00 + 10.087 0.943750 37800 17.78 + 10.695 0.950000 38052 20.00 + 11.367 0.956250 38299 22.86 + 12.367 0.962500 38550 26.67 + 13.207 0.968750 38799 32.00 + 13.767 0.971875 38925 35.56 + 14.263 0.975000 39051 40.00 + 15.031 0.978125 39174 45.71 + 15.999 0.981250 39300 53.33 + 17.263 0.984375 39428 64.00 + 17.647 0.985938 39490 71.11 + 18.303 0.987500 39551 80.00 + 19.311 0.989062 39612 91.43 + 20.591 0.990625 39675 106.67 + 22.159 0.992188 39739 128.00 + 22.895 0.992969 39769 142.22 + 23.839 0.993750 39800 160.00 + 25.023 0.994531 39831 182.86 + 26.191 0.995313 39864 213.33 + 27.615 0.996094 39894 256.00 + 28.399 0.996484 39910 284.44 + 28.767 0.996875 39927 320.00 + 28.927 0.997266 39942 365.71 + 29.167 0.997656 39957 426.67 + 29.599 0.998047 39972 512.00 + 30.191 0.998242 39980 568.89 + 30.415 0.998437 39988 640.00 + 30.735 0.998633 39996 731.43 + 31.711 0.998828 40004 853.33 + 32.495 0.999023 40011 1024.00 + 32.991 0.999121 40015 1137.78 + 33.471 0.999219 40019 1280.00 + 33.631 0.999316 40023 1462.86 + 33.695 0.999414 40027 1706.67 + 33.727 0.999512 40033 2048.00 + 33.727 0.999561 40033 2275.56 + 33.759 0.999609 40035 2560.00 + 33.791 0.999658 40037 2925.71 + 33.823 0.999707 40040 3413.33 + 33.855 0.999756 40043 4096.00 + 33.855 0.999780 40043 4551.11 + 33.855 0.999805 40043 5120.00 + 33.887 0.999829 40045 5851.43 + 33.887 0.999854 40045 6826.67 + 33.919 0.999878 40046 8192.00 + 33.919 0.999890 40046 9102.22 + 33.951 0.999902 40048 10240.00 + 33.951 0.999915 40048 11702.86 + 33.951 0.999927 40048 13653.33 + 33.951 0.999939 40048 16384.00 + 33.951 0.999945 40048 18204.44 + 34.015 0.999951 40049 20480.00 + 34.015 0.999957 40049 23405.71 + 34.015 0.999963 40049 27306.67 + 34.015 0.999969 40049 32768.00 + 34.015 0.999973 40049 36408.89 + 34.079 0.999976 40050 40960.00 + 34.079 1.000000 40050 inf +#[Mean = 3.031, StdDeviation = 3.985] +#[Max = 34.048, Total count = 40050] +#[Buckets = 27, SubBuckets = 2048] +---------------------------------------------------------- +59996 requests in 30.00s, 3.88MB read +Requests/sec: 1999.87 +Transfer/sec: 132.41KB + +![Histogram_get_2000.png](..%2Fdata%2Fstage1%2Fget%2FHistogram_get_2000.png) + +[get-cpu](..%2Fdata%2Fstage1%2Fget%2Fprofile-2000-get-cpu.html) + +[get-alloc](..%2Fdata%2Fstage1%2Fget%2Fprofile-2000-get-alloc.html) \ No newline at end of file