Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Modern Flask

性能基准

以 gunicorn 为服务器,以 --workers 1 --threads 1 为性能基准

目的是为了在容器环境下,以 1 CPU 为基准进行调度

配置

Flask.config

使用环境变量 CONFIG_SOURCE 来判断配置来源,只支持 Python 类型

  • 本地文件
    • xxxx.py
  • Kubernetes 资源
    • kubernetes://[NAMESPACE]/configmaps/[NAME]/[KEY]
    • kubernetes://[NAMESPACE]/secrets/[NAME]/[KEY]
    • kubernetes://configmaps/[NAME]/[KEY]
    • kubernetes://secrets/[NAME]/[KEY]
  • HTTP 资源
    • http://xxxxx.xxxx/xxxx.py
    • https://xxxxx.xxxx/xxxx.py

默认为本地文件 config.py

可观测性

可观测性框架基于 OpenTelemetry,使用 Zipkin 作为导出格式

默认启用了对以下组件的观测

  • logging
  • flask
  • sqlalchemy
  • redis

可以使用 Flask.config 的 SERVICE_NAME 自定义 service.name

配置来源于标准环境变量,详细参考:

指标使用 Prometheus,暴露于 /metrics 路径下

数据库

使用 SQLAlchemy 库

Engine 配置来自于 Flask.config, 前缀 DATABASE_ENGINE_, 参考配置如下:

DATABASE_ENGINE_URL = "sqlite+pysqlite:///:memory:"
DATABASE_ENGINE_ECHO = True
DATABASE_ENGINE_FUTURE = True

详细参考 https://github.com/sqlalchemy/sqlalchemy/blob/533f5718904b620be8d63f2474229945d6f8ba5d/lib/sqlalchemy/engine/create.py#L43

Session 配置来自于 Flask.config, 前缀 DATABASE_SESSION_, 参考配置如下:

DATABASE_SESSION_AUTOFLUSH = False

详细参考 https://github.com/sqlalchemy/sqlalchemy/blob/533f5718904b620be8d63f2474229945d6f8ba5d/lib/sqlalchemy/orm/session.py#L3866

Redis

使用 Redis 库, 配置来自于 Flask.config, 前缀 REDIS_, 参考配置如下:

REDIS_HOST = "127.0.0.1"

详细参考 https://github.com/redis/redis-py/blob/12c17bfc436ea6784bbc8b2d327d981520858eb7/redis/client.py#L853

存储

目前只支持 Qcloud COS

配置来自于 Flask.config,前缀 STORAGE_,参考配置如下

STORAGE_VENDOR = "cos"

STORAGE_SECRET_ID = "xxxxxxxxx"
STORAGE_SECRET_KEY = "xxxxxxxxx"
STORAGE_REGION = "ap-guangzhou"
STORAGE_ENDPOINT = "xxx.xxx.com"

详细参考 https://github.com/tencentyun/cos-python-sdk-v5/blob/3b6e2f1bdf28ebd7e29a211105c8f4dc6b46eddd/qcloud_cos/cos_client.py#L36

许可证

Guo Y.K., MIT License

Metadata

Release files for modern-flask 202112b3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modern-flask 202112b3
File Size Uploaded
modern-flask-202112b3.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modern-flask 202112b3
File Interpreter ABI Platform
modern_flask-202112b3-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / modern-flask-202112b3.tar.gz

Download URL modern-flask-202112b3.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
22f5d496327ecb63c4e52b585dc257f208c232b820735ee89e4c11f91218576b
BLAKE2b-256 checksum
How to use checksums
862bc56a72243bbad0a52c37a8de6f39aa1231852357fa461dce49ecf61d2db0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

Release files / modern_flask-202112b3-py3-none-any.whl

Download URL modern_flask-202112b3-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9528b10ef4e7e98fd7eac2527e0e1d4f20276a6efe43112a034dc09fced2376
BLAKE2b-256 checksum
How to use checksums
bed5cf83b3fd217c9df82100790f53c40cc1299754a7a3db59c4cb96a25ef77d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page