原生Quarkus应用程序是否比JVM上的应用程序更好?

原生Quarkus应用程序是否比JVM上的应用程序更好?,quarkus,Quarkus,我正在比较不同可执行文件中的相同Quarkus应用程序,包括常规jar、快速jar和本机可执行文件。为了能够比较它们,我运行了相同的性能测试 结果如下: 常规Jar,从0.904s开始。关于性能,结果如下所示: Running 1m test @ http://localhost:8080/hello 2 threads and 10 connections Thread Stats Avg Stdev Max +/- Stdev Latency 361.86

我正在比较不同可执行文件中的相同Quarkus应用程序,包括常规jar、快速jar和本机可执行文件。为了能够比较它们,我运行了相同的性能测试

结果如下:

  • 常规Jar,从
    0.904s
    开始。关于性能,结果如下所示:

    Running 1m test @ http://localhost:8080/hello
    2 threads and 10 connections
    Thread Stats   Avg      Stdev     Max   +/- Stdev
      Latency   361.86us    4.48ms 155.85ms   99.73%
      Req/Sec    29.86k     4.72k   37.60k    87.83%
    3565393 requests in 1.00m, 282.22MB read
    Requests/sec:  59324.15
    Transfer/sec:      4.70MB
    
    Running 1m test @ http://localhost:8080/hello
    2 threads and 10 connections
    Thread Stats   Avg      Stdev     Max   +/- Stdev
      Latency   344.38us    3.89ms 142.71ms   99.74%
      Req/Sec    27.21k     6.52k   40.67k    73.48%
    3246932 requests in 1.00m, 257.01MB read
    Requests/sec:  54025.50
    Transfer/sec:      4.28MB
    
    Running 1m test @ http://localhost:8080/hello
    2 threads and 10 connections
    Thread Stats   Avg      Stdev     Max   +/- Stdev
      Latency   303.72us  471.86us  29.00ms   98.05%
      Req/Sec    19.03k     3.21k   30.19k    78.75%
    2272236 requests in 1.00m, 179.86MB read
    Requests/sec:  37867.20
    Transfer/sec:      3.00MB
    
  • 快速Jar,从
    0.590s
    开始。关于性能,结果如下所示:

    Running 1m test @ http://localhost:8080/hello
    2 threads and 10 connections
    Thread Stats   Avg      Stdev     Max   +/- Stdev
      Latency   361.86us    4.48ms 155.85ms   99.73%
      Req/Sec    29.86k     4.72k   37.60k    87.83%
    3565393 requests in 1.00m, 282.22MB read
    Requests/sec:  59324.15
    Transfer/sec:      4.70MB
    
    Running 1m test @ http://localhost:8080/hello
    2 threads and 10 connections
    Thread Stats   Avg      Stdev     Max   +/- Stdev
      Latency   344.38us    3.89ms 142.71ms   99.74%
      Req/Sec    27.21k     6.52k   40.67k    73.48%
    3246932 requests in 1.00m, 257.01MB read
    Requests/sec:  54025.50
    Transfer/sec:      4.28MB
    
    Running 1m test @ http://localhost:8080/hello
    2 threads and 10 connections
    Thread Stats   Avg      Stdev     Max   +/- Stdev
      Latency   303.72us  471.86us  29.00ms   98.05%
      Req/Sec    19.03k     3.21k   30.19k    78.75%
    2272236 requests in 1.00m, 179.86MB read
    Requests/sec:  37867.20
    Transfer/sec:      3.00MB
    
  • 本机,从
    0.011s
    开始。关于性能,结果如下所示:

    Running 1m test @ http://localhost:8080/hello
    2 threads and 10 connections
    Thread Stats   Avg      Stdev     Max   +/- Stdev
      Latency   361.86us    4.48ms 155.85ms   99.73%
      Req/Sec    29.86k     4.72k   37.60k    87.83%
    3565393 requests in 1.00m, 282.22MB read
    Requests/sec:  59324.15
    Transfer/sec:      4.70MB
    
    Running 1m test @ http://localhost:8080/hello
    2 threads and 10 connections
    Thread Stats   Avg      Stdev     Max   +/- Stdev
      Latency   344.38us    3.89ms 142.71ms   99.74%
      Req/Sec    27.21k     6.52k   40.67k    73.48%
    3246932 requests in 1.00m, 257.01MB read
    Requests/sec:  54025.50
    Transfer/sec:      4.28MB
    
    Running 1m test @ http://localhost:8080/hello
    2 threads and 10 connections
    Thread Stats   Avg      Stdev     Max   +/- Stdev
      Latency   303.72us  471.86us  29.00ms   98.05%
      Req/Sec    19.03k     3.21k   30.19k    78.75%
    2272236 requests in 1.00m, 179.86MB read
    Requests/sec:  37867.20
    Transfer/sec:      3.00MB
    
本机应用程序中处理的请求数量大约比JVM Quarkus应用程序少100万。然而,本机应用程序的启动时间、平均值和Stdev比其他应用程序要好


我想知道为什么会发生这种情况,以及本机应用程序是否优于JVM。

本机quarkus应用程序的启动时间和内存消耗肯定会更好。这是因为quarkus扩展了graalvm的原生图像概念

本机映像是一个处理应用程序所有类的实用程序 以及它们的依赖关系,包括来自JDK的依赖关系。它是静态的 分析这些数据以确定哪些类和方法是可用的 可在应用程序执行期间访问。然后提前完成 将可访问的代码和数据编译为 特定的操作系统和体系结构

由于应用程序是通过提前编译处理的,并且使用的JVM(也称为底层VM)只包含基本部分,因此与JVM相比,生成的程序具有更快的启动时间和更低的运行时内存开销