Appengine,python27性能下降 [英] Appengine, performance degradation with python27

查看:114
本文介绍了Appengine,python27性能下降的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在appengine上测试python27,所以我从python25迁移了我的应用程序。对于每个请求,性能都比两倍慢!然后我又回到了python25,性能再次像以前一样。这里是一张图片:




(毫秒/请求)(cgi handler python 27,then python25)

我的应用使用 Werkzeug Jinja2 ,以及使用memcache非常多。什么原因会导致性能急剧下降?或者仅仅是因为appengine上的python2.7仍然处于测试阶段?



有关应用程序的一些细节:



这是相当简单的网上商店。有一些延期的PDF生成任务,但这些并不会影响整体图形,因为头版页面的命中率最高。几乎所有东西都是memcached。它需要约0.8秒的空缓存来加载一个页面的Python 2.5。加载非缓存页面需要很长时间,主要是因为有许多db查询。缓存页面在60〜100 ms内加载。平均加载时间约为150毫秒。用Python 2.7的性能很糟糕。非高速缓存页面需要2秒才能加载。缓存页面的加载时间超过200毫秒。



不幸的是,我没有任何分析数据,我也不知道python 2.7中的东西究竟是什么放慢了。



我的页面加载时间数是从实时页面收集的,服务时间为10 req / sec,1个驻留python25实例可轻松处理此加载。



我还测试了python 2.7与wsgi和 threadsafe:yes ,但与python 2.7和cgi相比,性能仅提高一点。

解决方案

Usenet on Usenet 我从Google上看到这样的声明:在某些情况下,他的Python 2.7运行时速度比Python 2.5运行时慢,而在其他情况下速度更快,我们现在还没有公布原因。似乎没有人发现迄今为止2.7的速度比2.5快的情况...因此...

我读到这个


  1. Google知道有问题。

  2. 他们不知道如何处理它。

我的分析表明python 2.7多线程应用程序花费了大约。他们有35%的时间在 {method'acquire'of'thread.lock'objects} - 并且看起来发生在gooles RPC代码中。还有迹象表明,导入有严重的锁定问题。



基本上,除了等待AppEngine修复它之外,你无能为力。另请参阅有关放缓的此综合文档



几乎可以肯定不会在这方面发挥重要作用的因素包括:


  • 上传pyc文件(GAE基础架构为您完成)

  • 服务器配置(GAE是如此巨大的规模,甚至在内测2.7中也很慢)

  • WSGI与CGI(不会解释如此巨大的性能影响)



  • 丑陋的是Google大幅提价两步,但告诉我们通过使用多线程Python 2.7,你可以更有效地运行新的价格,看起来不那么糟糕。不幸的是Python 2.7。运行时仍被标记为实验性,并且不能提供生产质量性能。

    I wanted to test python27 on appengine so I have migrated my app from python25. Performance got more than 2x slower for every request! Then I've returned to python25 and performance is again as it was before. Here is a picture:

    (milliseconds/request) (cgi handler python 27, then python25)

    My app uses Werkzeug, Jinja2, and memcache is used quite alot. What reasons can cause such a dramatic decrease in performance? Or is it just because python2.7 on appengine is still in beta?

    Some details about application:

    It is quite simple online shop. There are some deferred tasks with pdf generation however these don't affect overall graph much because the front page gets most hits. Nearly everything is memcached. It takes up to ~0.8 sec with empty cache to load a page with python 2.5. Non-cached pages takes long to load mainly because there are many db queries. Cached pages load in 60~100 ms. Average load time is ~150 ms. With python 2.7 performance is terrible. Non-cached pages takes 2+ secs to load. Cached pages load in 200+ ms.

    Unfortunately I don't have any profiling data and I can't tell what exactly slows things down in python 2.7.

    My numbers for page-load time are collected from live page which serves ~10 req/sec and 1 resident python25 instance easily deals with this load.

    I have also tested python 2.7 with wsgi and threadsafe:yes, but performance improved just a little compared to python 2.7 and cgi.

    解决方案

    Somewhere on Usenet I read a statement like this from Google "he Python 2.7 runtime is slower than the Python 2.5 runtime in some cases and faster in others. We aren't publicizing the reasons why at this point.". Seems nobody has found so far a scenario where 2.7 is faster than 2.5 thus ...

    I read into this

    1. Google is aware of a preformace issue.
    2. They not sure how to handle it.

    My profiling indicates that python 2.7 multithreaded applications spend ca. 35 % of their time in {method 'acquire' of 'thread.lock' objects} - and seemingly that happens in googles RPC code. There are also indication that importing has serious locking issues.

    Basically you can't do anything about it except waiting for the AppEngine to fix it. See also this comprehensive documentation about the slowdown.

    Factors which almost certainly don't play a significant role in this are:

    • uploading pyc files (the GAE infrastructure does that for you)
    • the server provisioning (GAE is such a massive scale and even in closed beta 2.7. was slow)
    • WSGI vs. CGI (wouldn't explain such a huge performance hit)

    The ugly thing is that Google did a massive price hike in two steps but told us "by using multithreaded python 2.7 you can run so much more effective that the new prices don't look so bad". Unfortunately the Python 2.7. runtime is still labeled "experimental" and doesn't deliver production quality performance.

    这篇关于Appengine,python27性能下降的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