Play!Framework 1.2.3 VS IIS 7.5 + ASP.NET 4.0
大家好,我想说的是,我的小型基准测试显示 Play 的性能无法与 .net 相媲美,至少在我的小型笔记本电脑中是这样。详细内容如下:
播放代码
// Controller
public class Benchmark extends Controller {
@CacheFor
public static void hello() {
String who = "world";
render(who);
}
}
// View
hello ${who}!
ASP.Net 代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Benchmark.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>Hello <span id="spnName" runat="server"></span></p>
</div>
</form>
</body>
</html>
using System;
namespace Benchmark {
public partial class Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
spnName.InnerText = "world";
}
}
}
基准测试工具:ab,在同一台机器上运行:
`ab -n 10000 -c 100 http://localhost/`
播放结果:
Server Software: Play!
Server Hostname: localhost
Server Port: 80
Document Path: /
Document Length: 13 bytes
Concurrency Level: 100
Time taken for tests: 4.839 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 3650000 bytes
HTML transferred: 130000 bytes
Requests per second: 2066.42 [#/sec] (mean)
Time per request: 48.393 [ms] (mean)
Time per request: 0.484 [ms] (mean, across all concurrent requests)
Transfer rate: 736.57 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.5 0 7
Processing: 5 48 7.0 45 79
Waiting: 2 33 11.3 34 74
Total: 5 48 7.1 45 80
Percentage of the requests served within a certain time (ms)
50% 45
66% 47
75% 49
80% 53
90% 58
95% 62
98% 69
99% 72
100% 80 (longest request)
asp.net 结果:
Server Software: Microsoft-IIS/7.5
Server Hostname: localhost
Server Port: 80
Document Path: /
Document Length: 5160 bytes
Concurrency Level: 100
Time taken for tests: 3.806 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Non-2xx responses: 10000
Total transferred: 53780000 bytes
HTML transferred: 51600000 bytes
Requests per second: 2627.28 [#/sec] (mean)
Time per request: 38.062 [ms] (mean)
Time per request: 0.381 [ms] (mean, across all concurrent requests)
Transfer rate: 13798.35 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 2
Processing: 6 38 3.8 37 61
Waiting: 4 27 7.6 28 57
Total: 6 38 3.8 37 61
Percentage of the requests served within a certain time (ms)
50% 37
66% 38
75% 39
80% 40
90% 43
95% 44
98% 48
99% 51
100% 61 (longest request)
注意:
IIS 预热非常快,运行基准测试 2 次即可达到巅峰表现;而Play大约需要4到5次才能达到其极限。
播放在生产模式下开始。
更改 ab 的并发设置不会对结果 2 产生太大影响。 IIS 总是表现出色。
我的机器配置:HP 4720s上的Windows 7(32位),CPU:i5 M 430 2.27GHz 4核;内存 4GB
所以我有点沮丧,因为我是一个超级游戏迷,并且在这个平台上工作了 2 年多。有谁知道有什么方法可以提高 Play 的性能吗?
Hi I am a little bit to say that my little benchmark test shows Play's performance cannot match .net, at least in my little laptop. Here is the details:
Play Code
// Controller
public class Benchmark extends Controller {
@CacheFor
public static void hello() {
String who = "world";
render(who);
}
}
// View
hello ${who}!
ASP.Net code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Benchmark.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>Hello <span id="spnName" runat="server"></span></p>
</div>
</form>
</body>
</html>
using System;
namespace Benchmark {
public partial class Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
spnName.InnerText = "world";
}
}
}
benchmark tool: ab, running on the same machine:
`ab -n 10000 -c 100 http://localhost/`
Play result:
Server Software: Play!
Server Hostname: localhost
Server Port: 80
Document Path: /
Document Length: 13 bytes
Concurrency Level: 100
Time taken for tests: 4.839 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 3650000 bytes
HTML transferred: 130000 bytes
Requests per second: 2066.42 [#/sec] (mean)
Time per request: 48.393 [ms] (mean)
Time per request: 0.484 [ms] (mean, across all concurrent requests)
Transfer rate: 736.57 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.5 0 7
Processing: 5 48 7.0 45 79
Waiting: 2 33 11.3 34 74
Total: 5 48 7.1 45 80
Percentage of the requests served within a certain time (ms)
50% 45
66% 47
75% 49
80% 53
90% 58
95% 62
98% 69
99% 72
100% 80 (longest request)
asp.net result:
Server Software: Microsoft-IIS/7.5
Server Hostname: localhost
Server Port: 80
Document Path: /
Document Length: 5160 bytes
Concurrency Level: 100
Time taken for tests: 3.806 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Non-2xx responses: 10000
Total transferred: 53780000 bytes
HTML transferred: 51600000 bytes
Requests per second: 2627.28 [#/sec] (mean)
Time per request: 38.062 [ms] (mean)
Time per request: 0.381 [ms] (mean, across all concurrent requests)
Transfer rate: 13798.35 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.4 0 2
Processing: 6 38 3.8 37 61
Waiting: 4 27 7.6 28 57
Total: 6 38 3.8 37 61
Percentage of the requests served within a certain time (ms)
50% 37
66% 38
75% 39
80% 40
90% 43
95% 44
98% 48
99% 51
100% 61 (longest request)
Notes:
IIS warm up very quickly, run the benchmark test 2 times to reach it's peak performance; while it take about 4 or 5 times for Play to reach it's limitation.
play is started in prod mode.
changing concurrent setting of ab doesn't impact the result 2 much. IIS always out perform play.
the configuration of my machine: windows 7 (32bit) on HP 4720s, CPU: i5 M 430 2.27GHz 4 core; memory 4GB
So I am a little bit frustrated as I am a huge play fan and worked on this platform for over 2 years. Does anyone know any way to improve the performance of Play?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是我的经验;
Play 在 linux/ngix 或 linux/apache 上的运行速度比在 windows/iis 上快得多
play 的问题1.2.x 是它的常规(动态)渲染引擎;因此我建议使用 play 2 来提高性能并降低内存使用量。如您所知,play 2 的模板引擎基于静态编译的 scala 代码,我可以说 play 2 是我见过的最快的 Web 框架。
here are my experiences;
Play is working on linux/ngix or linux/apache much faster than on windows/iis
the problem with play 1.2.x is it's groovy (dynamic) rendering engine; so I recommend play 2 for performance and low memory usage. As you know play 2's template engine is based on static compiled scala code and I can say play 2 is the fastest web framework I've ever seen.
我认为您在 Play 1 中遇到了默认 Groovy 模板支持的糟糕性能。
在 Play 2 中,有一个更快的基于 scala 的模板引擎。
对于 Play 1,还实现了许多其他模板系统,即:我认为是 Japid。
另外:游戏 1 存在一个更快的 groovy 模板引擎实现,您可以在这里找到相关信息:http://kjetland.com/blog/2011/11/playframework-new-faster-groovy-template-engine/
I think you are experiencing the poor performance of the default groovy template support in play 1.
In Play 2, there is a faster scala-based template engine.
For Play 1 there is a number of other template systems implemented, ie: Japid i think.
Also: There exists a faster groovy template engine implementation for play 1 which you can find info about here: http://kjetland.com/blog/2011/11/playframework-new-faster-groovy-template-engine/
很多时候,我们看到围绕框架的“炒作”,找到真相的唯一方法是自己测试或寻找专业基准。我建议您检查基准测试结果“http:// /www.techempower.com/benchmarks/#section=data-r8&hw=i7&test=query”。您会惊讶地发现老式的“java servlet-raw”跻身顶级性能框架列表之列,忽略了围绕“非阻塞”、Scala、NodeJS 的流行语。
与 Play1 相比,Play2 可能具有更好的性能,但“内存使用率低”绝对不是事实。运行bootstrap Play1应用程序仅消耗50m内存,运行bootstrap Play2应用程序很容易消耗超过300m。
Many times we see "hypes" around framework and the only way to find the truth was testing by your own or look for professional benchmark. I suggest you to check the benchmark result "http://www.techempower.com/benchmarks/#section=data-r8&hw=i7&test=query". You would be surprised to know that old fashioned "java servlet-raw" was among the TOP performance framework list, ignoring the buzzwords around "Non-Blocking", Scala, NodeJS.
Play2 may have better performance compared to Play1, but "low memory usage" was definitely NOT TRUTH. Running bootstrap Play1 app consumes only 50m memory, running bootstrap Play2 app could easily consume more than 300m.