[译]Quarkus 与 Spring Boot:全方位对比

作者:Samuel Catalano

原文地址

https://medium.com/@samuelcatalano/quarkus-vs-spring-boot-a-head-to-head-comparison-3b9502c0a345

译者注:本文按照意思翻译,而不是直译。翻译时尽可能让译文符合汉语的表达习惯。

When it comes to building microservices and other cloud-native applications, there are many options available to developers. Two popular frameworks that have been gaining traction in recent years are Quarkus and Spring Boot. Both frameworks have their own set of features and capabilities, but which one is the best for your project? In this article, we'll take a head-to-head look at Quarkus and Spring Boot to help you decide.

当开发微服务或其他云原生应用时,开发者们有许多可选项。最近几年比较受关注的两个流行框架是 Quarkus 和 Spring Boot。二者有各自的一套功能和能力,但对你的项目来说,哪个才是最好的?这里我们进行一次 Quarkus 和 Spring Boot 的全方位对比来帮助你选择。

Performance 性能

One of the biggest advantages of Quarkus is its performance. Quarkus is a Kubernetes native framework, which means it is designed to run in a containerized environment. It uses an Ahead-of-Time (AOT) compiler to pre-compile Java bytecode into native code, resulting in faster startup times and lower memory usage. This is a significant advantage when it comes to running applications in cloud environments, where resources are often limited.

Quarkus 最大的优势之一就是性能。Quarkus 是 Kubernetes 原生的框架,也就是说,它是按照在容器化环境中运行来设计的。它用一种 Ahead-of-Time(AOT)编译器将 Java 字节码提前编译成原生机器码,所以它启动更快且占用内存更小。云环境常常是资源受限的,当程序在云环境中运行时,Quarkus 的这个特点是显著的优势。

On the other hand, Spring Boot is a traditional Java framework, which means it uses the Java Virtual Machine (JVM) to run applications. While Spring Boot can also run in a containerized environment, it doesn’t have the same level of performance optimization as Quarkus.

另一方面,Spring Boot 是传统的 Java 框架,也就是说,它用 Java 虚拟机(JVM)来运行应用。尽管 Spring Boot 也能在容器化环境中运行,但它达不到 Quarkus 那种程度的性能优化。

Framework size 框架大小

One of the biggest differences between Spring Boot and Quarkus is the size of the frameworks themselves. Spring Boot is a well-established and feature-rich framework, but it comes with a lot of dependencies that can increase the size of your application. This may not be an issue for some applications, but it can be a problem if you’re deploying to resource-constrained environments, such as Kubernetes pods.

Spring Boot 和 Quarkus 之间最大的不同之一就是框架本身占据(硬盘)空间的大小。Spring Boot 完善而且功能丰富,但它有大量的依赖项,会增加你的程序大小。对有些程序来说这不是问题,但如果你要把程序部署在资源受限的环境(如 Kubernetes Pod),就可能有问题。

On the other hand, Quarkus is a relatively new framework that's been designed from the ground up to be "supersonic, subatomic Java." This means that it has a much smaller runtime footprint compared to Spring Boot, which can make it more suitable for resource-constrained environments. Quarkus also has a feature to optimize the size of the application using the native-image for GraalVM.

另一方面,Quarkus 框架相对较新,一开始就被设计为“超音速(快)、亚原子(小)Java”。这意味着它占据的空间比 Spring Boot 要小很多,也就更适合资源受限的环境。此外,Quarkus 还有通过 GraalVM 把程序编译成原生代码的功能,以此来优化程序大小。

Startup time 启动时间

Another important consideration when choosing a framework is startup time. Spring Boot applications typically have longer startup times, which can be an issue if you’re deploying to a cloud environment or using serverless functions.

选择框架的另一个考量点就是启动时间。Spring Boot 的启动时间比较长,如果你把程序部署到云环境或 Serverless 服务上,这是个问题。

Quarkus, on the other hand, is optimized for fast startup time. This makes it a great choice for scenarios where you need to spin up a lot of instances quickly, such as with serverless functions or cloud deployments.

而 Quarkus 对启动时间进行了专门的优化。这让它成为了需要快速启动大量实例场景(云环境或 Serverless 服务)下的绝佳选择。

Development mode 开发模式

Both Spring Boot and Quarkus have built-in development modes that allow for fast iteration and hot reloading of code changes. This can be a huge productivity boost for developers, as it allows them to see the changes in the application immediately without having to rebuild and redeploy the entire application.

