文档介绍:高性能,高流量,多数据中心
互联网应用架构实战
——以FreeWheel MRM系统后台为例
Diane Yu
Co-Founder, CTO
王迪
FreeWheel核心系统技术总监
2009-04
FreeWheel Confidential
高性能,高流量系统架构设计的基本原则
Design with failure in mind
• There is no bug free software
• There is no failure proof hardware
Partition your data
• Load balance: Even partition
• Easiness to repartition
• Reduce dependency
Redundancy
• Reduce single point of failure
• System auto recoverability
Monitor, monitor, monitor
• Monitor from customer perspective
• Monitor from capacity perspective
FreeWheel Confidential
高性能,高流量系统架构设计的基本原则
KISS
• Keep: Upkeep
• Requirement is meant to change all the time
• Software is meant to evolve all the time
• Simple Stupid
• More code, more maintenance
• Something is wrong when it plicated
Just in time
• Just in time design
• Perfect design doesn’t exist
• Design just enough to get started
• Just in time refine/refactor
• Know when to refactor
• Refactor in pieces is always better plete rewrite
FreeWheel Confidential
如何实现高性能
服务性能指标
•广告投放服务Up time %——每月down<=4分钟
•负载均衡
• Web服务多路转发
•前端应用服务器failover设计
•多线程
• Watch Dog/SNMP自动监测
• Counter服务器,本地缓存+中心同步+后台反馈,避免单点故障
•单次广告投放延迟<150ms
•轻量级Web Server + FastCGI
•广告决策信息提前构建并缓存,减少DB访问,cache分级更新
•第三方监测Gomez
FreeWheel Confidential
如何实现高流量
高系统吞吐量的设计原则
•简化前端应用服务逻辑
•单点服务响应快
•易于开发/维护
•易于横向扩展
•易于提高可靠性
•减少单个事务处理的状态依赖
•每次广告请求和确认携带所有必要的决策信息,减少服务器间的
通信依赖和请求间的状态依赖。
•缺点:日志信息冗余,数据量大
•以空间换时间
•海量日志处理交由Map-Reduce后台完成
FreeWheel Confidential
Hadoop取舍之间
Hadoop是Map-Reduce思想的开源实现
优点:
•适用于海量信息处理与挖掘
•开源社区支持,已在大型搜索引擎应用,改进搜索质量
•可用廉价机器组成大规模集群,良好的自动调度
•将复杂问题,分解为基本的Mapper和Reducer方法交替完
成,编程开发简单。
缺点:
• NFS交换和存储日志数据,I/O负载较高
•单节点需拥有待处理信息的全部拷贝,处理能力与内存成正
比,处理跨节点分散数据的交换时间较高
•过程中Debug较困难
•重新处理代价较高
FreeWheel Confidential
Hadoop取舍之间(续)
业务待处理日志特点
•单条日志数据尺寸较大(2k);数据域较多,通常在几十;每
日总日志条目数据量较大,G~T级。
•日志生成时间/空间分散
•一次业务事务t由若干关联步骤组成,如A->B->C,且同时有
若干事务同时发生
•各步骤可能发生在不同前端服务器,如A发生于S1
•各步骤均产生一至多条日志,如A