饿了么整体架构
—程军@Jeff_arc
简介
• 产品介绍
• 架构演变
⺫⽬目录
(饿了么)
• 始创于2009年
• 2015是2014年的10倍的增⻓长速度
• 中国最⼤大的外卖平台
产品介绍
⽤用户 餐厅
⾼高端配送 社会化配送
订单
调度配送
产品介绍
北京
乌鲁木齐
哈尔滨
海口
昆明
西宁
上海
GMV/天:
8000W +
员工人数:
10,000+
覆盖城市:
300+
产品介绍
午餐 晚餐
时间线
• ⽇日单: 280万
• 峰值: 约 300单/秒
订
单
产品介绍
10x
架构演变
架构演变
PHP NGINX
Internet
单机时代
PHP NGINX
Internet
单机时代
PHP NGINX
Internet
HAProxy
负载均衡
Order User Order User
PHP NGINX
Internet
HAProxy
HAProxy
User Ordering HAProxyHAProxy
SOA: Mark I (400k ~ 600k)
Order User Order User
PHP NGINX
Internet
HAProxy
HAProxy
User Ordering
HAProxy
HAProxy
SOA: Mark I (600k vs 1M)
Order Order User User
PHP NGINX
Internet
F5
HAProxy
User Ordering
HAProxy
HAProxy
Gateway: Mark II (600k vs 1M)
PHP NGINX
Internet
F5
HAProxy
User Ordering HAProxy HAProxy
SOA: Mark II (600k vs 1M)
NGINX
Internet
F5
HAProxy
User Ordering HAProxy HAProxy
PHP
SOA: Mark II (600k vs 1M)
PHP
PHP: Mark II (600k vs 1M)
• FPM => HHVM
• Cache
SOA: Mark II (600k vs 1M)
NGINX
Internet
F5
HAProxy
User Ordering HAProxy HAProxy
PHP
PHP NGINX
Internet
F5
HAProxy
Ordering HAProxy HAProxyUser
SOA: Mark II (600k vs 1M)
Service: Mark II (600k vs 1M)
RedisRed RedRed
Python
PostgreSQL
PostGISMysql
MysqlMySQL
Redis
RabbitmqTwemproxy
Redis
Service: Mark II (600k vs 1M)
Python
PostgreSMySQL
Red
RabbitmTwempro
Red
• 降级
• 数据缓存
• 按领域拆分数据库
• 异步消息通知
Service: Mark II ( vs 1M)
RedRed RedRed
Python
PostgreSQL
PostGISMysql
MysqlMySQL
Redis
RabbitmqTwemproxy
Redis
MysqlMysql
Python
PostgreS
MySQL Red
RabbitmTwempro
Red
DAL
MySQL Proxy
• 连接重⽤用
• 限流
• 查询拒绝(耗时sql)
• 读写分离
• 分库分表
MysqlMysql
PostgreS
MySQL Red
RabbitmTwempro
Red
DAL • 连接重⽤用 • 限流
• 查询拒绝(耗时sql)
• 读写分离
• 分库分表
Python
PHP NGINX
Internet
F5
HAProxy
User Ordering HAProxy HAProxy
SOA: Mark II ( vs 1M)
PHP NGINX
Internet
F5
HAProxy
User Ordering HAProxy HAProxy
SOA: Mark II ( vs 1M)
PHP NGINX
Internet
F5
HAProxy
User Ordering HAProxy HAProxy
Orchestrator: Mark III
Web Service
Gateway
Web Service
Gateway
Web Service
Orchestrator
• 前端⾃自⼰己⽣生成⻚页⾯面
• 前端异步调⽤用
• 太多的http请求
• 实现业务功能需要依赖后端
前台后台分离
Web Service
Gateway
Web Service
Gateway
Web Service
Orchestrator
Orchestrator: Mark III
Cart API Shopping API Banner API Geo location API
Internet
F5
Web Service
Gateway
Web Service
Gateway
Web Service
Orchestrator
Orchestrator: Mark III
PHP NGINX
Internet
F5
HAProxy
User Order HAProxy HAProxy
Web Service
Gateway
Web Service
Gateway
Web Service
Orchestrator
Orchestrator: Mark III
BookinBookinBookinBookinPromotiPromotioShoppinShopping
Web Service
Gateway
Web Service
Gateway PHP NGINX
Internet
F5
HAProxy
Shopping Marketing
Web Service
Orchestrator
Service
Booking Ordering
MSA
BookinBookinBookinBookinPromotiPromotiShoppinShoppin
Web Service
Gateway
Web Service
Gateway PHP NGINX
Internet
F5
API Proxy
Shopping Marketing
Web Service
Orchestrator
Service
Booking Ordering
MSA
Web Service
Gateway
Web Service
Gateway PHP NGINX
Internet
F5
API Proxy
Web Service
Orchestrator
Service
BookinBookinBookinBookinPromotiPromotiShoppinShoppinShopping Marketing Booking Ordering
Orchestrator: Mark IV
Shopping Marketing Booking Ordering
Internet
F5
API Call DSL in HTTP
API RPC Call
Web Service
Gateway
Web Service
Gateway
API Service
Orchestrator
Orchestrator: Mark IV
Shopping Marketing Booking Ordering
Internet
F5
API Call DSL in HTTP
API RPC Call
API
Service
API
Service
API Service
Orchestrator
Web Service
Gateway
Web Service
Gateway PHP NGINX
Internet
F5
API Proxy
Web Service
Orchestrator
Service
Web Service
Gateway
Web Service
Gateway
API Service
Orchestrator
BookinBookinBookinBookinPromotiPromotiShoppinShoppinShopping Marketin Booking Ordering
Web Service
Gateway
Web Service
Gateway PHP NGINX
Internet
F5
API Proxy
Web Service
Orchestrator
Service
Web Service
Gateway
Web Service
Gateway
API Service
Orchestrator
BookingBookingBookinBookinPromotioPromotioShoppinShoppinShopping Marketing Booking Ordering
当前
Internet
F5
Service
Web Service
Gateway
Web Service
Gateway
API Service
Orchestrator
BookingBookinBookingBookinPromotiPromotioShoppinShoppinShopping Marketing Booking Ordering
规划
Q&A
结束