modern flask framework
Project description
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
或者 Jaeger
作为导出格式, 默认启用了对以下组件的观测
- logging
- flask
- sqlalchemy
- redis
切换导出格式
使用 Flask.config
配置项 OTEL_EXPORTER
切换 zipkin
和 jaeger
设置 service.name
Flask.config
配置项SERVICE_NAME
- 环境变量,
JAEGER_SERVICE_NAME
(以支持jaeger-operator
)
设置其他参数
所有 Flask.config
中,以 OTEL_
开头的配置会自动写入环境变量,用以配置 OpenTelemetry
的其他组件
详细参考:
- https://opentelemetry-python.readthedocs.io/en/latest/exporter/zipkin/zipkin.html
- https://opentelemetry-python.readthedocs.io/en/latest/exporter/jaeger/jaeger.html
- https://opentelemetry-python-contrib.readthedocs.io/en/latest/instrumentation/logging/logging.html
指标
使用标准 Prometheus 库,暴露于 /metrics
路径下
数据库
使用 SQLAlchemy
库
Engine
配置来自于 Flask.config
, 前缀 DATABASE_ENGINE_
, 参考配置如下:
DATABASE_ENGINE_URL = "sqlite+pysqlite:///:memory:"
DATABASE_ENGINE_ECHO = True
DATABASE_ENGINE_FUTURE = True
Session
配置来自于 Flask.config
, 前缀 DATABASE_SESSION_
, 参考配置如下:
DATABASE_SESSION_AUTOFLUSH = False
Redis
使用 Redis
库, 配置来自于 Flask.config
, 前缀 REDIS_
, 参考配置如下:
REDIS_HOST = "127.0.0.1"
详细参考 https://github.com/redis/redis-py/blob/12c17bfc436ea6784bbc8b2d327d981520858eb7/redis/client.py#L853
存储
目前只支持 腾讯云 COS 和 阿里云 OSS
配置来自于 Flask.config
,前缀 STORAGE_
,参考配置如下
腾讯云 COS
STORAGE_VENDOR = "cos"
STORAGE_SECRET_ID = "xxxxxxxxx"
STORAGE_SECRET_KEY = "xxxxxxxxx"
STORAGE_REGION = "ap-guangzhou"
STORAGE_ENDPOINT = "xxx.xxx.com"
阿里云 OSS
STORAGE_VENDOR = "oss"
STORAGE_ACCESS_KEY_ID = ""
STORAGE_ACCESS_KEY_SECRET = ""
STORAGE_ENDPOINT = ""
STORAGE_BUCKET = ""
详细参考 https://pypi.org/project/oss2/
许可证
Guo Y.K., MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file modern-flask-202112b7.tar.gz
.
File metadata
- Download URL: modern-flask-202112b7.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 741f73e15d88fef87b8b097fad1ab8fc4bfb4008fdef6d3f3e772f0f66e79aa0 |
|
MD5 | 20f1184a3a0710e2ac44b6766427c098 |
|
BLAKE2b-256 | a80f704230c8c3b5f9668bc4d02d763c941ac75f112aec95b25fa5e90de5e9b9 |
File details
Details for the file modern_flask-202112b7-py3-none-any.whl
.
File metadata
- Download URL: modern_flask-202112b7-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c1b25347d0bbfbbcc7e1da0696cdbd6c0ebd68b4220de97bc9035cc8ad2055b |
|
MD5 | 6a0d942a12d69f52d519ab6f2c3582f4 |
|
BLAKE2b-256 | 4e7d4ca7320f3275a2a5e529ac859503d2ae11bf01cc4ed83afc7b527570926f |