<返回更多

Spring Native&Quarkus对比分析

2023-08-25  今日头条  阿拉尔的阳光
加入收藏

概述

Spring Reactive(Spring WebFlux) → 背靠 Pivotal → 归属 VMware → 归属戴尔
Quarkus 和 Vert.x → 背靠 Eclipse 基金会 → 主要由 Red Hat 支持
Helidon → 背靠 Oracle
Micronaut → 背靠 Object Computing(GrAIls、OpenDDS)
Lagom → 背靠 Lightbend(Akka)

对比分析

启动&构建指标对比

Spring Native&Quarkus对比分析

启动&构建指标对比

性能测试

资源版本

压测源码&镜像

native-sample: 基于spring native构建原生镜像示例

quarkus-sample: 基于quarkus构建原生镜像示例

Quarkus Native Image: guanyangsunlight/spring-project-samples:quarkus-sample-0.0.1-SNAPSHOT

Quarkus JVM Image: guanyangsunlight/spring-project-samples:quarkus-sample-0.0.1-SNAPSHOT-jvm

Spring Boot Native Image: guanyangsunlight/spring-project-samples:native-sample-0.0.1-SNAPSHOT

Spring Boot JVM Image: guanyangsunlight/spring-project-samples:native-sample-0.0.1-SNAPSHOT-jvm

MySQL Image: guanyangsunlight/spring-project-samples:sample-mysql-8.0.32

quarkus-sample: quarkus-sample/src/main/docker/docker-compose.yml

native-sample: native-sample/src/main/docker/docker-compose.yml

压测架构

Spring Native&Quarkus对比分析

压测架构

压测场景case

压测服务接口

{
    "code": 200,
    "message": "OK",
    "data": {
        "id": 4,
        "version": 1,
        "deleted": 0,
        "createBy": "admin",
        "updateBy": "admin",
        "createTime": 1695312514000,
        "updateTime": 1695312532000,
        "username": "test41"
    }
}

压测脚本

k6 run  -u 50 --duration 300s -e url=http://127.0.0.1:8082/api/test/get/4 simple-test.js

-i:指定请求数量
-u:模拟并发数量
--duration:请求时长定义,例如:60s,1m
-e url:指定环境变量url,用于实际场景替换
  scenarIOS: (100.00%) 1 scenario, 50 max VUs, 36s max duration (incl. graceful stop):
           * default: 50 looping VUs for 6s (gracefulStop: 30s)


     ✓ is status 200

     checks.........................: 100.00% ✓ 7761        ✗ 0   
     data_received..................: 1.9 MB  324 kB/s
     data_sent......................: 730 kB  121 kB/s
     http_req_blocked...............: avg=12.22µs min=1µs    med=3µs     max=3.26ms   p(90)=5µs     p(95)=6µs    
     http_req_connecting............: avg=7.1µs   min=0s     med=0s      max=2.19ms   p(90)=0s      p(95)=0s     
     http_req_duration..............: avg=38.56ms min=7.55ms med=34.26ms max=216.77ms p(90)=58.96ms p(95)=68.51ms
       { expected_response:true }...: avg=38.56ms min=7.55ms med=34.26ms max=216.77ms p(90)=58.96ms p(95)=68.51ms
     http_req_failed................: 0.00%   ✓ 0           ✗ 7761
     http_req_receiving.............: avg=52.57µs min=19µs   med=46µs    max=680µs    p(90)=81µs    p(95)=97µs   
     http_req_sending...............: avg=19.87µs min=7µs    med=16µs    max=1.27ms   p(90)=27µs    p(95)=38µs   
     http_req_tls_handshaking.......: avg=0s      min=0s     med=0s      max=0s       p(90)=0s      p(95)=0s     
     http_req_waiting...............: avg=38.49ms min=7.51ms med=34.18ms max=216.58ms p(90)=58.89ms p(95)=68.46ms
     http_reqs......................: 7761    1288.780058/s
     iteration_duration.............: avg=38.7ms  min=7.76ms med=34.4ms  max=218.51ms p(90)=59.08ms p(95)=68.64ms
     iterations.....................: 7761    1288.780058/s
     vus............................: 50      min=50        max=50
     vus_max........................: 50      min=50        max=50
import http from 'k6/http';
import { check } from 'k6';

export default function () {
  const res = http.get(`${__ENV.url}`);
  check(res, {
    'is status 200': (r) => r.status === 200
  });
}

压测指标

被压机器指标

被压机器性能指标

压测结果

Spring Native&Quarkus对比分析

压测结果

压测总结

优缺点及选型总结

Quarkus优缺点

Spring Boot Native优缺点

技术选型思考

在实际决策过程中,最好能够根据具体情况进行技术选型,可能的话,可以在小规模的项目或者原型中尝试并评估这些框架。

Quarkus对Spring开发者的额外好处

参考文档

关键词:Spring      点击(8)
声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多Spring相关>>>