互联网公司技术架构资料.新浪微博.构建可扩展微博架构.pdf
- 文件大小: 664.9KB
- 文件类型: pdf
- 上传日期: 2025-08-17
- 下载次数: 0
概要信息:
¢sBfx<¤¢
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)!
• A2Hget/set!
ø*;¶ă
¦y9Ąø*;·ă
¯
1. #¼UMemcacheq®
2. Get": ñë9J
3. Set": Ăõ
Ą-S ¤¢éç
MQvö¼¾ ¶
• 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
– IDCB¼
– ă
• 0j¾¦y0j
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
当前页面二维码