作者:yanyige | 发布时间:2017-04-12 09:49
第四天
9时57分 第一节课 前端 梁超(LC)
前端的演进
- 跨端化——IOS、Android、RN、Weex、Electron等
- 单页化——Vue、React等
- 服务化——Node
业务的演进
业务特性
- 日均PV:3亿
- 峰值QPS:2万/秒
- 用户级产品,首屏响应要快
- 高收入产品,要求4个9稳定
演化进程
个性化需求成为趋势(服务动态化) –> 网络劫持增多一度达到5(全站https)
服务动态化
全国多机房 + 海外机房
机房内部
负载均衡 + https代理集群 + http服务集群
用户访问路径
DNS分省运营商线路解析 + 负载均衡 + https代理服务 + http真实服务
HTTP服务组成
Nginx + Lua HTTP Server
|
|
Go Dynamic Service
|
|
Static Data Store————Static Data Generator
动静结合
Go Dynamic Service
遇到了什么问题
- 访问量大、机器负载高
- 机器资源有限、扩容困难
- 动态服务响应时间长
优化思路
- 优化现有的服务流程,动静分离
- 选择速度更快的语言
重新定义发布流程
性能保障
例子: 360娱乐
技术选型
前端: Vue + webpack 后端: Nginx + Koa + Middlewares + Docker
服务端: Nginx + Go + Docker
分析现状,定义角色
- 360娱乐访问量百万级,对压力要求不高
- 业务逻辑相对复杂
14时00分 第二节课 NodeJS lizheming
课堂链接
https://ppt.baomitu.com/d/0f4500f7#/11
NPM scripts
dependencies
dependencies
发布后需要安装的模块
devDependencies
自己需要用的模块
peerDependencies
依赖的模块
bundledDenpendencies
捆绑依赖
optionalDenpendencies
可选依赖
semver version
http://semver.org/lang/zh-CN/
bin
"bin": {
"test": "echo 123",
},
通过test执行这个脚本
registry
淘宝源
NPM的问题?
https://yarnpkg.com
制作、发布模块
-npm login -npm logout -npm publish -npm unpublish
练习 url: http://hitokoto.us/api.html
npm install request-promise-native registry=http://np
npm install --save // 保存到dependencies
const request = require(request-promise-native);
module.exports = function() {
request.get({
uri:
json: true
}).then(resp => resp.hitokoto);
}
更新模块
- npm version patch
- npm version minor
- npm version major
一个好的模块
- Git && 清晰的源码
- 浅显易懂的 README.md
- 遵循 semver 规范的版本号
- 高覆盖度的测试用例
npm能做什么?
CLI Web GUI loT Image Processing RealTime
- CLI: https://github.com/tj/commander.js
- GUI: https://electron.atom.io/
- IoT: https://www.h5jun.com/post/raspberry-pi.html
- Spider: PhantomJS / ScaperJS / Chromium
RESTful接口规范
- 每个 API 都对应一种资源或资源集合
- 使用 HTTP Method 来表示对资源的动作
- 使用 HTTP Status Code 来表示资源操作结果
Module自动更新
NodeJS调试
https://thinkjs.org/zh-cn/doc/2.2/debug.html