SlideShare une entreprise Scribd logo
1  sur  39
站内评论与留言系统

  技术部 kim
目的
• 介绍现状
• 分享开发过程
评论?
• UGC
• 基础模块
• 二级内容
播放页
专题
留言
我收到的
美女视频
瀑布流1
瀑布流2
瀑布流3
相片(旧)
相片(新)
精彩跟帖
负载
• PV 大于播放页
• 日增10-15万
• Nagios 监控
现状
•   PHP 3台
•   Memcached 18个节点
•   TT 12个节点
•   Redis 18个节点
•   MongoDB 2台机,6端口,48个库,每库2个
    表
页面入口
• 主脚本 objcmt.js
• 主样式 objcmt.importStyle()
• 模板 JavaScript+Html
程序入口
• 多入口
• 站内 api/commentApi.php
• 站外 e.g. api/renren/,api/sina/
回推
旧版
•   单库单表,1.4亿
•   Mysql Scheme
•   Enum字段
•   代码混乱
•   JavaScript Template
Why重构
•   存储
•   Read/Write 性能
•   Bugs
•   业务拓展
How?
•   MongoDB
•   开发环境
•   数据结构
•   数据迁移
•   程序重构
MongoDB
• ReplicaSet
• Sharding VS 分库
• 如何监控
MongoDB
• Group/MapReduce 性能
• Btree 索引
• PHP extension 不稳定
开发环境
• 本地模拟 ReplicaSet 架构
• 辅助工具 Rockmongo
数据结构(冗余架构)
•   视频相关 VS 用户相关
•   双表冗余
•   哈希
•   Observer模式
ID问题
•   ObjectId:4e7020cb 7cac81 af71 36236b
•   数字id:226166216
•   1/3内存
•   稳定性,移植性
•   ID生成器
ID问题
• CREATE TABLE IF NOT EXISTS `comment_id` (
•    `id` bigint(20) NOT NULL
  AUTO_INCREMENT,
•    PRIMARY KEY (`id`)
• ) ENGINE=InnoDB DEFAULT CHARSET=latin1
  AUTO_INCREMENT=200000000 ;
content问题
•   最大1k
•   Db size 与查询效率
•   理论上,非排序和条件字段都可放key/value
•   比如,放TT里
•   优化?
盖楼问题
•   MongoDB::getDBRef
•   楼层标识:tower_index
•   递归的使用
•   重复楼层的隐藏问题
•   上限?
数据迁移
•   脚本,求简
•   先迁移,后索引
•   No safe insert
•   1k/s 写入,白天单线程,晚上6线程,前后
    共计1星期
索引
• Free scheme 的优势

• 多值 OR 查询的修复:
• status:y/n/d -> status:1/0 and visible:1/0
索引
• 慢查询0容忍
• 日志的重要性
大表索引
• ReplicaSet 架构下的大表索引问题
缓存
•   列表,Redis list
•   总数,key/value
•   失效的时机
•   更高的命中率
分页
• LIMIT 的噩梦
• 排序,cursor 的应用
• LIMIT 0,稳定的翻页
F&Q
谢谢!

Contenu connexe

Tendances

Kubernetes use-ceph
Kubernetes use-cephKubernetes use-ceph
Kubernetes use-cephYang Guanjun
 
Chasingice
ChasingiceChasingice
Chasingice冰 白
 
Nginx深度開發與客制化
Nginx深度開發與客制化Nginx深度開發與客制化
Nginx深度開發與客制化Joshua Zhu
 
阿里CDN技术揭秘
阿里CDN技术揭秘阿里CDN技术揭秘
阿里CDN技术揭秘Joshua Zhu
 
新浪微博Feed服务架构
新浪微博Feed服务架构新浪微博Feed服务架构
新浪微博Feed服务架构XiaoJun Hong
 
Python小团队不妨知道的技术
Python小团队不妨知道的技术Python小团队不妨知道的技术
Python小团队不妨知道的技术jie.wang
 
高性能存储引擎TokuDB剖析
高性能存储引擎TokuDB剖析高性能存储引擎TokuDB剖析
高性能存储引擎TokuDB剖析Bohu TANG
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJSTechParty@UIC
 
110412 kningsoft-mongo db-intro-usage-in-mercury
110412 kningsoft-mongo db-intro-usage-in-mercury110412 kningsoft-mongo db-intro-usage-in-mercury
110412 kningsoft-mongo db-intro-usage-in-mercuryZoom Quiet
 