Spring Boot 和 Quarkus 的开发模式都支持代码改动的快速迭代和热重载。这能大大提高开发者的生产力,因为这样可以让他们能够立即看到程序中的更改,而不需要重新构建和部署整个程序。

Development Experience 开发体验

Quarkus and Spring Boot both offer similar development experiences. Both frameworks use an annotation-based programming model and provide a wide range of features to help developers build applications quickly and easily. However, Quarkus does have some unique features that make it stand out. For example, Quarkus has a live reload feature, which allows developers to make changes to their application and see the changes reflected in real-time, without having to rebuild the entire application.

Quarkus 和 Spring Boot 的开发体验类似。这两个都使用基于注解的编程模型,并提供各式各样的功能来帮助开发者快速、轻松地编写程序。 然而 Quarkus 有一些独特的功能。比如说,Quarkus 有实时重加载功能,允许开发者在修改代码后可以立即看到程序行为的变化,不需要重新构建。

Spring Boot also has a live reload feature but it's a third-party plugin that is not as seamless as Quarkus.

Spring Boot 也有这个功能,但它以第三方插件的形式提供,不像 Quarkus 那样无缝自带。

Support and Community 支持与社区

Spring Boot has been around for much longer than Quarkus, and as such, it has a much larger community and a more extensive ecosystem of plugins and libraries. This means that there is a wealth of resources available for developers who are using Spring Boot, including a wide range of tutorials, guides, and sample code.

Spring Boot 出现得比 Quarkus 早得多,因此,它有更大的社区以及更广泛的插件、库以及背后的生态系统。这意味着使用 Spring Boot 的开发者可以获得非常丰富的资料,包括各种教程、指南、代码例子。

Quarkus is a relatively new framework, but it has been gaining traction quickly. The Quarkus community is still smaller than Spring Boot, but it is growing rapidly. While there may be fewer resources available for Quarkus developers, the community is very active and responsive to questions and issues.

Quarkus 比较新,但它已经很快地受到关注了。Quarkus 社区现在仍比 Spring Boot 的社区小,但正在快速壮大。虽然 Quarkus 的开发者可用的资料可能少些,但社区非常活跃并且也积极地回应问题。(这里的“问题”包括 question 和 issue。——译者注)

Comparison Table 对比表

略。

Conclusion 结论

Both Quarkus and Spring Boot are excellent frameworks for building microservices and cloud-native applications. Quarkus offers superior performance and a unique live-to-reload feature, while Spring Boot has a larger community and a more extensive ecosystem of plugins and libraries. The choice between the two frameworks will depend on your specific project requirements and the skills of your development team.

Quarkus 和 Spring Boot 都构建微服务和云原生应用的优质框架。前者有不俗的性能和独特的实时重载入功能,后者有更大的社区和更广泛和生态(包括插件、库之类的)。它们之间的选择取决于你的具体项目和团队的技术栈。

If you need a framework that offers maximum performance and a streamlined development experience, Quarkus might be the better choice. Its Kubernetes native design and AOT compiler allow for faster startup times and lower memory usage, making it ideal for cloud-native environments. Additionally, its live reload feature allows for real-time changes without the need for a full rebuild, making the development process more efficient.

如果你需要的是一个提供尽可能高的性能并简化开发体验的框架,Quarkus 比较好。它的 Kubernetes 原生设计理念和 AOT 编译可以让程序有更快的启动时间和更少的内存消耗,这让它成为云原生环境的理想选择。此外,实时重载入功能也能让开发更高效。

On the other hand, if you prefer a more established framework with a larger community and more resources, Spring Boot might be the way to go. Its long-standing presence in the Java ecosystem and its vast community of developers means that there are a wealth of resources available for developers to use, including tutorials, guides, and sample code.

另一方面,如果你倾向于更大的社区以及更丰富的资源的成熟框架,Spring Boot 比较好。它在 Java 生态圈中的成熟且有庞大的社区,开发者能用的资源和资料(教程、指南、代码例子)都比较充足。

Ultimately, the best choice will depend on your specific use case and the needs of your team. Both Quarkus and Spring Boot are powerful and capable frameworks, and either one can be a great choice for your project.

最终结论,哪个好取决于你的具体情况和团队的需要。它俩都功能强大,能力范围广,无论哪个(在场景合适的情况下)都会成为你的优选。

posted @   风华神使  阅读(1602)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· winform 绘制太阳,地球,月球 运作规律
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示