6 ms·
Flask _does_ scale really well with lines of codes. However the limitations of Python w.r.t. async log really start to show once you step beyond simple CRUD ap
by nicodjimenez 9y ago
Flask _does_ scale really well with lines of codes. However the limitations of Python w.r.t. async log really start to show once you step beyond simple CRUD apps.
- Rapzid 9y agoThis was my experience. Just exited a startup that relied on Python heavily. Built a flask-restful based back end with SQL Alchemy.. Never had any issues with flask per say, but it made me happy I know languages with far better tooling and concurrency experience/performance :)
- chucky_z 9y agoDid you ever attempt to use PyPy? Flask works with it, and in my experience the handful of times I've needed Python to be more performant, PyPy got me there easily. My use-case was I was doing a heavy part of an ETL pipeline out of MySQL and it was taking an unreasonable amount of time. PyPy was a roughly ~8x speedup, which ended up being faster than doing direct manipulation with MySQL via the cli (!!!).
- oneweekwonder 9y agoFor interest sake, can SQLAlchemy run on PyPy; pgsql driver support? thanks,
- sirn 9y agoSQLAlchemy can run on PyPy, but you have to use pg8000 (pure Python) or psycopg2cffi (cffi port) instead of psycopg2 for pg.
- fermigier 9y agoI haven't used it in production (only made some benchmarks), but the recommended approach is to use the pg8000 driver (https://github.com/mfenniak/pg8000 https://github.com/mfenniak/pg8000) with pypy, instead of psycopg.
- zzzeek 9y agouse psycopg2cffi: https://pypi.org/project/psycopg2cffi/ https://pypi.org/project/psycopg2cffi/
- joshuamorton 9y agoJust use sanic. It's a mostly drop in replacement for flask that is async first and runs on uvloop.
- gusmd 9y agoQuart is another option. Even more of a "drop-in replacement" than sanic.
- bpicolo 9y agoThe unfortunate bit is you lose out on so much of the ecosystem going hard on asyncio right now though (like sqlalchemy orm).
- aserafini 9y agoaiohttp + pee wee async is the best combination available right now IMO. A fully asyncio app with pleasant non-blocking ORM and migrations.
- bpicolo 9y agoI'll have to give that a shot sometime. :) Haven't used peewee before, as sqlalchemy has mostly been tremendous. That said, if I'm starting a new project where I'm pretty sure I need async io, I'm not sure Python is my first choice. It's got decent facilities but compared to other ecosystems it's not as mature there
- abhishekjha 9y agoCan you elaborate a little more on `limitations of Python w.r.t. async log`? I have switched to Django + Gunicorn which seems to be handling requests just fine.
- nicodjimenez 9y agoI meant async logic. So that means things like worker threads and messaging. It's more of a limitation of Python as a language than anything else. As bad as NodeJS is, the fact that it's underpinned by an event loop makes it more powerful with async stuff. Golang is better, though a little funkier.