Closed mebest100 closed 2 years ago
Hi, For this use case, you should definitely not use workers. Perhaps you can post a small snippet of what your verticle does? However we can only do some wild guessing about what's wrong. I would recommend to explore web-client-examples and, for a complete introduction, to get a copy of the Vert.x In Action book (disclaimer: I'm a co-worker of the author).
@tsegismont Thanks for your reply, the small fake code snippet of my vertile is just as follow FYI ` WebClient client = WebClient.create(vertx); router.route("/testpath").handler( ctx -> { ... code logic to get request params ... requestData = getReqData() client.postabs(requestData.getUrl()) .sendJsonObject(requestData.getPayload(),result -> { ... code logic to use result to get final Result ...
ctx.response().end(FinalResult) })
} ) `
The turn out shows the tps is very low , seems somewhere is blocked, but I don't know what's wrong with the code. Thanks for your guide and advice
I can't see anything obviously wrong here. But there are many factors that can change the results of your benchmark, for example: number of verticle instances, http pool size.
@tsegismont If I use setInstances(), it will report error of Can't specity >1 instances for already created verticle when the project started.(Btw I use the spring framework of service comb(CSE) not purely springboot) what's the root cause? And I also had set http pool size for web client by SetMaxPoolSize(), but it does not work, the TPS still very low.
And Then I just build a simplest router and just response by fixed string just like below code:
router.route("/testpath").handler( ctx -> {ctx.response().end("OK")}
The TPS can be at good level of over 900.
But The TPS will be bad so long as add web client into router with the simplest logic as below.
router.route("/testpath").handler( ctx -> { client.postabs(ApiUrl) .send(res -> { ctx.response().end("OK") }) }
You can see we almost do nothing and just return fixed string in callback of web client when do post request. No complicated logic here, but the TPS very low at only 200(versus previous 900), and with bad response latency at over 900 ms but the actually the called Api just with latency at 200 ms,
obviouly abnormal, and seems blocked somewhere.
Want your comments for above. Thx!
About the error, that's probably because you use the vertx.deployVerticle
method that takes a verticle instance as argument. Use the method which takes a Supplier
instead.
I can't say much more. I would advise to post complete details about your benchmark on the user group (not everyone in the community is subscribed to GH issues). Someone might give a try and help you troubleshoot.
Hi, I'm trying to re-construct for springboot from synchronous to asynchronous by vertx, the target is raise TPS. But now encounter a problem, you know it's time-costing operation for post request calling to a rest api, the logics is we need to first to get result based on a post request by vertx-web-client, and then use the response to do some operations and re-assembly it to produce the final result in vertx-router.
I have tryied to used normal handler, blocking handler, and even executeblocking method, but the final result turned out a bad tps at only at 10 which is far below it is original in springboot. Obviously there must be blocking, but I don't know what' wrong with it exactly.
Hence my question is How to run vertx web client in router correcty and return response after calling rest api by web-client. What is the correct way to organize code for vertx when in such case. Pls help. Thx!