淘宝网前台应用性能优化实践
淘宝网前台应用性能优化实践淘宝网前台应用性能优化实践
淘宝网前台应用性能优化实践丁 宇
 
设计高性能mysql应用-TechClub技术沙龙
设计高性能mysql应用-TechClub技术沙龙设计高性能mysql应用-TechClub技术沙龙
设计高性能mysql应用-TechClub技术沙龙banping
 
移动搜索在慢网速下的优化
移动搜索在慢网速下的优化移动搜索在慢网速下的优化
移动搜索在慢网速下的优化Charlee Green
 
从开发到上线-实战持续交付
从开发到上线-实战持续交付从开发到上线-实战持续交付
从开发到上线-实战持续交付LI Daobing
 

Tendances (20)

Kubernetes use-ceph
Kubernetes use-cephKubernetes use-ceph
Kubernetes use-ceph
 
MongoDB SHARE
MongoDB SHAREMongoDB SHARE
MongoDB SHARE
 
Chasingice
ChasingiceChasingice
Chasingice
 
Mesos intro
Mesos introMesos intro
Mesos intro
 
Nginx深度開發與客制化
Nginx深度開發與客制化Nginx深度開發與客制化
Nginx深度開發與客制化
 
阿里CDN技术揭秘
阿里CDN技术揭秘阿里CDN技术揭秘
阿里CDN技术揭秘
 
Dynamo db
Dynamo dbDynamo db
Dynamo db
 
新浪微博Feed服务架构
新浪微博Feed服务架构新浪微博Feed服务架构
新浪微博Feed服务架构
 
Python小团队不妨知道的技术
Python小团队不妨知道的技术Python小团队不妨知道的技术
Python小团队不妨知道的技术
 
高性能存储引擎TokuDB剖析
高性能存储引擎TokuDB剖析高性能存储引擎TokuDB剖析
高性能存储引擎TokuDB剖析
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
Redis
RedisRedis
Redis
 
110412 kningsoft-mongo db-intro-usage-in-mercury
110412 kningsoft-mongo db-intro-usage-in-mercury110412 kningsoft-mongo db-intro-usage-in-mercury
110412 kningsoft-mongo db-intro-usage-in-mercury
 
淘宝网前台应用性能优化实践
淘宝网前台应用性能优化实践淘宝网前台应用性能优化实践
淘宝网前台应用性能优化实践
 
Ceph intro
Ceph introCeph intro
Ceph intro
 
设计高性能mysql应用-TechClub技术沙龙
设计高性能mysql应用-TechClub技术沙龙设计高性能mysql应用-TechClub技术沙龙
设计高性能mysql应用-TechClub技术沙龙
 
移动搜索在慢网速下的优化
移动搜索在慢网速下的优化移动搜索在慢网速下的优化
移动搜索在慢网速下的优化
 
Hantuo openstack
Hantuo openstackHantuo openstack
Hantuo openstack
 
Jsonp
JsonpJsonp
Jsonp
 
从开发到上线-实战持续交付
从开发到上线-实战持续交付从开发到上线-实战持续交付
从开发到上线-实战持续交付
 

En vedette

Welcome To My World
Welcome To My WorldWelcome To My World
Welcome To My WorldCherie25
 
Giessen r user group treffen 10 05-2011 - foliensatz
Giessen r user group treffen 10 05-2011 - foliensatzGiessen r user group treffen 10 05-2011 - foliensatz
Giessen r user group treffen 10 05-2011 - foliensatzmasem research institute
 
Women 2.0 2.14 fran maier
Women 2.0 2.14 fran maierWomen 2.0 2.14 fran maier
Women 2.0 2.14 fran maierFran Maier
 
Video Upload Architecture of 56.com
Video Upload Architecture of 56.comVideo Upload Architecture of 56.com
Video Upload Architecture of 56.comHo Kim
 
Welcome To My World
Welcome To My WorldWelcome To My World
Welcome To My WorldCherie25
 
Women on Boards Action Plan
Women on Boards Action PlanWomen on Boards Action Plan
Women on Boards Action PlanFran Maier
 
Basic word01
Basic word01Basic word01
Basic word01adisg
 
BasicWord03
BasicWord03BasicWord03
BasicWord03adisg
 
