Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
PyCon2013China_Bj_DAE
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Zoom.Quiet
December 20, 2013
Technology
230
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PyCon2013China_Bj_DAE
http://cn.pycon.org/2013/beijing
洪强宁 DAE系统的设计
Zoom.Quiet
December 20, 2013
Transcript
120 slides
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
公有云服务?
开源?
开源!
开源!
谢谢!
More Decks by Zoom.Quiet
See All by Zoom.Quiet
PyCon2014China-Zhuhai-high performance
zoomquiet
0
220
PyCon2014China-Zhuhai-meta programming
zoomquiet
1
190
PyCon2014China-Zhuhai-bpm.py
zoomquiet
0
160
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
170
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
170
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
180
PyCon2014China-Zhuhai-jeff
zoomquiet
0
170
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
230
DevFest2014-Zhuhai-Polymer
zoomquiet
0
510
Other Decks in Technology
See All in Technology
AI×アジャイルで、石橋を高速で叩きながら渡る~電力会社がゼロから築いた会員サイト改善プロセス~ / 20261112 Ayami Kanazawa & Shigeru Hirai
shift_evolve
PRO
1
110
Linuxネットワークスタック進化の軌跡: 過去10年の歩みと最新トレンド
orimanabu
4
770
異夢同船〜異なる夢でも同じ船でなんとかする〜
fortegp05
1
560
2026-11-16 JAWS-UG コンテナ支部 #31 ゆるLT大会 ECR のライフサイクルポリシーを いい感じに設定したい / ECR Lifecycle policy
masasuzu
3
580
さようならSSH鍵、こんにちはゼロトラスト ― AIフレンドリーで快適な自宅鯖SSH
atalie2m
14
7.3k
Well, that’s weird…
csswizardry
1
110
こんなに変わった! AWSネットワークの常識
shotashiratori
16
11k
Kubernetes, Agones, WebRTC, GPU で作る クラウドゲーミング基盤を本番運用に乗せるまで
vivion
0
200
IoTのデータ保存をSREの観点で考える
grimoh
1
110
ノードが消える前提で設計する!Karpenterで金融システムを止めないためのノウハウ大全
daitak
1
160
20261113_JAWS_Osaka
takuyay0ne
1
600
パスワードのない鍵で、 データを手元に置く
ginjihayashi
0
380
Featured
See All Featured
Context Engineering - Making Every Token Count
addyosmani
9
1.3k
Heart Work Chapter 1 - Part 1
lfama
PRO
11
37k
RailsConf 2023
tenderlove
30
1.6k
Speed Design
sergeychernyshev
33
2.2k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1.1k
Into the Great Unknown - MozCon
thekraken
41
2.8k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
How to build a perfect <img>
jonoalderson
1
6.2k
The SEO identity crisis: Don't let AI make you average
varn
0
630
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
340