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.6k
加速你的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
用恐龍書剖析 AWS Legacy Infra 的效能瓶頸
eric8230
0
55
伸長自如的磁碟空間
eric8230
0
430
Other Decks in Technology
See All in Technology
Everything As Code
yosuke_ai
0
440
アラフォーおじさん、はじめてre:Inventに行く / A 40-Something Guy’s First re:Invent Adventure
kaminashi
0
200
MySQLのSpatial(GIS)機能をもっと充実させたい ~ MyNA望年会2025LT
sakaik
0
180
複雑さを受け入れるか、拒むか? - 事業成長とともに育ったモノリスを前に私が考えたこと #RSGT2026
murabayashi
0
350
スクラムマスターが スクラムチームに入って取り組む5つのこと - スクラムガイドには書いてないけど入った当初から取り組んでおきたい大切なこと -
scrummasudar
0
270
松尾研LLM講座2025 応用編Day3「軽量化」 講義資料
aratako
14
4.7k
AI との良い付き合い方を僕らは誰も知らない
asei
1
320
Directions Asia 2025 _ Let’s build my own secretary (AI Agent) Part 1 & 2
ryoheig0405
0
110
AWS Lambda durable functions を使って AWS Lambda の15分の壁を超えてみよう
matsuzawatakeshi
0
120
投資戦略を量産せよ 2 - マケデコセミナー(2025/12/26)
gamella
0
550
"人"が頑張るAI駆動開発
yokomachi
1
660
アプリにAIを正しく組み込むための アーキテクチャ── 国産LLMの現実と実践
kohju
1
270
Featured
See All Featured
Deep Space Network (abreviated)
tonyrice
0
32
The World Runs on Bad Software
bkeepers
PRO
72
12k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
130
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
96
Designing Powerful Visuals for Engaging Learning
tmiket
0
190
Visualization
eitanlees
150
16k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
67
Rebuilding a faster, lazier Slack
samanthasiow
85
9.3k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Speed Design
sergeychernyshev
33
1.5k
Color Theory Basics | Prateek | Gurzu
gurzu
0
160
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
110
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 歡迎大家回饋建議