【发布时间】:2022-01-25 23:20:41
【问题描述】:
Vert.X 的一个优点是它的性能,但我看不出与我的测试有什么不同,有人知道为什么吗?测试只是打印 hello。
我还执行了请求 Google(Vert.x 中的异步请求)然后打印响应的测试。它还表明 2 个框架具有相同的性能。
Vert.x 代码:
public class MainVerticle extends AbstractVerticle {
static String HELLO = "hello";
@Override
public void start(Promise<Void> startPromise) throws Exception {
vertx.createHttpServer().requestHandler(req -> {
req.response()
.putHeader("content-type", "text/plain")
.end(HELLO );
}).listen(8888, http -> {
if (http.succeeded()) {
startPromise.complete();
System.out.println("HTTP server started on port 8888");
} else {
startPromise.fail(http.cause());
}
});
}
}
弹簧代码:
@SpringBootApplication
@RestController
public class DemoApplication {
static String HELLO = "hello";
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@GetMapping("/")
public String hei(){
return HELLO;
}
}
Apache Benchmark(从另一台机器调用):
ab -n 50000 -c 10 http://192.168.1.115:8888/
【问题讨论】:
标签: spring spring-boot vert.x