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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Eric
April 28, 2018
Technology
1.7k
5
Share
加速你的Ansible
2018/04/28@DevOps Taiwan Meetup
https://devops.kktix.cc/events/meetup13-0428
Eric
April 28, 2018
More Decks by Eric
See All by Eric
用恐龍書剖析 AWS Legacy Infra 的效能瓶頸
eric8230
0
65
伸長自如的磁碟空間
eric8230
0
440
Other Decks in Technology
See All in Technology
「速く作る」から「正しく作る」へ ─ 生成AI時代の開発フロー改革の ロードマップと実行 ─
starfish719
0
7.5k
サイバーセキュリティ概論 / Introduction to Cybersecurity
ks91
PRO
0
150
チームで実践する AI-DLC 思考の軌跡を残すチェックポイント設計
belongadmin
0
2.6k
AI Engineering Summit Tokyo 2026 AIの前に、やることがある 〜医療データ企業の4フェーズ〜
dtaniwaki
0
1.8k
Djangoユーザが知っ得なPostgreSQL機能 - 設計の選択肢を増やす / Djang-use-PostgreSQL
soudai
PRO
0
180
SIer20年! 培ったスキルがスタートアップで輝く時
shucho0103
0
230
AI-DLCを活用した高品質・安全なAI駆動開発実践 / AI Driven Development
yoshidashingo
1
350
Unlocking the Apps
pimterry
0
230
「気づいたら仕事が終わっている」バクラクAIエージェント本番運用の裏側 / layerx-bakuraku-aie2026
yuya4
18
10k
AI フレンドリーなエラー監視を TypeScript で実現する
shinyaigeek
2
250
Ruby::Boxでできること、Refinementsでできること
joker1007
3
390
Javaコミュニティをもっと楽しむための9箇条
takasyou
0
1.3k
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
GitHub's CSS Performance
jonrohan
1033
470k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.5k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
Raft: Consensus for Rubyists
vanstee
141
7.5k
GraphQLとの向き合い方2022年版
quramy
50
15k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
55k
How to build a perfect <img>
jonoalderson
1
5.6k
The Cult of Friendly URLs
andyhume
79
6.9k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
340
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
HDC tutorial
michielstock
2
690
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 歡迎大家回饋建議