103
網站上線了,然後呢? 陳小風 TechPodcastNight

Tw mvc#31網站上線了然後呢

  • Upload
    twmvc

  • View
    499

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Tw mvc#31網站上線了然後呢

網站上線了,然後呢?

陳小風

TechPodcastNight

Page 2: Tw mvc#31網站上線了然後呢

http://mvc.tw

自我介紹

陳鋒逸(陳小風)

經歷

KKTIX 工程師

微軟最有價值專家 (MVP)

SkillTree兼任講師

社群研討會講師

TechPodcastNight

twMVC

AgileCommunity.tw

Javascript.tw

粉絲團: 愛流浪的小風

Page 3: Tw mvc#31網站上線了然後呢

軟體和教堂非常類似

建成之後我們就開始祈禱…

3

Page 4: Tw mvc#31網站上線了然後呢

http://mvc.tw

Software in 2017

趨勢變化

競爭激烈

時間就是金錢

Page 5: Tw mvc#31網站上線了然後呢

http://mvc.tw

對產品的共識不一致

5

我們眼中的產品

實際的產品

老闆希望的產品 PM想像的產品

股東理想中的產品 使用者用到的產品

Page 6: Tw mvc#31網站上線了然後呢

http://mvc.tw

提早確認

修正方向

修正

修正

修正

修正

適應改變

Page 7: Tw mvc#31網站上線了然後呢

在產品上線之前

工程師平均一天工作 12 小時…

在產品上線之後

工程師平均一天工作 12 小時…

On Call 24 小時…

7

Page 8: Tw mvc#31網站上線了然後呢

http://mvc.tw

產品團隊的挑戰

持續交付新產品

保持系統穩定

瞭解服務狀態

應付意外狀況

Page 9: Tw mvc#31網站上線了然後呢

持續交付高品質軟體

9

Page 10: Tw mvc#31網站上線了然後呢

對軟體開發來說

最困難的不是如何上線…

是如何快速、持續把新版本上線…

10

Page 11: Tw mvc#31網站上線了然後呢

http://mvc.tw

持續交付的痛點

穩定性

相容性

可回復性

應變性

Page 12: Tw mvc#31網站上線了然後呢

http://mvc.tw

你有聽過測試嗎?

驗證結果符合預期

找出潛在問題

安全防護網

有重構的機會

Page 13: Tw mvc#31網站上線了然後呢

http://mvc.tw

你的測試怎麼做?

Page 14: Tw mvc#31網站上線了然後呢

http://mvc.tw

你做的是測試嗎?

預期會發生的行為 => 驗證

找出意料外的行為 => 測試

讓 驗證 自動化順暢

穩定防呆

Page 15: Tw mvc#31網站上線了然後呢

http://mvc.tw

100

120137

160

20

17

23

15

SPRINT 1 SPRINT 2 SPRINT 3 SPRINT 4

Code Increasement

測試工作量

程式碼行數與測試需求

15

Page 16: Tw mvc#31網站上線了然後呢

http://mvc.tw

為什麼需要自動化測試

0

1

2

3

4

5

6

7

8

2 4 6 8 10 12

測試人員需求

有自動化測試 沒自動化測試

測試人員是原本的 7 倍

Page 17: Tw mvc#31網站上線了然後呢

http://mvc.tw

惡性循環

開發時間少

測試問題多

加班趕工上線

發現程式很難改

投入更多資源

Page 18: Tw mvc#31網站上線了然後呢

http://mvc.tw

讓測試自動化

單元

測試

整合

測試

壓力

測試

驗收

測試

系統

測試

Page 19: Tw mvc#31網站上線了然後呢

http://mvc.tw

有測試就安全了嗎?

涵蓋率 重複 安全性

風格 技術債

Page 20: Tw mvc#31網站上線了然後呢

http://mvc.tw

自動化部署

避免手誤

標準化流程

節省時間

減少人力介入

Page 21: Tw mvc#31網站上線了然後呢

21

Page 22: Tw mvc#31網站上線了然後呢

http://mvc.tw

Source Code Production

CI Server

Build Unit Test

Integration Test

Code Analysis

Deploy

持續交付流程

22

Page 23: Tw mvc#31網站上線了然後呢

http://www.ambysoft.com/essays/whyAgileWorksFeedback.html

23

Page 24: Tw mvc#31網站上線了然後呢

