CherryPy performance testing on Python 2.7 / 3.9 / 3.10 by Locust!
Created:22-04-17 17:30
Updated:23-01-28 22:56
I am both a fan of Python and its web framework CherryPy. Recently I upgraded one of my CherryPy-powered sites from Python 2.7 / CherryPy 17.4.2 to Python 3.X / CherryPy 18.6.1. Using the 2to3 tool, the code migration from Python 2 to 3 was surprisingly easy, I only need to manually change a very small portion of the code. After upgrading, I was curious if the migration would have any performance impacts, so I used the Python powered Locust load testing tool (I am impress by it!), to do a load testing on my test machine (Surface Go 2 - Intel Core M3 8100Y (1.10GHz) 8GB Memory), which on the same time, runs 3 instances of my CherryPy testing site:
The testing results are all good news! I was quite surprised that the speed difference was so huge between Python 2.7 instance and Python 3.9 instance, and Python 3.10 instance was even a little bit better! ** Concurrency: 150 users **
It's worth mentioning, that the tested site is not a "hello world" project, it's a small real-world site that reads contents from SQLite backend database, and renders pages by the Jinja2 template engine, cookies and sessions are also used, after processing the outputed page size loaded by Locust were about 30 Kb in average. Also, consider it's running on a dual core Surface, I'm quite happy with the performance.
P.S. Why I am still a fan of the old CherryPy instead of more popular micro frameworks like Flask and FastAPI? Because IMHO, if it is used in production, Flask or FastAPI needs another production-ready WSGI HTTP Server, the officially recommended one is gunicorn, but it's only available under UNIX, while I am a mostly windows user... CherryPy / Cheroot can also be this WSGI server, but why shouldn't I use cherrypy as an All-in-One solution? ***See also: *** |
|