TouchTyping01 - intro & home row
TouchTyping01 - intro & home rowTouchTyping01 - intro & home row
TouchTyping01 - intro & home rowadisg
 
P1 nursery rhymes
P1 nursery rhymesP1 nursery rhymes
P1 nursery rhymesadisg
 
Jack and the Beanstalk
Jack and the BeanstalkJack and the Beanstalk
Jack and the Beanstalkadisg
 
AdvancedWord02
AdvancedWord02AdvancedWord02
AdvancedWord02adisg
 
Effective Pair Programming
Effective Pair ProgrammingEffective Pair Programming
Effective Pair ProgrammingJames Thompson
 
Blue Ocean Strategy - Creating Value Innovations
Blue Ocean Strategy - Creating Value InnovationsBlue Ocean Strategy - Creating Value Innovations
Blue Ocean Strategy - Creating Value Innovationsmelanie_ernst
 

En vedette (17)

Welcome To My World
Welcome To My WorldWelcome To My World
Welcome To My World
 
Giessen r user group treffen 10 05-2011 - foliensatz
Giessen r user group treffen 10 05-2011 - foliensatzGiessen r user group treffen 10 05-2011 - foliensatz
Giessen r user group treffen 10 05-2011 - foliensatz
 
Women 2.0 2.14 fran maier
Women 2.0 2.14 fran maierWomen 2.0 2.14 fran maier
Women 2.0 2.14 fran maier
 
Video Upload Architecture of 56.com
Video Upload Architecture of 56.comVideo Upload Architecture of 56.com
Video Upload Architecture of 56.com
 
Welcome To My World
Welcome To My WorldWelcome To My World
Welcome To My World
 
All About Me
All About MeAll About Me
All About Me
 
Women on Boards Action Plan
Women on Boards Action PlanWomen on Boards Action Plan
Women on Boards Action Plan
 
Basic word01
Basic word01Basic word01
Basic word01
 
BasicWord03
BasicWord03BasicWord03
BasicWord03
 
All About Me
All About MeAll About Me
All About Me
 
Crnascarfinal.5
Crnascarfinal.5Crnascarfinal.5
Crnascarfinal.5
 
TouchTyping01 - intro & home row
TouchTyping01 - intro & home rowTouchTyping01 - intro & home row
TouchTyping01 - intro & home row
 
P1 nursery rhymes
P1 nursery rhymesP1 nursery rhymes
P1 nursery rhymes
 
Jack and the Beanstalk
Jack and the BeanstalkJack and the Beanstalk
Jack and the Beanstalk
 
AdvancedWord02
AdvancedWord02AdvancedWord02
AdvancedWord02
 
Effective Pair Programming
Effective Pair ProgrammingEffective Pair Programming
Effective Pair Programming
 
Blue Ocean Strategy - Creating Value Innovations
Blue Ocean Strategy - Creating Value InnovationsBlue Ocean Strategy - Creating Value Innovations
Blue Ocean Strategy - Creating Value Innovations
 

Similaire à Comment System of 56.com

分布式Key-value漫谈
分布式Key-value漫谈分布式Key-value漫谈
分布式Key-value漫谈lovingprince58
 
合久必分,分久必合
合久必分,分久必合合久必分,分久必合
合久必分,分久必合Qiangning Hong
 
数据架构方面的一些探讨
数据架构方面的一些探讨数据架构方面的一些探讨
数据架构方面的一些探讨Chao Zhu
 
课题二:Node.js那些事儿
课题二:Node.js那些事儿课题二:Node.js那些事儿
课题二:Node.js那些事儿Liu Allen
 
使用Big pipe提升浏览速度 wk_velocity
使用Big pipe提升浏览速度 wk_velocity使用Big pipe提升浏览速度 wk_velocity
使用Big pipe提升浏览速度 wk_velocitykumawu
 
豆瓣网技术架构变迁
豆瓣网技术架构变迁豆瓣网技术架构变迁
豆瓣网技术架构变迁reinhardx
 
大型网站架构的发展
大型网站架构的发展大型网站架构的发展
大型网站架构的发展drewz lin
 
大型网站架构的发展
大型网站架构的发展大型网站架构的发展
大型网站架构的发展Hesey
 
淘宝前台系统性能分析与优化
淘宝前台系统性能分析与优化淘宝前台系统性能分析与优化
淘宝前台系统性能分析与优化丁 宇
 
