Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
PyCon2013China_Bj_DAE
Search
Zoom.Quiet
December 20, 2013
Technology
0
200
PyCon2013China_Bj_DAE
http://cn.pycon.org/2013/beijing
洪强宁 DAE系统的设计
Zoom.Quiet
December 20, 2013
Tweet
Share
More Decks by Zoom.Quiet
See All by Zoom.Quiet
PyCon2014China-Zhuhai-high performance
zoomquiet
0
160
PyCon2014China-Zhuhai-meta programming
zoomquiet
1
130
PyCon2014China-Zhuhai-bpm.py
zoomquiet
0
110
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
93
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
100
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
120
PyCon2014China-Zhuhai-jeff
zoomquiet
0
89
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
120
DevFest2014-Zhuhai-Polymer
zoomquiet
0
420
Other Decks in Technology
See All in Technology
ソースを読むプロセスの例
sat
PRO
15
9.7k
OSSで50の競合と戦うためにやったこと
yamadashy
3
880
クラウドとリアルの融合により、製造業はどう変わるのか?〜クラスメソッドの製造業への取組と共に〜
hamadakoji
0
270
Claude Code Subagents 再入門 ~cc-sddの実装で学んだこと~
gotalab555
10
17k
OCIjp_Oracle AI World_Recap
shinpy
1
150
コンパウンド組織のCRE #cre_meetup
layerx
PRO
0
160
HonoとJSXを使って管理画面をサクッと型安全に作ろう
diggymo
0
150
LLMプロダクトの信頼性を上げるには?LLM Observabilityによる、対話型音声AIアプリケーションの安定運用
ivry_presentationmaterials
0
740
AI-Readyを目指した非構造化データのメダリオンアーキテクチャ
r_miura
1
270
会社を支える Pythonという言語戦略 ~なぜPythonを主要言語にしているのか?~
curekoshimizu
1
260
Zephyr(RTOS)にEdge AIを組み込んでみた話
iotengineer22
1
240
AWS UG Grantでグローバル20名に選出されてre:Inventに行く話と、マルチクラウドセキュリティの教科書を執筆した話 / The Story of Being Selected for the AWS UG Grant to Attending re:Invent, and Writing a Multi-Cloud Security Textbook
yuj1osm
1
110
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
920
Navigating Team Friction
lara
190
15k
Code Reviewing Like a Champion
maltzj
526
40k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.1k
Become a Pro
speakerdeck
PRO
29
5.6k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Designing Experiences People Love
moore
142
24k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
Transcript
DAE PyCon China 2013
About Me • 洪强宁 / hongqn • 2002年开始接触Python • 2004年开始完全使⽤用Python⼯工
作 • 2006年加⼊入⾖豆瓣,现任⾸首席架 构师 • www.douban.com/people/ hongqn/ •
[email protected]
议程 • DAE是什么 • 为什么要开发DAE • DAE的架构 • DAE的特点 •
DAE的未来
None
DAE是什么
Douban Adorable Engineers
Douban Adorable Engineers Douban App Engine
Douban Adorable Engineers Douban App Engine
PaaS
Platform as a Service (PaaS)
PaaS
PaaS Private
PaaS Private Python
Current State
427 apps
427 apps 126 对外应⽤用
bubbler.labs.douban.com
m.douban.com
douban.fm
movie.douban.com
group.douban.com
code
up
花名册
精灵宝钻
…等等
每天处理 2.4 亿动态请求 5K 峰值 qps on 32 nodes
None
为什么要开发DAE
代码拆分
代码拆分 1 big svn repo (17万提交)
代码拆分 1 big svn repo (17万提交) 4602 git repo (2881
fork)
重⽤用基础设施 Proj A Proj B Proj C Proj D MySQL,
BeansDB, Memcache, MQ …
简化新项⺫⽬目启动 $ dae create $ dae serve $ dae deploy
最佳实践对 每个app开箱即⽤用
最佳实践对 每个app开箱即⽤用 持续集成
最佳实践对 每个app开箱即⽤用 持续集成 分级上线
最佳实践对 每个app开箱即⽤用 持续集成 分级上线 状态收集
最佳实践对 每个app开箱即⽤用 持续集成 分级上线 状态收集 故障报告
Scale SA
Scale SA 4
None
DAE的架构
基础公共服务 运⾏行环境 路由系统 依赖 管理 部署系统 资源管理 系统
app.yaml
pip-req.txt $ dae install flask
pip-req.txt $ dae install flask PyPI 镜像 pypi.douban.com
pip-req.txt $ dae install flask
Instance
Instance • web
Instance • web • gunicorn
Instance • web • gunicorn • service
Instance • web • gunicorn • service • gunicorn +
customized worker
Instance • web • gunicorn • service • gunicorn +
customized worker • daemon
Instance • web • gunicorn • service • gunicorn +
customized worker • daemon • zookeeper
预定义 handler • 预定义 URL • 预定义 query parameter •
预定义 message queue
两级结构 Load Balancer (nginx) Gateway (nginx) App (gunicorn) App Starter
unix socket fallback start Node 1 Gateway (nginx) App (gunicorn) App Starter Node 2
基础服务API • mysql • memcache • doubandb, doubanfs • moosefs
• beanstalkd • cdn • statsd + graphite • mail • elastic search • irc waylife 监控API调⽤用
部署 部署界⾯面 部署服务 控制命令 部署进度 节点 Load Balancer 节点 (via
websocket) ⽣生成配置 更新路由 节点 应⽤用⾃自检 更新代码 重启应⽤用
DAE升级 dev集群 (master branch) beta集群 (beta branch) stable集群 (release branch)
测试应⽤用 对内应⽤用 对外应⽤用 持续集成
None
DAE的特点
Low Overhead
Low Overhead • 资源分配 — 进程
Low Overhead • 资源分配 — 进程 • 资源隔离 — UNIX帐号
Low Overhead • 资源分配 — 进程 • 资源隔离 — UNIX帐号
• 资源限制 — 外部监控
Customizable
Customizable • 每个应⽤用从模板⽣生成nginx配置
Customizable • 每个应⽤用从模板⽣生成nginx配置 • 使⽤用 hook point 定制
Customizable • 每个应⽤用从模板⽣生成nginx配置 • 使⽤用 hook point 定制 • 或者只使⽤用⽣生成的
nginx 配置⽚片段
⾃自依赖
⾃自依赖 • 通过⼀一个应⽤用部署应⽤用
⾃自依赖 • 通过⼀一个应⽤用部署应⽤用 • 通过⼀一个应⽤用管理应⽤用
⾃自依赖 • 通过⼀一个应⽤用部署应⽤用 • 通过⼀一个应⽤用管理应⽤用 • ⼀一个应⽤用 scale 所有应⽤用
⾃自依赖 • 通过⼀一个应⽤用部署应⽤用 • 通过⼀一个应⽤用管理应⽤用 • ⼀一个应⽤用 scale 所有应⽤用 •
⼀一个应⽤用 serve 跨应⽤用的静态⽂文件
⾃自依赖 • 通过⼀一个应⽤用部署应⽤用 • 通过⼀一个应⽤用管理应⽤用 • ⼀一个应⽤用 scale 所有应⽤用 •
⼀一个应⽤用 serve 跨应⽤用的静态⽂文件 • DAE 的代码托管在⼀一个 DAE 应⽤用上
gevent
gevent • 默认启⽤用
gevent • 默认启⽤用 • ⽀支持⻓长连接,如 websocket
gevent • 默认启⽤用 • ⽀支持⻓长连接,如 websocket • 节省内存
gevent • 默认启⽤用 • ⽀支持⻓长连接,如 websocket • 节省内存 • 很多坑
gevent • 默认启⽤用 • ⽀支持⻓长连接,如 websocket • 节省内存 • 很多坑
greenify 已开源 github.com/douban/greenify
gevent • 默认启⽤用 • ⽀支持⻓长连接,如 websocket • 节省内存 • 很多坑
Service 是⼀一等公民
Service 是⼀一等公民 • Thrift
Service 是⼀一等公民 • Thrift • 在线客户端⽣生成
Service 是⼀一等公民 • Thrift • 在线客户端⽣生成 • 依赖注册
Service 是⼀一等公民 • Thrift • 在线客户端⽣生成 • 依赖注册 • 升级通知
Service 是⼀一等公民 • Thrift • 在线客户端⽣生成 • 依赖注册 • 升级通知
thriftclient 即将开源
Service 是⼀一等公民 • Thrift • 在线客户端⽣生成 • 依赖注册 • 升级通知
收集⼤大量状态数据
内置最佳实践
内置最佳实践 • 错误收集 - sentry
内置最佳实践 • 错误收集 - sentry • 在线 profile ⼯工具
内置最佳实践 • 错误收集 - sentry • 在线 profile ⼯工具 •
预发布环境
内置最佳实践 • 错误收集 - sentry • 在线 profile ⼯工具 •
预发布环境 • 持续集成
内置最佳实践 • 错误收集 - sentry • 在线 profile ⼯工具 •
预发布环境 • 持续集成 • Code集成
内置最佳实践 • 错误收集 - sentry • 在线 profile ⼯工具 •
预发布环境 • 持续集成 • Code集成 • 打包发布
内置最佳实践 • 错误收集 - sentry • 在线 profile ⼯工具 •
预发布环境 • 持续集成 • Code集成 • 打包发布 • 分级上线
内置最佳实践 • 错误收集 - sentry • 在线 profile ⼯工具 •
预发布环境 • 持续集成 • Code集成 • 打包发布 • 分级上线 • 服务地址实时推送
内置最佳实践 • 错误收集 - sentry • 在线 profile ⼯工具 •
预发布环境 • 持续集成 • Code集成 • 打包发布 • 分级上线 • 服务地址实时推送 cfgpusher 即将开源
内置最佳实践 • 错误收集 - sentry • 在线 profile ⼯工具 •
预发布环境 • 持续集成 • Code集成 • 打包发布 • 分级上线 • 服务地址实时推送
不受限的Python环境
不受限的Python环境 • 可⽤用C扩展
不受限的Python环境 • 可⽤用C扩展 • 可⽤用 fork, subprocess, multiprocessing…
不受限的Python环境 • 可⽤用C扩展 • 可⽤用 fork, subprocess, multiprocessing… 曹娥已开源 github.com/douban/CaoE
不受限的Python环境 • 可⽤用C扩展 • 可⽤用 fork, subprocess, multiprocessing…
None
DAE的未来
⾖豆瓣所有应⽤用的平台
cgroups
离线⼤大数据计算
更好的 service 体系
跨 IDC
QoS
公有云服务?
开源?
开源!
开源!
谢谢!