Appengine, performance degradation with python27

前端 未结 6 898
天涯浪人
天涯浪人 2021-01-31 10:03

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 perfor

相关标签:
6条回答
  • 2021-01-31 10:10

    Python 2.7 support is still experimental. One aspect of being new and experimental is that it hasn't had the kind of performance baking and tuning that Python 2.5 has.

    0 讨论(0)
  • 2021-01-31 10:10

    As far as I know, Python 2.7 should be faster than 2.5. However, there are some factors that can influence speeds:

    • The way the binary is compiled;
    • Whether your libraries (such as Memcache) are compiled as C(++) or Python. A C++ module is, of course, faster than the Python equivalent;
    • The server it's on - I haven't ever used App Engine but I'd assume that a server only runs either Python 2.5 or Python 2.7, since mixing them would be a waste of resources. If the 2.7 servers are used a lot more than the 2.5 servers and App Engine hasn't compensated for this, you'll notice the performance go down as well.

    These are the first 3 things that I came up with, but there are a lot of factors. Even the weather could in theory affect performance.

    0 讨论(0)
  • 2021-01-31 10:14

    By swtiching to python2.7 my app performance under load is 3x worse.

    With 2.5:

    Connection Times (ms) min mean[+/-sd] median max Connect: 36 48 15.4 41 109 Processing: 685 3010 1893.3 2657 9255 Waiting: 685 3009 1893.3 2656 9255 Total: 725 3058 1900.5 2711 9333

    Percentage of the requests served within a certain time (ms) 50% 2711 66% 3287 75% 3896 80% 4521 90% 6146 95% 7078 98% 7934 99% 8413 100% 9333 (longest request)

    With 2.7:

    Connection Times (ms) min mean[+/-sd] median max Connect: 35 46 11.4 41 96 Processing: 1076 7614 4190.5 6711 32284 Waiting: 1075 7614 4190.5 6711 32283 Total: 1124 7660 4195.5 6764 32353

    Percentage of the requests served within a certain time (ms) 50% 6764 66% 7790 75% 8751 80% 9392 90% 10844 95% 13139 98% 25219 99% 27259 100% 32353 (longest request)

    0 讨论(0)
  • 2021-01-31 10:15

    A quote from google itself

    Experimental!

    The Python 2.7 runtime is an experimental, innovative, and rapidly changing new feature for App Engine. Unfortunately, being on the bleeding edge means that we may make backwards-incompatible changes. We will inform the community once the Python 2.7 runtime is no longer experimental.

    They haven't really made it for production use yet , Its like beta testing .

    So keep your application in python2.7 till the experimental phase is over.

    You can also try uploading only the compiled .pyc files because python27 runtime supports bytecode upload

    0 讨论(0)
  • Did you migrated your application to use WSGI instead of CGI when run on python 2.7?

    It is possible that CGI interface is just a wrapper around WSGI that is enabled for 2.7 now.

    0 讨论(0)
  • 2021-01-31 10:26

    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.

    0 讨论(0)
提交回复
热议问题