基于My sql的分布式数据库实践
基于My sql的分布式数据库实践基于My sql的分布式数据库实践
基于My sql的分布式数据库实践锐 张
 
基于MySQL的分布式数据库实践
基于MySQL的分布式数据库实践基于MySQL的分布式数据库实践
基于MySQL的分布式数据库实践jackbillow
 
Taobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qconTaobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qconYiwei Ma
 
构建可扩展的微博系统
构建可扩展的微博系统构建可扩展的微博系统
构建可扩展的微博系统lonegunman
 
Full stack-development with node js
Full stack-development with node jsFull stack-development with node js
Full stack-development with node jsXuefeng Zhang
 
redis 适用场景与实现
redis 适用场景与实现redis 适用场景与实现
redis 适用场景与实现iammutex
 
GitLab—the new workbench
GitLab—the new workbenchGitLab—the new workbench
GitLab—the new workbenchtblanlan
 
Gitlab - the new workbench (2nd edition)
Gitlab - the new workbench (2nd edition)Gitlab - the new workbench (2nd edition)
Gitlab - the new workbench (2nd edition)Pu Shiming
 
網站上線了,然後呢?
網站上線了,然後呢?網站上線了,然後呢?
網站上線了,然後呢?Kirk Chen
 

Similaire à Comment System of 56.com (20)

分布式Key-value漫谈
分布式Key-value漫谈分布式Key-value漫谈
分布式Key-value漫谈
 
合久必分,分久必合
合久必分,分久必合合久必分,分久必合
合久必分,分久必合
 
数据架构方面的一些探讨
数据架构方面的一些探讨数据架构方面的一些探讨
数据架构方面的一些探讨
 
课题二:Node.js那些事儿
课题二:Node.js那些事儿课题二:Node.js那些事儿
课题二:Node.js那些事儿
 
使用Big pipe提升浏览速度 wk_velocity
使用Big pipe提升浏览速度 wk_velocity使用Big pipe提升浏览速度 wk_velocity
使用Big pipe提升浏览速度 wk_velocity
 
豆瓣网技术架构变迁
豆瓣网技术架构变迁豆瓣网技术架构变迁
豆瓣网技术架构变迁
 
大型网站架构的发展
大型网站架构的发展大型网站架构的发展
大型网站架构的发展
 
大型网站架构的发展
大型网站架构的发展大型网站架构的发展
大型网站架构的发展
 
淘宝前台系统性能分析与优化
淘宝前台系统性能分析与优化淘宝前台系统性能分析与优化
淘宝前台系统性能分析与优化
 
基于My sql的分布式数据库实践
基于My sql的分布式数据库实践基于My sql的分布式数据库实践
基于My sql的分布式数据库实践
 
基于MySQL的分布式数据库实践
基于MySQL的分布式数据库实践基于MySQL的分布式数据库实践
基于MySQL的分布式数据库实践
 
A
AA
A
 
Taobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qconTaobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qcon
 
构建可扩展的微博系统
构建可扩展的微博系统构建可扩展的微博系统
构建可扩展的微博系统
 
java title
java titlejava title
java title
 
Full stack-development with node js
Full stack-development with node jsFull stack-development with node js
Full stack-development with node js
 
redis 适用场景与实现
redis 适用场景与实现redis 适用场景与实现
redis 适用场景与实现
 
GitLab—the new workbench
GitLab—the new workbenchGitLab—the new workbench
GitLab—the new workbench
 
Gitlab - the new workbench (2nd edition)
Gitlab - the new workbench (2nd edition)Gitlab - the new workbench (2nd edition)
Gitlab - the new workbench (2nd edition)
 
網站上線了,然後呢?
網站上線了,然後呢?網站上線了,然後呢?
網站上線了,然後呢?
 

Plus de Ho Kim

解决Lvs上行丢包的过程和收获
解决Lvs上行丢包的过程和收获解决Lvs上行丢包的过程和收获
解决Lvs上行丢包的过程和收获Ho Kim
 
40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.x40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.xHo Kim
 
Project Management Using Redmine
Project Management Using RedmineProject Management Using Redmine
Project Management Using RedmineHo Kim
 
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tips
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tipsOpenResty/Lua 70+ Advanced Programming Skills and Optimization tips
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tipsHo Kim
 
