Java REST 的 Grails 与 Spring 性能
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23001609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Grails vs Spring performance for REST
提问by Vahid Pazirandeh
I've created some REST endpoints using pure Groovy/Grails. For now most of the operations are all CRUD-like.
我已经使用纯 Groovy/Grails 创建了一些 REST 端点。目前大多数操作都是类似 CRUD 的。
I'm beginning to compare the performance of the Grails app to an equivalent Java/Spring app for the CRUD scenarios that I've made, using JMeter. So now I'm taking a subset of the scenarios I've implemented in Grails and porting to a basic Spring MVC app.
我开始使用 JMeter 将 Grails 应用程序的性能与我制作的 CRUD 场景的等效 Java/Spring 应用程序的性能进行比较。所以现在我将我在 Grails 中实现的场景的一个子集移植到一个基本的 Spring MVC 应用程序。
I'm very interested in seeing performance comparisons published by others on the web.Can anyone refer me to some?
我对查看其他人在网络上发布的性能比较非常感兴趣。有人可以给我推荐一些吗?
Any other information in regards to the testing and analysis I'm going to do is welcome. Thanks!
欢迎提供有关我将要进行的测试和分析的任何其他信息。谢谢!
UPDATE REGARDING THE ANSWER:
关于答案的更新:
- @Lari's answer below references a website with extremely comprehensive tests, comparing Grails 2.Xvs Spring 4.X(see README.md), in addition to a multitude of other frameworks.
- However, those tests have Grails running on Resinwhile Spring is on Tomcat. A little strange to me since Grails uses Tomcat by default.
- Resin and Tomcat arguably have similar performance.
- The website has several sections (tabs on top) and even subsections (tabs in the "Results" area). My original question was regarding web service behavior for REST. To that end here are the top-level sections that answered my question:
- Querying multiple rows in a DB table(HTTP GET) and returning JSON array as result.
- Modifying multiple rows in a DB tableand returning JSON array as result. This test does not use HTTP PUT with a body, but instead HTTP GET. Scroll to bottom of page for details, and also Requirementspage.
- If you're interested in HTML rendering see the Fortune Cookieexample.
- @Lari 下面的回答引用了一个网站,其中包含非常全面的测试,比较了Grails 2.X与Spring 4.X(请参阅 README.md),以及众多其他框架。
- 然而,这些测试让Grails 在 Resin上运行,而Spring 在 Tomcat 上运行。对我来说有点奇怪,因为 Grails 默认使用 Tomcat。
- Resin 和 Tomcat 可以说具有相似的性能。
- 该网站有几个部分(顶部的选项卡)甚至子部分(“结果”区域中的选项卡)。我最初的问题是关于 REST 的 Web 服务行为。为此,这里是回答我的问题的顶级部分:
- 查询数据库表中的多行(HTTP GET) 并返回 JSON 数组作为结果。
- 修改数据库表中的多行并返回 JSON 数组作为结果。此测试不使用带有正文的 HTTP PUT,而是使用 HTTP GET。滚动到页面底部了解详细信息,以及需求页面。
- 如果您对 HTML 渲染感兴趣,请参阅Fortune Cookie示例。
Not surprisingly Spring is better, but like @Joshua points out, this is a contrived example and you will have to be the judge of what to extrapolate from the results. Not to mention that Grails used Resin while Spring used Tomcat. Hopefully each server (Tomcat / Resin) was configured similarly in terms of max threads, Java memory, etc? The config files may be buried in the source code(if you find out, let me know).
不足为奇的是 Spring 更好,但就像 @Joshua 指出的那样,这是一个人为的例子,你必须判断从结果中推断出什么。更不用说 Grails 使用 Resin 而 Spring 使用 Tomcat。希望每个服务器(Tomcat / Resin)在最大线程数、Java 内存等方面的配置类似?配置文件可能隐藏在源代码中(如果你发现了,请告诉我)。
I also setup dummy applications for Spring 4.X vs Grails 2.X, with Tomcat being configured exactly the same (both used the same standalone Tomcat installation rather than one bundled inside Grails). In my tests I performed an HTTP GET and returned a JSON array which was formed using static (pre-instantiated) in-memory objects (no DB query). My results also showed better performance for Spring (sorry I can't find my data any longer!). I used Spring Boot to slap a Spring app together quickly, and Grails already has scaffolding by default.
我还为 Spring 4.X 和 Grails 2.X 设置了虚拟应用程序,Tomcat 的配置完全相同(两者都使用相同的独立 Tomcat 安装,而不是捆绑在 Grails 中的一个)。在我的测试中,我执行了 HTTP GET 并返回了一个 JSON 数组,该数组是使用静态(预实例化)内存对象(无数据库查询)形成的。我的结果还显示了 Spring 更好的性能(抱歉,我再也找不到我的数据了!)。我使用 Spring Boot 快速将 Spring 应用程序组合在一起,Grails 默认已经有了脚手架。
采纳答案by Lari Hotari
There is http://www.techempower.com/benchmarks/. The source codeis at github.
有http://www.techempower.com/benchmarks/。的源代码是在github上。
回答by Mr. Cat
Take a look at this PLAY VS. GRAILS SMACKDOWNpresentation. You can find some results of perfomance inside.
看看这个PLAY VS。GRAILS SMACKDOWN演示文稿。你可以在里面找到一些性能的结果。