美文网首页
CorkBoardIt

CorkBoardIt

作者: 尚无花名 | 来源:发表于2019-03-23 21:24 被阅读0次

a mini version of instagram
这是笔者是Gatech OMSCS项目CS6400的课程项目。
我把它deploy到aws上去,
这个链接在 2019年7月前应该都是有效的
http://52.206.247.212:8080

我在面试中的project deep dive环节用我的这个course project 过了那一轮面试。

Basic function:

  1. User register/login
  2. User Create CorkBoard(相册)
  3. User Add Push Pin(photo)
  4. User View Other people's corkBoard
  5. User "Watch" a CorkBoard.
  6. User Like PushPin
  7. User follow other user
  8. User Comments a PushPin
  9. Search
  10. Popular Sites(图片来源最多的站点), Popular tags(最热门的tag), Statistics :各种统计数据
  11. Generate time line

Data model

  1. User table
    user_id, user_email, name, pin
  2. CorkBoard table
    corkboard_id, owner_id, category
  3. Pushpin Table
    id, owner_id, corkboard_id, url, tag
  4. Watch Table
    user_id, corkboard_id (user_id做为ordering field)
  5. Like Table
    user_id, pushpin_id (pushpin_id做为ordering field)
  6. Follow Table
    user_id, followee_id
  7. Comments Table
    pushpin_id, user_id, timestamp, content
  8. Category Table
    category
  9. Tag Table
    tag

选用SQL 数据库,因为主要是结构化的data,(除了照片)
SQL支持比较复杂的查询。比较容易提取出各种统计数据
图片存在单独的服务器上,本地sql数据库里只保留一个url

Working solution:

  1. user login in, 检查用户身份.
  2. Generate timeline. backend query most recent update the corkboard he watched, the people he follows. The backend merge this result and return the top k most recent update from the user.
    The back end also query the user's own Corkboard and shows the statistics.
    这里用到的是pull model
  3. 用户添加数据 User add new Corkboard, add new push pin, add new comments.
  4. Other functionality: Search, 使用Like 语句查询join起来。

登录信息存在哪里

php里面有Session, session信息存在server端。SessionId传给浏览器,浏览器每次访问时都要带着SessionID. Server端的session信息可以存在内存里,反正也不是需要持久化。

Scale

这个项目目前是单机版
如果需要scale的话: 使用consistent hashing.
Sharding Key: user table, corkBoard table, watch,follow都按 user id sharding,
pushpin table, comments_table 按 pushpin id sharding.

如何加速查询

读多写少的系统,可以用Cache进行优化。Memchched
对于热门统计(popular tag, popular site)可以定期查询(每一小时查一次存起来)。
也可以在tag table里增加一个field 叫count, 每次有新图片被了tag 就update tag table, 这样就很方便查最热门的tag了。也可以增加一个table叫site 进行popular site查询的加速

建立索引:因为pushpin table 和comment table数据最大,先对pushpin table建立primary index, comment table建立primary index。
对Like table建立索引按 pushpin_id建立clustering index,(因为经常要显示一个图片有多少人like了)

相关文章

  • CorkBoardIt

    a mini version of instagram这是笔者是Gatech OMSCS项目CS6400的课程项目...

网友评论

      本文标题:CorkBoardIt

      本文链接:https://www.haomeiwen.com/subject/afrjvqtx.html