互联网公司技术架构资料.新浪微博.构建可扩展微博架构.pdf

  • 文件大小: 664.9KB
  • 文件类型: pdf
  • 上传日期: 2025-08-17
  • 下载次数: 0

概要信息:

¢sB€fx<¤¢
Tim Yang!
’²x<
ž¤¢k

<^4x<
<^
• 7Ú
– ?à
– ±ä
– ½æ
• Content Manager System!
<^
• ž, LAMP!
– MySQL master/slave"
– Memcached"
– PHP"
– CDN"
x<
• x<I
– Real-time"
– ,°,Í
– &|ÙD
&|ÙD
&|ÙD
• x<Ã&|ÙDéç©v
– Push(Š)"
– Pull(ƒ)"
Push 
• ‚x<Â(ù
– Inbox: Ž4¾x<
– Outbox: i?àx<
• ?à[4›Ìinbox(ü)!
• ¥ÂÁˆêÿInbox(ò)!
Push(Figure) 
User A 
UpdateAction 
Inbox 
(Append to 1s  
home timeline) 
Inbox 
(Append to 2s  
home timeline) 
Inbox 
(Append to 3s  
home timeline) 
Followers of User A 
= 1, 2, 3 
Push 
•  ¶]¸Ê;Ċõ
• Ô¶0?ý
Pull 
• ?à[4Ûhoutbox(ò)!
• ¥Â›,°bíInbox(ü)!
Pull 
User I 
Get home_timeline 
Outbox 
(statuses sent by A) 
Outbox 
(Statuses sent by B) 
Outbox 
(Statuses sent by C) 
User Is  
Following List 
= A, B, C 
Pull 
•  ¶ÜÎ[)
• Ô¶çËýV
• x<˜	´|0?ÍÑ
• Bû@Š}ƒ¾“v]¸
¤¢†~g'
- YāT—Ü
ì­ý
• Y£?àý5,000
/W
• nQ578¡/Ä
• éçÍÑ_ý2,000?!
IOºĈ
• g'5,000 – 10,000?!
• 100,000?!
F£
• Latency!
• DB read timeout!
• 5Çtimeout (503 error)!
• å/“§
u«éç
• E«Éw
• c´|[+´|Ā2(Message 
Queue)!
• òýϾ?à
MQ products 
• Kestrel by twitter"
• RabbitMQ, an Erlang Queue 
Server"
• Memcacheq!
– O’²x<ćÀVã©#¼
Memcacheq 
• RBerkeley db, Æ\BĆ
• Memcached protocol, a¾
client library!
• _–¿‰(stats queue)!
• A›2Hget/set!
ø*;¶ă
¦yœ9Ąø*;·ă
“¯
1. #¼UMemcacheq®
2. GetŒ": ñ뛜9J
3. SetŒ": ßõ„	

”Ą-S ¤¢éç
MQ“vö¼¾ ¶
• Offline work!
• p¼ì­ýQß
• åØ
• u«öè
• >3
#¼MQ>3
çËtþV´|0?tþ
¤¢†~]•{
îüâ¾îl]•{
The value of the tweet 
decreases 
exponentially with 
time!
    "
John Kalucki, Twitter"
http://t.sina.com.cn/pub/star#a_ty 
å/zï
Cachey:
Ram is the new the disk!
• Local Cache!
• Memcached!
• Database buffer/cache!
• LAMPcache=Bõe
• Cachey:F’¾ÿĉ
_ýÿĉ
• TBÏ
• zï=Ó
– QuickLZ"
– LZO"
– ¼gzip"
;¶ÿĉ
• ;¶ă, SIGSEGV!
• Y!pb
– 1. Consistent hash"
– 2. Read-through cache"
Consistent hash 
• >¹
•  ¶
– ąÝšd
Read-through cache 
Read-through and Write-
through 
• Products or projects!
– MySQL memcached UDF"
– Cache money for Ruby on Rails"
• Or wrap a proxy for the db 
driver, in any language!
Evictionsÿĉ
• Evections: cache‘‡áð
• {Ú¾K¨
• Latency»¾µX	
Y!ø*evictions 
• ã1cache_ý
• c¬‘‡
•‘‡0t
• #¼ĂŸZÈ"key!
Multigetÿĉ
When memcached servers are 
CPU bound, adding more 
memcached servers doesn't 
help serve more requests.!
!
- Jeff Rothschild, Vice President of 
Technology at Facebook"
Cache†~multiget 
hole 
Memcached
(Max RPS: A)
Memcached
(Max RPS C)
Memcached
(Max RPS: B)
Multiget (keys…)
M
ul
tig
et
M
ul
tig
et
M
ul
tig
et
Application
Max RPS of application < (A and B and C) 
M
ul
tig
et
å/“¯
• Memcached replication!
¤¢†~³ý[)
¤¢†~
N.ÕÐm`ÿĉ
P¹0j
• ×Þ4>LĄâ0jv
úÖ
– êÿ÷r
– IDCB¼
– ă
• 0j¾¦y˜‘‡0j
‘‡P¹0j>¹
• Master-slave!
• Master-master"
• 2PC/3PC!
• Paxos!
• http://timyang.net/data/multi-
idc-design/ !
P¹0j¾“§
• MySQL master/slave!
• Dynamo/Cassandra!
• PNUTS!
¤¢†~APIêÿý
’²x

缩略图:

  • 缩略图1
  • 缩略图2
  • 缩略图3
  • 缩略图4
  • 缩略图5
当前页面二维码

广告: