Play!Framework 1.2.3 VS IIS 7.5 + ASP.Net 4.0

时间:2012-01-24 07:10:53

标签: asp.net performance iis playframework benchmarking

您好我有点说我的小基准测试显示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)

注意:

  1. IIS非常快速预热,运行基准测试2次以达到峰值性能;虽然Play需要4到5次才能达到它的限制。

  2. 以prod模式启动播放。

  3. 更改ab的并发设置不会对结果产生太大影响。 IIS总是执行播放。

  4. 我的机器配置:HP 4720s上的Windows 7(32位),CPU:i5 M 430 2.27GHz 4核心;记忆4GB

  5. 所以我有点沮丧,因为我是一个巨大的粉丝,在这个平台上工作了2年多。有谁知道改善Play性能的方法吗?

3 个答案:

答案 0 :(得分:2)

这是我的经历;

  1. Play比linux / iis上的linux / ngix或linux / apache更快

  2. play 1.2.x的问题在于它的groovy(动态)渲染引擎;所以我建议播放2以获得性能和低内存使用率。如你所知,Play 2的模板引擎基于静态编译的scala代码,我可以说play 2是我见过的最快的Web框架。

答案 1 :(得分:0)

我认为你在游戏1中遇到了默认groovy模板支持的糟糕表现。

在Play 2中,有一个更快的基于scala的模板引擎。

对于Play 1,实现了许多其他模板系统,即:我认为是Japid。

另外:游戏1存在一个更快的groovy模板引擎实现,你可以在这里找到相关信息:http://kjetland.com/blog/2011/11/playframework-new-faster-groovy-template-engine/

答案 2 :(得分:0)

很多时候我们看到围绕框架的“炒作”,找到真相的唯一方法是自己测试或寻找专业基准。我建议你查看基准测试结果“http://www.techempower.com/benchmarks/#section=data-r8&hw=i7&test=query”。你会惊讶地发现老式的“java servlet-raw”是TOP性能框架列表中的一员,忽略了围绕“非阻塞”,Scala,NodeJS的流行语。

与Play1相比,Play2可能具有更好的性能,但“低内存使用率”绝对不是真的。运行引导程序Play1应用程序仅消耗50米内存,运行引导程序Play2应用程序可能轻松消耗超过300米。