网站系统,域名
访问Google

- You type maps.google.com into the address bar of your browser.
 - The browser checks the cache for a DNS record to find the corresponding IP address of maps.google.com.
 - The browser sends an HTTP request to the webserver.
 - webserver => http server(Apache, nginx)
 - http server => WebApplication(Django, nodejs)
 - webapplication response

 
API 设计
直接使用user id是不安全的,正确方式是通过登陆后的token获取id




News Feed List Web Api



翻页 Pagination
多请求一个 page_size = n + 1, max_id = the last item id, real displayed = n items

refresh
find items id > max_id (latest)
Mention

直接返回缺点


短网址
Service


转换算法
随机生成去重

SQL

NoSQL

Scale
优化 response time
- Use Cache
 - 地理位置提速
centralized mysql + distributed memcached

 
一台数据库服务器搞不定


练习 Custom url (自定义链接 转 longurl)
自增Id法: 单独创建一个 cutsom url -> longurl 数据表
随机生成法: 直接存储 custom url