腾讯大讲堂58 拍拍app platform中间件解决方案简介

16
腾讯大讲堂 第五十八期 研发管理部 大讲堂主页: http://km.oa.com/class 与讲师互动: http://km.oa.com/group/class

Transcript of 腾讯大讲堂58 拍拍app platform中间件解决方案简介

Page 1: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

腾 讯 大 讲 堂

第五十八期

研发管理部

大讲堂主页: http://km.oa.com/class与讲师互动: http://km.oa.com/group/class

Page 2: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

拍拍 AppPlatform中间件解决方案简介

电子商务部

鲁锋 (henrylu)

2009-02-14

Page 3: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

大纲

系统原理

灵活部署

快捷开发

Page 4: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

PaiPai 后台服务的整体架构

CGI AppServer

DBServer DBMS

DBServer DBMS

App ServerWeb Server

DB Server

Page 5: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

需要状态机支持

App Server 内部协议流转四种模式

纯转发

Statless Statful 1

和多个DBServer通讯

对协议流转的顺序有

严格要求

Statful 2

发送不需要Response的协议包

Statful 3

和多个DBServer通讯

对协议流转的顺序没有

要求(常用于数据统计 )

Page 6: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

App Server 开发模式

App Server业务需求 映射 协议路由分发代码

协议解析代码

业务逻辑代码

底层IO代码

重复代码

Page 7: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

映射到 AppPlatform 中间件架构

业务代码

底层代码

Services

Container

映射到AppPlatform

设计

Page 8: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

WWW

Web Server(C++)LW-HttpdHTTP

Web Container

Web Service

Config Agent

Query Route

App Server(C++)NetIO

App Container

App ServiceTCP

Java ServerTomcat

Spring

Java Service

App Platform (AppContainer AutoGen)

Stub4Web SkelSerialize

AutoGen

IDL

Stub4Java

Page 9: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

AutoGen 框架代码生成工具 ( C++ h 数据源)

数据源解析器

Meta 树

C++ 工程

模板

Java 工程

模板

C++ 工程

框架

Java 工程

框架

模板替换

模板替换

AutoGen

Page 10: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

AutoGen 框架代码生成工具 ( Java IDL 数据源)

Java IDLIDL解析器

Meta 树

C++ 工程

模板

Java 工程

模板

C++ 工程

框架

Java 工程

框架

模板替换

模板替换

AutoGen V5

SVNIDLIDLIDL

使用eclipse

使用命令行

AutoGenPlugIn

Page 11: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

AppPlatform 中间件部署架构——传统两层架构

DBUser

DBUser

DBUser

MSGQ DBMS

DBEval

DBEval

DBEval

MSGQ DBMS

DBItem

DBItem

DBItem

MSGQ DBMS

Netio MSGQTCP

一台物理机器

ControllorMSGQ

Web层(CGI)

Page 12: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

AppPlatform 部署架构——传统三层架构

Netio MSGQTCP

AppUser

AppUser

AppUser

MSGQMSGQ

AppEval

AppEval

AppEval

MSGQMSGQ

AppItem

AppItem

AppItem

MSGQMSGQ

DBUser

DBUser

DBUser

MSGQ DBMS

DBEval

DBEval

DBEval

MSGQ DBMS

DBItem

DBItem

DBItem

MSGQ DBMS

一台物理机器

ControllorMSGQ

TCPMsgQ BackNetio

Netio MSGQTCP

一台物理机器

ControllorMSGQ

Web层(CGI)

Page 13: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

AppPlatform 部署架构——大 APP 架构

Netio MSGQTCP

AppUser

AppUser

AppUser

MSGQMSGQ

AppEval

AppEval

AppEval

MSGQMSGQ

AppItem

AppItem

AppItem

MSGQMSGQ

DBUser

DBUser

DBUser

MSGQ DBMS

DBEval

DBEval

DBEval

MSGQ DBMS

DBItem

DBItem

DBItem

MSGQ DBMS

一台物理机器

ControllorMSGQ

Web层(CGI)

推荐

Page 14: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

传统 Statful 状态机的实现Int OnExecute()

{

switch(m_cStat)

{

case S_START:

OnWebRequest(WebRequest[out]);

// Do Something…

DoDB1Request(DB1Request[in]);

m_cStat = S_CHECK_1; return 1;case S_CHECK_1:

OnDB1Response(DB1Response[out]);// Do Something… DoDB2Request(DB2Request[in]);m_cStat = S_CHECK_2; return 1;

case S_CHECK_2:OnDB2Response(DB2Response[out]);// Do something…DoWebResponse(WebResponse[in]);m_cStat = S_FINISH; return 0;

} // … return 0;

}

Statful DB1

DB2

S_START

S_CHECK_1

S_CHECK_2

Page 15: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

优化后的 Statful 状态机的实现Int OnExecute(){

OnWebRequest(WebRequest[out]); // Do Something…

CallDB1(DB1Request[in], DB1Response[out]); // Do Something… with DB1Response

CallDB2(DB2Request[in], DB2Response[out]); // Do Something… with DB2Response

DoWebResponse(WebResponse[in]);

// …return 0;

}奥妙就在此:CallDB1(DB1Request[in], DB1Response[out]){

DoDB1Request(DB1Request[in]); Schedule();// Linux System Call swapcontext(…)OnDB1Response(DB1Response[out]);

}

Statful DB1

DB2

Page 16: 腾讯大讲堂58 拍拍app platform中间件解决方案简介

谢谢大家!

问题?