Web Caching Architecture and Design
Web Caching Architecture and DesignWeb Caching Architecture and Design
Web Caching Architecture and DesignHo Kim
 
Lua 30+ Programming Skills and 20+ Optimization Tips
Lua 30+ Programming Skills and 20+ Optimization TipsLua 30+ Programming Skills and 20+ Optimization Tips
Lua 30+ Programming Skills and 20+ Optimization TipsHo Kim
 
人人-56 账号拆分项目总结
人人-56 账号拆分项目总结人人-56 账号拆分项目总结
人人-56 账号拆分项目总结Ho Kim
 
OpenResty/Lua Practical Experience
OpenResty/Lua Practical ExperienceOpenResty/Lua Practical Experience
OpenResty/Lua Practical ExperienceHo Kim
 
JavaScript 80+ Programming and Optimization Skills
JavaScript 80+ Programming and Optimization SkillsJavaScript 80+ Programming and Optimization Skills
JavaScript 80+ Programming and Optimization SkillsHo Kim
 
Character Encoding and Database Transcoding Project
Character Encoding and Database Transcoding ProjectCharacter Encoding and Database Transcoding Project
Character Encoding and Database Transcoding ProjectHo Kim
 
PHP Optimization for Millions Visits Level
PHP Optimization for Millions Visits LevelPHP Optimization for Millions Visits Level
PHP Optimization for Millions Visits LevelHo Kim
 
Git Essence Tutorial
Git Essence TutorialGit Essence Tutorial
Git Essence TutorialHo Kim
 
MongoDB Basics and Tutorial
MongoDB Basics and TutorialMongoDB Basics and Tutorial
MongoDB Basics and TutorialHo Kim
 
PHP Coding Standard and 50+ Programming Skills
PHP Coding Standard and 50+ Programming SkillsPHP Coding Standard and 50+ Programming Skills
PHP Coding Standard and 50+ Programming SkillsHo Kim
 

Plus de Ho Kim (14)

解决Lvs上行丢包的过程和收获
解决Lvs上行丢包的过程和收获解决Lvs上行丢包的过程和收获
解决Lvs上行丢包的过程和收获
 
40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.x40 Powerful Shortcuts of Xcode 6.x
40 Powerful Shortcuts of Xcode 6.x
 
Project Management Using Redmine
Project Management Using RedmineProject Management Using Redmine
Project Management Using Redmine
 
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tips
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tipsOpenResty/Lua 70+ Advanced Programming Skills and Optimization tips
OpenResty/Lua 70+ Advanced Programming Skills and Optimization tips
 
Web Caching Architecture and Design
Web Caching Architecture and DesignWeb Caching Architecture and Design
Web Caching Architecture and Design
 
Lua 30+ Programming Skills and 20+ Optimization Tips
Lua 30+ Programming Skills and 20+ Optimization TipsLua 30+ Programming Skills and 20+ Optimization Tips
Lua 30+ Programming Skills and 20+ Optimization Tips
 
人人-56 账号拆分项目总结
人人-56 账号拆分项目总结人人-56 账号拆分项目总结
人人-56 账号拆分项目总结
 
OpenResty/Lua Practical Experience
OpenResty/Lua Practical ExperienceOpenResty/Lua Practical Experience
OpenResty/Lua Practical Experience
 
JavaScript 80+ Programming and Optimization Skills
JavaScript 80+ Programming and Optimization SkillsJavaScript 80+ Programming and Optimization Skills
JavaScript 80+ Programming and Optimization Skills
 
Character Encoding and Database Transcoding Project
Character Encoding and Database Transcoding ProjectCharacter Encoding and Database Transcoding Project
Character Encoding and Database Transcoding Project
 
PHP Optimization for Millions Visits Level
PHP Optimization for Millions Visits LevelPHP Optimization for Millions Visits Level
PHP Optimization for Millions Visits Level
 
Git Essence Tutorial
Git Essence TutorialGit Essence Tutorial
Git Essence Tutorial
 
MongoDB Basics and Tutorial
MongoDB Basics and TutorialMongoDB Basics and Tutorial
MongoDB Basics and Tutorial
 
PHP Coding Standard and 50+ Programming Skills
PHP Coding Standard and 50+ Programming SkillsPHP Coding Standard and 50+ Programming Skills
PHP Coding Standard and 50+ Programming Skills
 

Comment System of 56.com