Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
加速你的Ansible
Search
Eric
April 28, 2018
Technology
5
1.4k
加速你的Ansible
2018/04/28@DevOps Taiwan Meetup
https://devops.kktix.cc/events/meetup13-0428
Eric
April 28, 2018
Tweet
Share
More Decks by Eric
See All by Eric
伸長自如的磁碟空間
eric8230
0
400
Other Decks in Technology
See All in Technology
DevIO2024_レガシー運用からの脱却 -クラウド活用の実践事例とベストプラクティス-
jun2882
0
210
JBUG岡山 #6 WordCamp男木島の チームビルディング
takeshifurusato
0
150
推薦システムを本番導入する上で一番優先すべきだったこと~NewsPicks記事推薦機能の改善事例を元に~
morinota
0
120
目標設定は好きですか? アジャイルとともに目標と向き合い続ける方法 / Do you like target Management?
kakehashi
10
3k
テストケースの自動生成に生成AIの導入を試みた話と生成AIによる今後の期待
shift_evolve
0
180
コンテナ・K8s研修 - 前半 コンテナ基礎・ハンズオン【MIXI 24新卒技術研修】
mixi_engineers
PRO
0
170
公共領域から学ぶ クラウド移行についてエンジニアが意識していること
kawakawa2222
0
140
Luupの開発組織におけるインシデントマネジメントの変遷 ver.RoadtoSRENEXT2024
grimoh
1
270
可視化プラットフォームGrafanaの基本と活用方法の全て
hamadakoji
0
230
RAGのサービスをリリースして1年3ヶ月が経ちました
segavvy
4
910
シフトレフトで挑む セキュリティの生産性向上
sekido
PRO
0
270
AWSで”最小権限の原則”を実現するための考え方 /20240722-ssmjp-aws-least-privilege
opelab
10
4.3k
Featured
See All Featured
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
35
6.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.3k
The Brand Is Dead. Long Live the Brand.
mthomps
52
36k
Designing for humans not robots
tammielis
247
25k
Fireside Chat
paigeccino
25
2.8k
Code Review Best Practice
trishagee
58
16k
Agile that works and the tools we love
rasmusluckow
325
20k
Web development in the modern age
philhawksworth
203
10k
Bootstrapping a Software Product
garrettdimon
PRO
304
110k
Building Applications with DynamoDB
mza
89
5.8k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
26
2.1k
Producing Creativity
orderedlist
PRO
340
39k
Transcript
加速你的Ansible 王仁宏 aka Eric 2018/04/28 @ DevOps Taiwan
Hi , I’m Eric
Ansible新手 (請大家鞭小力一點)
Agenda 1. 故事起源 2. Ansible加速 3. Q&A
故事起源 1. Ansible新手上路第一個月 2. 剛推坑同事使用 3. 該次部署主機群數量約150台 4. 新增一個檔案、刪除一個檔案
同事說... 雖然比以前土炮部署舒服, 但Ansible執行速度好慢...
http://i.imgur.com/CrMWH0h.jpg
於是開始思考,到底慢在哪裡。
收集執行時間數據 ansible-profile vim /etc/ansible/ansible.cfg callback_whitelist = profile_tasks :wq
None
150台的佈署時間 (調整前) 1. gathering facts時間約530秒 2. 新增一個檔案時間約18秒 3. 刪除一個檔案時間約17秒
565 秒
幾個小調整 1. Disable gathering facts (視情況) 2. Fork Process (ansible-playbook
-f n)
150台的佈署時間 (調整後-1) 1. gathering facts時間約530秒 -> 0秒 2. 新增一個檔案時間約18秒 ->
11秒 3. 刪除一個檔案時間約17秒 -> 10秒
21 秒
https://i.ytimg.com/vi/nYQyy7ZyOA8/hqdefault.jpg
沒有最快,只有更快。
Ansible ssh + python
那就從ssh開始動手腳吧。
SSH 連線再利用 1. SSH PIPELINING (視情況) 2. SSH Control Persist
SSH PIPELINING vim /etc/ansible/ansible.cfg pipelining=True :wq
SSH Control Persist OpenSSH 5.6 或更高 vim ~/.ssh/config Host *
ControlPersist 1h Compression yes ControlMaster auto ControlPath ~/.ssh/sockets/%r@%h-%p :wq // 連線持久化保留1小時 // 啟用壓縮 // ssh連線共用 //socket保存路徑
http://7.share.photo.xuite.net/leonchen01/176b299/8118575/320468842_m.jpg
150台的佈署時間 (調整後-2) 1. gathering facts 花費時間約0秒 2. 新增一個檔案的時間約11秒 -> 11秒
3. 刪除一個檔案的時間約10秒 -> 4秒
15 秒
150台的佈署時間 (調整後-2) 1. gathering facts 花費時間約0秒 2. 新增一個檔案的時間約11秒 -> 4秒
3. 刪除一個檔案的時間約4秒
8秒 以後部署不用一首歌的時間,8秒就足夠 XD
同事說... 這速度跑起來好爽阿...
總結 1. Ansible-profile 收集數據 2. Disable gathering facts (視情況) 3.
Fork Process (ansible-playbook -f n) 4. SSH PIPELINING (視情況) 5. SSH Control Persist (OpenSSH 5.6 或更高)
Thanks. ericwang8230 [at] gmail.com
Q&A 歡迎大家回饋建議