Hi, In an attempt to speed up an application I came across a bottle neck with Python Scripts in Zope. Using apache's 'ab' utility I tested a simple query (sql_course_components) directly with the following URL: ab -n 20 -c 4 'http://myserver/portal_skins/acs/sql_course_components/manage_test?gcom_id= 19030&term_code=200405&SUBMIT=Submit+Query' ----- Requests per second: 23.22 [#/sec] (mean) Using a Python Script (ptest) to return the result from the query is much slower: return context.sql_course_components(gcom_id=19030, term_code=200405) ab -n 20 -c 4 'http://myserver/portal_skins/acs/ptest' ----- Requests per second: 2.59 [#/sec] (mean) I tried the same test with an external method with similar results. Why is there such a big difference between accessing the ZSQL query directly and using a python script (which is needed to process the query in the real application) to return the query? TIA, Sion
Sion Morris wrote at 2005-1-10 17:13 +0000:
In an attempt to speed up an application I came across a bottle neck with Python Scripts in Zope.
Using apache's 'ab' utility I tested a simple query (sql_course_components) directly with the following URL:
ab -n 20 -c 4 'http://myserver/portal_skins/acs/sql_course_components/manage_test?gcom_id= 19030&term_code=200405&SUBMIT=Submit+Query'
----- Requests per second: 23.22 [#/sec] (mean)
Using a Python Script (ptest) to return the result from the query is much slower:
return context.sql_course_components(gcom_id=19030, term_code=200405)
ab -n 20 -c 4 'http://myserver/portal_skins/acs/ptest'
----- Requests per second: 2.59 [#/sec] (mean)
Note, that what you do in the two cases is not the same! In the first case, you pass strings as arguments and get back a string. In the second case, you pass integers as arguments and get back an object (a "Shared.DC.ZRDB.Results.Results" instance). This must be converted to a string by the response object. While it is surprising that the first case seems to be about an order of magnitude faster, it might be explained (not sure!) that the queries are different or the string conversion is different. I recommend to use a profiler to analyse precisely where the time is used. A candidate would be ZopeProfiler: <http://www.dieter.handshake.de/pyprojects/zope> -- Dieter
participants (2)
-
Dieter Maurer -
Sion Morris