该【知乎架构变迁史 】是由【王夫人】上传分享,文档一共【90】页,该文档可以免费在线阅读,需要了解更多关于【知乎架构变迁史 】的内容,可以使用淘豆网的站内搜索功能,选择自己适合的文档,以下文字是截取该文章内的部分文字,如需要获得完整电子版,请下载此文档到您的设备,方便您编辑和打印。:.
知乎架构变迁史
李申申:.
RU11M+
MAU80M+
MPV220M+:.
:.
Youjumpoffacliffandyouassemblean
aeroplaneonthewaydown.
ReidHoffman:.
Linode512M:.
你永远不知道明早醒来会面对什么问题:.
宕机@知乎:.
LVSLVS
Mailgun
NginxNginx
Mail
PictureUploadWebWeb
M
Redis
PictureStorage
MSS
MySQLMySQLRedis:.
MySQL经典问题
主从延迟:.
资源隔离:.
内网优化:.
硬盘升级:.
应用层灵活调用:.
RedisShard:.
32
0/2
node3node1
计算hash计算hash
KeyKey
计算hash
计算hash
计算hash计算hash
node4node2:.
-shard:.
工具是一个过程
用大小形状都合适的物体,以最有效的方式完成工作:.
Profiling:.
Werkzeug:.
Puppet:.
Shipit:.
知乎邀请制:.
申请注册:.
日志系统:.
分布式收集
集中存储
可订阅
实时
简单:.
Scribe无法订阅
KafkaScala
FlumeJava:.
Kids
KidsisDataStream:.
AppAppApp
PublishPublish
Publish
AgentAgent
AgentAgent
Subscribe
KidsServerLogAnalyzer
PsubscribeSubscribe
LogAnalyzerLogAnalyzer:.
MultipleStore
StorerStore
BufferStore
Thread
StorerPriorityStore
NotifyFetch
⑥
GlobalMessageQueue
⑦
MessageMessageMessageFetch
WorkerThreadWorkerThread
PushLatestLatestLatest
④
ClientClient
⑤NotifyWorker
ClientClient
②Accept
Accept
Master
③Thread
Publish
①ConnectConnect
Message
Subscribe/Psubscribe⑧
AppApp
(Publisher)(Subscriber):.
:.
添加回答
更新通知更新动态
更新搜索索引
判断是否Spam
更新回答计数
?
更新个人主页
失效缓存判断内容质量
?内容审核
是否非法
?
??:.
EventDrivenArchitecture:.
Miller
Sink
Master
MillerWorker
Worker01
Worker02
Beanstalkd
WorkerN:.
①
Web
④
②
③
MySQLSink
④④
noti-millersearch-miller
MasterMaster
⑤⑤
Beanstalkd
⑥⑥
noti-millersearch-miller
WorkerWorker
⑦⑦
notiserverindexer:.
In100+
Out1500+:.
LVSLVS
Miller
MasterSink
NginxNginx
MillerWorker
WebWeb
Worker01
M
Worker02
BeanstalkdRedis
WorkerNMSS
MySQLMySQLRedis:.
页面渲染优化:.
HomeUI
FeedUISidebarUI
Data
Item1UIItem2UINavigatorUI
QuestionUIAnswerUI:.
HomeNode
FeedNodeSidebarNodeData
Item1NodeItem2NodeNavigatorNode
QuestionNodeAnswerNode:.
ZhihuNode:.
classAnswerVoteBarV2(ZhihuNode):
!
definit(self,answer_id):
=answer_id
!
deftemplate_v2(self):
return""
!
defprime(self):
(,)
defobj(self):
vote=(,)
returnObjectDict(vote=vote):.
Question500ms->150ms
Feed1s->600ms:.
Service-orientedarchitecture:.
RPC框架变迁史:.
Wish
ProtocolBuffers
STP
TCP:.
Snow
JSON
STP
TCP:.
Zone:.
ApacheAvroIDL
ProtocolVersioningProtocolGenerator
APIProtocol
SyncClient
ConnectionPoolAsyncServer
AsyncClientCommunication
&
TransportProtocols:.
ApacheAvro-IDL
//GoogleProtocolBuffer //ApacheAvro
messageCalcResponse{ protocolCalc{
enumResult{ errorZeroDivision{
OK=0; stringmessage;
ZERO_DIVISION=1; }
}
requiredResultresult=1; intdivide(inta,intb)throwsZeroDivision;
optionalint32c=2; }
}
messageCalcRequest{
int32a=1;
int32b=2;
}
serviceCalc{
rpcDivide(CalcRequest)returns(CalcResponse);
}:.
ApacheAvro-APIProtocolFile
//Wish’sgeneratedfiles… //ApacheAvro’sgeneratedfile,simplyasnippetofJSON
{
"Calc":{
"messages":{
"divide":{
"errors":["ZeroDivision"],
"reqest":[{"name":"a","type":"int"},
{"name":"b","type":"int"}],
"response":"int"}},
"namespace":None,
"protocol":"Calc",
"types":[
{"fields":[{"name":"message","type":"string"}],
"name":"ZeroDivision",
"type":"error"}
]
}
}:.
ServerExample
importsnow importzone
classCalc(): fromprotoimportprotos
!
defdivide(self,a,b): classCalc():
ifb==0: !
return{"code":1,"msg":"Zerodefdivide(self,a,b):
division."} ifb==0:
return{"code":0,"c":a/b} raise
!(name="ZeroDivision")
(Calc(),port=9000).run()returna/b
!
([Calc(protos["Calc"])],
port=9000).run():.
HeaderBody
Serializer(Avro/JSON)
Transporter(Binary/STP)
TCP:.
Consul:.
Tracing:.
知乎业务服务结构图
聚
合话题Feed⾸首⻚页Feed发现搜索推荐收藏圆桌
层
内
容问答专栏通知私信已读
层
基
础⽤用户评论图⽚片推送分享话题邮件短址
层
数据服务逻辑服务通道服务:.
LVS01LVS02
keepAlived
Nginx01Nginx02
Web01Web02WebN前端展⽰示层
keepAlived
Haproxy01Haproxy02
后端业务逻辑层
MillerFeedServiceMemberService···
BeantalkSinkKidsMySQLRedisCassandra存储&通信层:.
知乎专栏的全新实践:.
传统网站的开发模式
前后端代码交叉
工程师互相等待
前端代码部署成本高:.
WebApp
RESTfulAPIServer
RPCServerWorkers
MySQLRedis:.
前后端分离,逻辑更清晰
AngularJS:代码复用、快速开发
并行开发
独立部署:.
<(▰˘◡˘▰)>
产品设计师也能修改代码了:.
工具要不断跟上:.
Dash:.
Heroin:.
Radius:.
CFB:.
Crony:.
Oops:.
Boxen:.
想各种办法发挥自我创新
其实就是找各种办法刺激工程师们:.
Hackathon:.
TinkDay:.
谢谢
知乎架构变迁史 来自淘豆网m.daumloan.com转载请标明出处.