gpt4 book ai didi

django - Jython + Django 尚未准备好进行生产?

转载 作者:行者123 更新时间:2023-12-04 01:52:44 26 4
gpt4 key购买 nike

所以最近我在 Jython 平台上玩弄 Django,想看看它在“生产”中的表现。我测试的网站只是一个简单的 return HttpResponse("Time %.2f" % time.time())查看,所以不涉及数据库。
我尝试了以下两种组合(使用 ab -c15 -n500 -k <url> 完成的测量,VirtualBox 上的 Ubuntu Server 10.10 中的所有内容):

  • J2EE 应用服务器(Tomcat/Glassfish),已部署的 WAR 文件

    我得到的结果是
    Requests per second:    143.50 [#/sec] (mean)
    [...]
    Percentage of the requests served within a certain time (ms)
    50% 16
    66% 16
    75% 16
    80% 16
    90% 31
    95% 31
    98% 641
    99% 3219
    100% 3219 (longest request)

    显然,服务器偶尔会挂掉几秒钟,这是 Not Acceptable 。我认为这与重新加载 Jython 有关,因为启动 jython shell 也需要大约 3 秒。
  • AJP 服务使用修补的 flup 包(+ Apache 作为前端)

    注意:flup 是 manage.py runfcgi 使用的包,我不得不修补它,因为 flup 的线程/ fork 支持似乎不适用于 Jython(-> AJP 是唯一的工作方法)。

    这里的结果几乎相同,但有时最后 100 个请求甚至根本没有得到答复(但服务器进程仍然存在)。

  • 我在 SO(而不是 serverfault)上问这个,因为它非常特定于 Django/Jython。 有没有人有在 Jython 上部署 Django 站点的经验?是否有另一种(更快)的方式来为网站提供服务?还是现在在 Java 平台上使用 Django 还为时过早?

    最佳答案

    因此,没有人回答,我进行了更多调查,似乎我的问题可能与 VirtualBox 有关。使用不同的服务器操作系统(Debian Squeeze、Ubuntu Server),我遇到了类似的问题。例如,通过简单的静态文件服务,我从 Apache 网络服务器(在 Debian 上)得到了这个结果:

    > ab -c50 -n1000 http://ip.of.my.vm/some/static/file.css

    Requests per second: 91.95 [#/sec] (mean) <--- quite impossible for static serving
    [...]
    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 2 22.1 0 688
    Processing: 0 206 991.4 31 9188
    Waiting: 0 96 401.2 16 3031
    Total: 0 208 991.7 31 9203

    Percentage of the requests served within a certain time (ms)
    50% 31
    66% 47
    75% 63
    80% 78
    90% 156
    95% 781
    98% 844
    99% 9141 <--- !!!!!!
    100% 9203 (longest request)
    这导致得出的结论是(我没有结论,但是)我认为 Java 重新加载可能不是这里的问题,而是虚拟化。我将在真正的主机上进行尝试,直到那时才回答这个问题。

    跟进
    现在,我在 Apache 上使用 Jython + AJP 通过 TCP/mod_proxy_ajp 成功测试了一个基本的 Django 站点(实际上只是欢迎页面)(再次使用修补过的 flup 包)。这次是在真实主机上(i7 920,6 GB RAM)。结果证明我的上述假设是正确的,我真的不应该再次在虚拟主机上进行基准测试。这是欢迎页面的结果:
    Document Path:          /jython-test/
    Document Length: 2059 bytes

    Concurrency Level: 40
    Time taken for tests: 24.688 seconds
    Complete requests: 20000
    Failed requests: 0
    Write errors: 0
    Keep-Alive requests: 0
    Total transferred: 43640000 bytes
    HTML transferred: 41180000 bytes
    Requests per second: 810.11 [#/sec] (mean)
    Time per request: 49.376 [ms] (mean)
    Time per request: 1.234 [ms] (mean, across all concurrent requests)
    Transfer rate: 1726.23 [Kbytes/sec] received

    Connection Times (ms)
    min mean[+/-sd] median max
    Connect: 0 1 1.5 0 20
    Processing: 2 49 16.5 44 255
    Waiting: 0 48 16.5 44 255
    Total: 2 49 16.5 45 256

    Percentage of the requests served within a certain time (ms)
    50% 45
    66% 48
    75% 51
    80% 53
    90% 69
    95% 80
    98% 90
    99% 97
    100% 256 (longest request) # <-- no multiple seconds of waiting anymore
    非常有希望,我会说。唯一的缺点是平均请求时间 > 40 ms,而开发服务器的平均值 < 3 ms。

    关于django - Jython + Django 尚未准备好进行生产?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4996823/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com