http://mvc.tw

Developer

工具不是萬能

人工確認

Definition of Done

同步資訊

24

Page 25: Tw mvc#31網站上線了然後呢

http://mvc.tw

Source Code Production

CI Server

Build Unit Test

Integration

Test

Code

Analysis

Deploy

Code ReviewPair Programming

持續交付流程

Page 26: Tw mvc#31網站上線了然後呢

http://mvc.tw

Development

Test

RD

QA

Test DB

開發

測試

Production DBStage

測試

Production

使用服務

正式上線

Multiple Stage

26

Page 27: Tw mvc#31網站上線了然後呢

http://mvc.tw

環境落差

環境不一致

資料量大

資料複雜度高

效能問題

架構問題

27

Page 28: Tw mvc#31網站上線了然後呢

http://mvc.tw

Canary & Rolling Release

App

1

App

1

App

1

App

1

App

1

App

1

App

1

App

1 V2

App

1 V2

App

1 V2

App

1 V2

App

1 V2

App

1 V2

App

1 V2

CI Server

app.com

Canary

Production

Page 29: Tw mvc#31網站上線了然後呢

http://mvc.tw

壓力測試的難題

與現實有落差

人類 vs 機器

測試的死角

瞬間的瓶頸

29

Page 30: Tw mvc#31網站上線了然後呢

30

Page 31: Tw mvc#31網站上線了然後呢

Unique User Count / Minutes

31

Page 32: Tw mvc#31網站上線了然後呢

http://mvc.tw

PhantomJs

根據 Request Log

根據 GA

客制化腳本

同時發動

模擬使用者行為

32

Page 33: Tw mvc#31網站上線了然後呢

http://mvc.tw

Customize Script

Runner

Admin

模擬使用者行為

33

Page 34: Tw mvc#31網站上線了然後呢

http://mvc.tw

Recap

確保品質

持續交付

避免意外

有效產出

34

Page 35: Tw mvc#31網站上線了然後呢

Immutable Infrastructure

35

Page 36: Tw mvc#31網站上線了然後呢

http://mvc.tw

WebSite

Database

Redis

網站架構

36

Page 37: Tw mvc#31網站上線了然後呢

http://mvc.tw

App App

Redis Database

• Stateless

• Recoverable

• Reuse

• Scale out & Scale up

Scalable Application

37

Page 38: Tw mvc#31網站上線了然後呢

http://mvc.tw

Maintainable

• Install

• Setup

• Maintain

38

Page 39: Tw mvc#31網站上線了然後呢

http://mvc.tw

Maintainable

• Install

• Setup

• Maintain

39

Page 40: Tw mvc#31網站上線了然後呢

http://mvc.tw

App App

Redis Database

Terraform

Infrastructure as Code

40

Page 41: Tw mvc#31網站上線了然後呢

http://mvc.tw

App

Redis Database

Puppetprovition

Infrastructure as Code

41

Page 42: Tw mvc#31網站上線了然後呢

http://mvc.tw

App

DockerWeb

DB

Redis

Infrastructure as Code

42

Page 43: Tw mvc#31網站上線了然後呢

http://mvc.tw

Branch A

Web

DB

Redis

Infrastructure as Code

43

Testing

Environment

Branch B

Web

DB

Redis

Production

Environment

App App

Web Web Web Web

DB

Redis

Page 44: Tw mvc#31網站上線了然後呢

http://mvc.tw

Terraform

使用 HCL / JSON

容易閱讀

支援多平台

可匯入現有資源

搭配版本控管

44

Page 45: Tw mvc#31網站上線了然後呢

http://mvc.tw

多平台

https://www.terraform.io/docs/providers/

目前有 70 多個 Provider

45

Page 46: Tw mvc#31網站上線了然後呢

http://mvc.tw

版本控管

46

Page 47: Tw mvc#31網站上線了然後呢

http://mvc.tw

Puppet

Provision

Package AWS AMI

Role Profile Pattern

Easy Reuse

Auto Scaling Group

47

Role

Nginx

Rails

FluentdAMI

Cloudwatch Log

Page 48: Tw mvc#31網站上線了然後呢

http://mvc.tw

Docker

快速建置環境

開發與正式環境一致

環境隔離

資源有效利用

降低維運成本

比虛擬化更輕量

Page 49: Tw mvc#31網站上線了然後呢

