Conversation
7ab7036 to
3c1b336
Compare
| } | ||
|
|
||
| try { | ||
| HttpResponse<String> response = sender.send(url); |
There was a problem hiding this comment.
Use asynchronous sending (or a thread pool). Otherwise, the calls may block and the required RPC performance cannot be achieved
There was a problem hiding this comment.
This is a limitation of the current implementation. The next issue (#10 ) introduces Virtual Threads — each request will be submitted to a Virtual Thread pool so the main loop is not blocked.
| while (System.nanoTime() < sendNextTime) { | ||
| // busy-wait | ||
| } |
There was a problem hiding this comment.
At high RPS sleep precision can become a problem — we can overshoot the interval. Should I combine both approaches (sleep for most of the wait, then busy-wait for the last ~1ms), or is Thread.sleep() acceptable for now?
There was a problem hiding this comment.
Thread.sleep is a simple way, but there are other delay options
Using a loop doesn’t look very reliable to me
| this.targetRps = targetRPS; | ||
| this.durationSeconds = durationSeconds; |
| private WireMockServer wireMock; | ||
| private String baseUrl; | ||
|
|
||
| @BeforeEach |
There was a problem hiding this comment.
add AfterEach for closing sender
| try (HttpSender sender = new HttpSender()) { | ||
| sender.send(baseUrl + "/test"); |
There was a problem hiding this comment.
HttpClient warmup. The first request takes 2-3 seconds due to internal initialization. Without this RPS accuracy tests fail because most of the test duration is spent on the cold start.
There was a problem hiding this comment.
In that case, it should be in the source code, not in the test code
What
Implement basic Load Engine with RPS throttling. The engine sends GET requests to a specified URL at a given rate and stops after the specified duration.
Changes:
LoadEngineclass withstart()andstop()methodsHow to verify
./mvnw test
Closes #2