dmwm / WMCore

Core workflow management components for CMS.
Apache License 2.0
46 stars 107 forks source link

Consider migration from CherryPy to Flask for WMCore #8962

Open vkuznet opened 5 years ago

vkuznet commented 5 years ago

Recently @vkuznet implemented support of x509-scitokens [1] and SSO [2] for cmsweb frontend. Both of them relies on using Flask+WSGI for cmsweb. Also @vkuznet presented concurrency studies [3] which shows that usage of Flask+WSGI may speed-up python web-based frameworks up to 30%. This brings the question: should we consider a migration of WMCore+CherryPy stack to WMCore+Flask+WSGI one. A proof-of-concept for DBS server used in [3] studies can be found here [4]. In particular, @vkuznet used Flask with DBS server, see lines 455-519 for Flask specific code. It also provides an example of dealing with DB connection and setting up pool of dbs agents. The Flask code basically wrap existing class into series of end-point and if we have clear separation of business and web logic the migration can be done easily.

I suggest to do evaluation of new technology and may be use spring, summer students to work on providing migration from CherryPy to Flask technology.

Best, Valentin.

[1] https://github.com/dmwm/deployment/pull/706 [2] https://github.com/dmwm/deployment/pull/711 [3] https://indico.cern.ch/event/705389/contributions/2894815/attachments/1599683/2535722/WebConcurrencyStudies.pdf [4] https://gist.github.com/vkuznet/70afa8aa2a8af314a3ecae6796c569b2

amaltaro commented 5 years ago

Thanks for these links, Valentin. I'll look into it later this week

amaltaro commented 1 month ago

I've just seen this article comparing Flask with FastAPI: https://www.turing.com/kb/fastapi-vs-flask-a-detailed-comparison

A few things are not clear to me, but I think it is worth it to share it.

In addition, Unified frontend has been (re-)implemented in FastAPI, so @hassan11196 would be a good person to talk to about experience with FastAPI, eventually.

vkuznet commented 1 month ago

I suggest to pay attention to the following characteristics:

ls venv/lib/python3.11/site-packages | wc -l 75


- benefits of framework, e.g. if your framework provides X throughput but your business logic handles only Y where `Y >> X` your entire throughput will be driven by Y rather than X. As such a simple switch of a web framework may not be beneficial if underlying app logic will not be improved.