http://mvc.tw

WebSite

Database

Redis

20%

50%15%

資源最佳化

Page 50: Tw mvc#31網站上線了然後呢

http://mvc.tw

Docker

WebSite

Database

Redis

Docker

Page 51: Tw mvc#31網站上線了然後呢

http://mvc.tw

Recap

Stateless

Scalable

Stable

Reuseable

51

Page 52: Tw mvc#31網站上線了然後呢

System Monitor and Profiling

52

Page 53: Tw mvc#31網站上線了然後呢

http://mvc.tw

監控維度

Infrastructure

Server

Application

Flow

Page 54: Tw mvc#31網站上線了然後呢

http://mvc.tw

App App

Redis Database

AWS

CloudWatch

• ELB Request Count

• CPU Usage

• Network Thoughput

• Disk IO

Intrastructure Status

54

Page 55: Tw mvc#31網站上線了然後呢

http://mvc.tw

Cloudwatch Dashboard

Page 56: Tw mvc#31網站上線了然後呢

http://mvc.tw

AWS Cloudwatch

56

Page 57: Tw mvc#31網站上線了然後呢

http://mvc.tw

App

Monit

• CPU Usage

• Memory Usage

• Disk Usage

• Application Status

• Custom Script

Server Status

57

Page 58: Tw mvc#31網站上線了然後呢

http://mvc.tw

M/ Monit

Page 59: Tw mvc#31網站上線了然後呢

http://mvc.tw

Application Level

Nginx

Rails Go

• Access Log

• Error Log

• Audit Log

• Others

Application Status

59

Page 60: Tw mvc#31網站上線了然後呢

http://mvc.tw

Logs

60

Page 61: Tw mvc#31網站上線了然後呢

工程師就是要用 Terminal

Page 62: Tw mvc#31網站上線了然後呢

http://mvc.tw

替 Log 加分

Centralize

持續分析

資料視覺化

監控問題

預防異常

62

Page 63: Tw mvc#31網站上線了然後呢

http://mvc.tw

ELK

Web Server Buffer

AWS CloudWatch Log

63

Page 64: Tw mvc#31網站上線了然後呢

http://mvc.tw

Kibana

Page 65: Tw mvc#31網站上線了然後呢

http://mvc.tw

Log Processing

Normalize Filter Aggregate Visualizize

Page 66: Tw mvc#31網站上線了然後呢

http://mvc.tw

Log as Dashboard

66

Page 67: Tw mvc#31網站上線了然後呢

http://mvc.tw

Log as Dashboard

Page 68: Tw mvc#31網站上線了然後呢

http://mvc.tw

Flow Status

服務流程是否正常

交易中斷

無法登入

歷史數據比較

可透過 Google Analytics 實現

Page 69: Tw mvc#31網站上線了然後呢

http://mvc.tw

Flow

Status

69

Page 70: Tw mvc#31網站上線了然後呢

http://mvc.tw

Dashboard

即時更

健康狀

關鍵資

資訊整合

70

Page 71: Tw mvc#31網站上線了然後呢

App App 2 DB Redis Network

App 3 App 4 Request CacheApp 5

71

Page 72: Tw mvc#31網站上線了然後呢

http://mvc.tw

Profiling

特定時間

狀態分析

資訊記錄

效能改善

系統優化

Infrastructure

Server

Application

Flow

72

Page 73: Tw mvc#31網站上線了然後呢

http://mvc.tw

Analysis Event

Infrastructure

Server

Application

FlowCollect Data

73

Cron Job

Page 74: Tw mvc#31網站上線了然後呢

http://mvc.tw

Profile Record

Page 75: Tw mvc#31網站上線了然後呢

http://mvc.tw

Profile Record

Page 76: Tw mvc#31網站上線了然後呢

http://mvc.tw

Profile Record

Page 77: Tw mvc#31網站上線了然後呢

http://mvc.tw

資訊收集

分析應用

關注重點

Recap

77

Page 78: Tw mvc#31網站上線了然後呢

Chatops

78

Page 79: Tw mvc#31網站上線了然後呢

http://mvc.tw

Notification

79

Infrastructure

CI Server

DashboardSlack

Page 80: Tw mvc#31網站上線了然後呢

http://mvc.tw

即時通知

信箱不會爆炸

盡量避免雜訊

重要訊息

