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
作为导出格式
默认启用了对以下组件的观测
- logging
- flask
- sqlalchemy
- redis
可以使用 Flask.config
的 SERVICE_NAME
自定义 service.name
配置来源于标准环境变量,详细参考:
- https://opentelemetry-python.readthedocs.io/en/latest/exporter/zipkin/zipkin.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
存储
目前只支持 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"
许可证
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-202112b1.tar.gz
.
File metadata
- Download URL: modern-flask-202112b1.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc92191101aa51c51e37024570770068d96754e7cd4e92a258b2a1d58e4d92cf |
|
MD5 | d9f0eefaf67ac9b96ff72e874522d730 |
|
BLAKE2b-256 | 3b8c8a633e6efd02fece1538831482ed33d4d9e5dd3a540743259b8f5b9e2c26 |
File details
Details for the file modern_flask-202112b1-py3-none-any.whl
.
File metadata
- Download URL: modern_flask-202112b1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2325df9c83373402b25eaa9ae026a58df2f2326092267145999fb97c14a750a4 |
|
MD5 | 8f01340d95f79fa352792bcdc35b00ac |
|
BLAKE2b-256 | f347514092eb6c7b041f627594a32768214c7b45276196d2fd22f850011fe3c7 |