写点什么

维基百科技术架构

用户头像
escray
关注
发布于: 2020 年 10 月 18 日
维基百科技术架构

维基百科技术架构


根据李智慧老师的授课内容,增加了一些新内容。



十几个人,七八条枪(捐献过来的服务器)


  • GeoDNS 基于地理位置的域名服务,多机房部署(全球三个数据中心)

  • LVS:Linux Virtual Server 负载均衡

  • Squid caching layers: 反向代理 Squid is a caching proxy for the Web .

  • Application server: Apache, PHP

  • Distribute Object Cache: Memchached 分布式对象服务器

  • Image server: Lighttpd

  • Search: Lucene

  • Core database:MySQL 主从、读写分离

  • External storage

  • Other

  • Invalidation notification(避免 Squid 返回脏内容,被编辑过的)

  • Profiling

  • Logging


简单、高效


维基百科更多的是静态的页面浏览(虽然也有编辑等操作,但是可能比例并不是很高),而且一般不会遇到突发流量(明星离婚会先发微博,但不会先更新维基)


有点怀疑这个 Wiki 的架构说明是否过时,现在真的还在用 PHP 么?这幅架构图最早好像出现在 2007 年 Fenng 的博客上。



Wiki 当时峰值 30,000 HTTP requests/s ,数据传输 3 Gbit/s,三个数据中心 Tampa, Amesterdam, Seoul,6 个管理员,350 台服务器(包括 P4,Xeon Quad-Core)


最早也是 LAMP 起家



55 台 Squid 服务器,还有 20 台准备上线,大概有五分之一的服务器用于 Squid。


其中还提到了一个 CARP 技术,Cache Array Routing Protocol,is used in load-balancing HTTP requests across multiple proxy cache servers.


另外一个之前没有注意到的点是 Memcached 主要用于 MediaWiki 的缓存,就是维基百科上面的多媒体部分(图片,视频……)


在 MediaWiki 优化部分,提到以下几点:


  • not doing anything stupid

  • avoiding expensive algorithms, database queries, etc.

  • caching every result that is expensive and has temporal locality of reference

  • focusing on the hot spots in the code (profiling!)


数据库存储方面:


  • Separate database per wiki (not separate server!) 这里提到的 per wiki 是指几个不同的 wiki 产品

  • One master, many replicated slaves 此处有敏感词

  • Read operations are load balanced over the slaves, write operations go to the master. (The master is used for some read operations in case the slaves are not yet up to date, lagged)


数据库 Scaling by


  • Separating read and write operations (master/slave)

  • Separating some expensive operations from cheap and more frequent operations (query groups)

  • Separating big, popular wikis from smaller wikis


核心库的 schema 还是挺复杂的



Wiki 存储了所有页面从创建 Day I 到现在的所有改动,使用了文本压缩算法,100X 的压缩率


当时(2007?)图片服务器大概有 1.3 TB 数据,4 百万文件,不知道现在是什么样的规模。


推荐大家去看一下原始的 pdf 文件,例外 Widimedia 的现状可以看这里:https://meta.wikimedia.org/wiki/Wikimedia_servers


发布于: 2020 年 10 月 18 日阅读数: 124
用户头像

escray

关注

Let's Go 2017.11.19 加入

在学 Elasticsearch 的项目经理

评论

发布
暂无评论
维基百科技术架构