減少干擾

Notification

Infrastructure

CI Server

Dashboard

Slack

80

Page 81: Tw mvc#31網站上線了然後呢

http://mvc.tw

即時通知

信箱不會爆炸

盡量避免雜訊

重要訊息

減少干擾

Notification

81

Page 82: Tw mvc#31網站上線了然後呢

http://mvc.tw

Interaction

82

Infrastructure

CI Server

DashboardSlack

Page 83: Tw mvc#31網站上線了然後呢

http://mvc.tw

Interaction

83

Infrastructure

CI Server

Dashboard

Slack

Robot

Page 84: Tw mvc#31網站上線了然後呢

http://mvc.tw

不需要介面

指令操作

權限管理

隨時隨地

Robot

84

Slack

Robot

Page 85: Tw mvc#31網站上線了然後呢

http://mvc.tw

Query Log Aggregation

85

Slack

Robot Dashboard

Page 86: Tw mvc#31網站上線了然後呢

http://mvc.tw

主動查詢

被動提醒

86

Page 87: Tw mvc#31網站上線了然後呢

http://mvc.tw

Apply Infrastructure

87

Slack

Robot Infrastructure

設定系統機器數量

Page 88: Tw mvc#31網站上線了然後呢

http://mvc.tw

Apply Infrastructure

88

Slack

Robot

App

Page 89: Tw mvc#31網站上線了然後呢

http://mvc.tw

Query Server Status

89

Slack

Robot

Page 90: Tw mvc#31網站上線了然後呢

http://mvc.tw

綜合應用

90

InfrastructureDashboard

Slack

Robot

User

Request

機器數量不足 是否加開機器?

Page 91: Tw mvc#31網站上線了然後呢

http://mvc.tw

降低門檻

方便操作

重點提示

改善流程

Recap

91

Page 92: Tw mvc#31網站上線了然後呢

http://mvc.tw

有效利用資源

減少重複工作

可靠度

穩定性

總結

92

解決問題

預防問題

工具只是輔助

持續改善

Page 93: Tw mvc#31網站上線了然後呢

http://mvc.tw

減少浪費

達成目標

消除瓶頸

解決問題

團隊文化

93

Page 94: Tw mvc#31網站上線了然後呢

http://mvc.tw

人 工具>

94

Page 95: Tw mvc#31網站上線了然後呢

http://mvc.tw 95

Page 96: Tw mvc#31網站上線了然後呢

96

版本控制

產品

單元測試

整合測試

代碼風格

自動部署

結對編程

CodeReview

持續集成

實例化需求

敏捷開發

Terraform

Puppet

Docker

不可變架構

架構即代碼

Bash

Automation

自動延展

高可用性

ElasticSearch

Fluentd

Kibana

CloudWatch

Monit

Dashboard

Alarm

Chatops

Notification

Operation

Page 97: Tw mvc#31網站上線了然後呢

http://mvc.tw 97

產品

穩定

持續交付

Page 98: Tw mvc#31網站上線了然後呢

http://mvc.tw

謝 謝 大 家

98

Page 99: Tw mvc#31網站上線了然後呢

http://mvc.tw

兩週舉辦一次的 Friday Night 線上版科技宅聚會, 晚上 9點到 10點,分享關於近期學習的新知,也分享工程師職涯路上的酸甜苦辣。

Tech Podcast Night

@TechPodcastNight

@TechPodcastNight

@Tech-Podcast-Night-Taipei

Page 100: Tw mvc#31網站上線了然後呢

http://mvc.tw

Blog 是記錄知識的最佳平台

100

https://dotblogs.com.tw

Page 101: Tw mvc#31網站上線了然後呢

http://mvc.tw

Jetbrains 重構必備工具

101https://www.jetbrains.com/resharper/

Page 102: Tw mvc#31網站上線了然後呢

http://mvc.tw

業界師資、實戰教學

102

https://skilltree.my

Page 103: Tw mvc#31網站上線了然後呢

謝謝各位

• 本投影片所包含的商標與文字皆屬原著作者所有。• 本投影片使用的圖片皆從網路搜尋。• 本著作係採用姓名標示-非商業性-相同方式分享 3.0 台灣授權。閱讀本授權條款,請到

http://creativecommons.org/licenses/by-nc-sa/3.0/tw/,或寫信至Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

h t t p s : / / m v c . t w