SQLAlchemy / Flask / PostgreSQL pool connection

前端 未结 3 724
半阙折子戏
半阙折子戏 2021-02-19 02:34

After having played for a long time with Django, I\'m trying a bit of Flask with SQLAlchemy, and I must say I quite like it. However there is something that I don\'t get: I have

3条回答
  •  悲哀的现实
    2021-02-19 03:24

    Every worker of your flask instance running a proper wsgi server with multiple workers will have it's own engine - because your script is loaded for every worker separately.

    In consequence you have simply no control about the real pooling, except you limit your worker threads of wsgi server and calculate the max allowed connections per engine/pool instance.

    Further details can be read at https://docs.sqlalchemy.org/en/13/core/pooling.html#using-connection-pools-with-multiprocessing

提交回复
热议问题