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
Docker Performance on Web Application
Search
Yuuki Tsubouchi (yuuk1)
January 17, 2015
Technology
7
130k
Docker Performance on Web Application
Docker Meetup Tokyo #4
Yuuki Tsubouchi (yuuk1)
January 17, 2015
Tweet
Share
More Decks by Yuuki Tsubouchi (yuuk1)
See All by Yuuki Tsubouchi (yuuk1)
博士学位論文予備審査 / Scaling Telemetry Workloads in Cloud Applications: Techniques for Instrumentation, Storage, and Mining
yuukit
1
1.6k
MetricSifter:クラウドアプリケーションにおける故障箇所特定の効率化のための多変量時系列データの特徴量削減 / FIT 2024
yuukit
2
160
工学としてのSRE再訪 / Revisiting SRE as Engineering
yuukit
19
12k
Cloudless Computingの論文紹介
yuukit
2
460
#SRE論文紹介 Detection is Better Than Cure: A Cloud Incidents Perspective V. Ganatra et. al., ESEC/FSE’23
yuukit
3
1.6k
エンジニアのためのSRE論文への招待 / Introduction to SRE Papers for Engineers
yuukit
2
11k
博士課程での研究まとめ 2023年1月版 / Summary of my research in the PhD course
yuukit
1
270
AI時代に向けたクラウドにおける信頼性エンジニアリングの未来構想 / DICOMO2022 6A-1
yuukit
7
2.9k
AIOps研究録―SREのための システム障害の自動原因診断 / SRE NEXT 2022
yuukit
10
12k
Other Decks in Technology
See All in Technology
技術に触れたり、顔を出そう
maruto
1
130
AWS Community Builderのススメ - みんなもCommunity Builderに応募しよう! -
smt7174
0
150
テストを書かないためのテスト/ Tests for not writing tests
sinsoku
1
170
FODにおけるホーム画面編成のレコメンド
watarukudo
PRO
2
200
「隙間家具OSS」に至る道/Fujiwara Tech Conference 2025
fujiwara3
6
6.1k
AWS re:Invent 2024 re:Cap Taipei (for Developer): New Launches that facilitate Developer Workflow and Continuous Innovation
dwchiang
0
140
今から、 今だからこそ始める Terraform で Azure 管理 / Managing Azure with Terraform: The Perfect Time to Start
nnstt1
0
120
OPENLOGI Company Profile
hr01
0
58k
アジャイルチームが変化し続けるための組織文化とマネジメント・アプローチ / Agile management that enables ever-changing teams
kakehashi
3
3.2k
デジタルアイデンティティ人材育成推進ワーキンググループ 翻訳サブワーキンググループ 活動報告 / 20250114-OIDF-J-EduWG-TranslationSWG
oidfj
0
380
Visual StudioとかIDE関連小ネタ話
kosmosebi
1
360
re:Invent2024 KeynoteのAmazon Q Developer考察
yusukeshimizu
1
120
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
44
13k
Bash Introduction
62gerente
610
210k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
Speed Design
sergeychernyshev
25
730
A Philosophy of Restraint
colly
203
16k
It's Worth the Effort
3n
183
28k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
860
Transcript
Docker Performance on Web Application JEZ@VVLJ %PDLFS.FFUVQ5PLZP
id:y_uuki ӡ༻ @y_uuk1
Docker Engine্Ͱɹ ΞϓϦέʔγϣϯΛɹ ಈ͔ͯ͠ੑೳྼԽ ͠ͳ͍ͷʁ
None
1 DockerͷύϑΥʔϚϯεʹ ͓͍ͯॏཁͳ͜ͱͳʹ͔
Linux Containers
/FUXPSL /BNFTQBDF *1$ /BNFTQBDF 654 /BNFTQBDF .PVOU /BNFTQBDF 6TFS /BNFTQBDF
1*% /BNFTQBDF
/FUXPSL /BNFTQBDF *1$ /BNFTQBDF 654 /BNFTQBDF .PVOU /BNFTQBDF 6TFS /BNFTQBDF
1*% /BNFTQBDF -JOVYΧʔωϧͷ໊લۭؒػೳͷ ू·Γ
Linux Containers Χʔωϧͷ֤ϦιʔεΛ໊લۭؒͰִ͠ ۭͨؒͰϓϩηεΛ࣮ߦ͢Δͱ͍͏Ϟσϧ ϑΝΠϧγεςϜɼϢʔβɼϓϩηεςʔ ϒϧɼωοτϫʔΫ… etc LXC Linux
Containers ͷϑϩϯτΤϯυ
Linux Containers Overhead ୯ମͷLinux ΧʔωϧͰ݁͢ΔͷͰ ΦϒδΣΫτͷڞ༗ޮ͕Α͍ Hypervisor ͷΑ͏ʹ֤ϦιʔεΛɹɹ ೋॏॲཧ͠ͳͯ͘Α͍
example/packet receive /*$ ,FSOFM 6TFSMBOE $PQZ $PQZ 4JOHMF ,FSOFM
example/packet receive /*$ ,FSOFM 6TFSMBOE $PQZ $PQZ /*$ ,FSOFM ,FSOFM
$PQZ $PQZ 4JOHMF ,FSOFM )ZQFSWJTPS 9FO ,7. 6TFSMBOE $PQZ ˞ 43*07ͳͲ)ZQFSWJTPSͰύέοτίϐʔΦʔόϔουΛগͳ͘ ͢Δ࣮͋Δ
Linux Containers ͩͱ Single Kernel Ͱ͍
Docker Filesystem -JOVY$POUBJOFST
UNION Filesystem -JOVY$POUBJOFST %PDLFS'JMFTZTUFN
IUUQTEPDTEPDLFSDPNUFSNTJNBHFTEPDLFSpMFTZTUFNTNVMUJMBZFSQOH UNION Filesystem Image
8SJUF*0 3FBE*0 ADBUFUDEFCJBO@WFSTJPOA
8SJUF*0 3FBE*0 8SJUF*0࠷্ॻ͖ࠐΈ 3FBE*0֘ϑΝΠϧΛ ֨ೲ͢ΔΛ୳ࡧ
UNION Filesystem • AUFS, Btrfs, OverlayFS … ͳͲΛ࣮ͬͯݱ • Copy
On Write: ݪຊΛෳͨ͠;ΓΛͯ͠ ͓͍ͯ৽نॻ͖ࠐΈ͕͋ͬͨΒෳΛ࡞Δ • LinuxΧʔωϧඪ४ͷ Device MapperΛͬ ࣮ͯݱͰ͖Δ
Storage drivers -JOVY$POUBJOFST %PDLFS'JMFTZTUFN 6/*0/'JMFTZTUFN
EFWJDFNBQQFS BVGT CUSGT PWFSMBZGT
EFWJDFNBQQFS BVGT CUSGT PWFSMBZGT 6OJPO'4ͷ࣮ΛબͰ͖Δ
Storage drivers devicemapper, aufs, btrfs, overrayfs (vfs) Χʔωϧඪ४ͳͨΊRHELܥͰͷɹɹ σϑΥϧτ devicemapper
Device Mapper ϒϩοΫσόΠεͷI/Oʹ༷ʑͳมΛՃ͑Δ͜ͱ͕ Ͱ͖Δ (҉߸ԽɺετϥΠϓɺϛϥʔ ͳͲ) ϒϩοΫσόΠευϥΠόϨϕϧͷ࣮ͳͷͰɹɹɹɹ ಛఆͷϑΝΠϧγεςϜʹґଘ͠ͳ͍ LVMͳͲͰΘΕ͍ͯΔ docker
commit ͕ΔͱsnapshotσόΠεΛ࡞ͯ͠Π ϝʔδͱ͢Δ
Volume -JOVY$POUBJOFST %PDLFS'JMFTZTUFN 6/*0/'JMFTZTUFN 4UPSBHF%SJWFST
Volume ίϯςφؒͰσΟϨΫτϦΛڞ༗͢ΔͨΊͷͷ ίϯςφ͝ͱͰͳ͘DockerάϩʔόϧͳྖҬʹ֨ ೲ͞ΕΔ ࢦఆͨ͠σΟϨΫτϦҎԼͷΠϝʔδΛόΠύε͠ ͯΞΫηε I/Oཁٻ͕Union FS෦Λ௨Βͳ͍ͷͰΦʔόϔου ͕গͳ͍
howto/Volume EPDLFSSVOWWBSMJCNZTRMNZTRM 70-6.&WBSMJCNZTRM EPDLFSSVONZTRM %PDLFSpMF 4IFMM 4IFMM PS
Docker Network -JOVY$POUBJOFST %PDLFS'JMFTZTUFN 6/*0/'JMFTZTUFN 4UPSBHF%SJWFST 7PMVNF
Portmapper -JOVY$POUBJOFST %PDLFS'JMFTZTUFN 6/*0/'JMFTZTUFN 4UPSBHF%SJWFST 7PMVNF %PDLFS/FUXPSL
Portmapper ίϯςφؒ௨৴ίϯςφɾϗετؒ௨৴ϗετଆ ͷ iptables ͰNAT ! iptables͕ͳ͍ڥͩͱಠࣗͷϢʔβϥϯυͷϓϩη ε(docker-proxy)Ͱίϯςφؒ௨৴ "%0$,&3JEPDLFSQUDQNUDQEQPSUK%/"5 UPEFTUJOBUJPO
EPDLFSQSPYZQSPUPUDQIPTUJQIPTUQPSU DPOUBJOFSJQDPOUBJOFSQPSU
Host Networking -JOVY$POUBJOFST %PDLFS'JMFTZTUFN 6/*0/'JMFTZTUFN 4UPSBHF%SJWFST 7PMVNF %PDLFS/FUXPSL 1PSUNBQQFS
Host Networking ίϯςφ༻ͷNetwork NamespaceΛ࡞Β ͣʹϗετͷωοτϫʔΫΛͦͷ··͏ ίϯςφϗετଆͷportΛlisten͢Δ iptablesdocker-proxyΛܦ༝͠ͳͯ͘Α ͘ͳΓɺΦʔόϔου͕খ͘͞ͳΔ
howto/Host Networking ! FYFDESJWFSOBUJWF PS -9$Ҏ্ͰFYFDESJWFSMYD ͕ඞཁ EPDLFSSVOOFUIPTUNZTRM
-JOVY$POUBJOFST %PDLFS'JMFTZTUFN 6/*0/'JMFTZTUFN 4UPSBHF%SJWFST 7PMVNF %PDLFS/FUXPSL 1PSUNBQQFS )PTU/FUXPSLJOH DockerͷύϑΥʔϚϯεʹ ͓͍ͯॏཁͳ͜ͱͳʹ͔
2 DockerԽͨ͠ ISUCONΞϓϦέʔγϣϯ ͷϕϯνϚʔΫ
ISUCON *JLBOKJOJ4QFFE6Q$0/UFTU
/HJOY CFODI NBSLFS .Z42- "QQ .FNDBDIFE ISUCON4 ༧બ
Machine & Software Spec instance type: m3.xlarge CPU: Xeon E5-2670
v2 @ 2.50GHz 4 vCPU Memory: 16GB RAM Storage: Magnetic volume OS: Ubuntu 14.04 LTS Kernel 3.18.0 Docker: 1.4.1 (latest) MySQL: 5.5.40, memcached: 1.4.14, Nginx:1.4.6
νϡʔχϯά༰ • είΞ 38446 ( 3000 req/s) • ࢼߦ͝ͱʹ +-1000
είΞఔͷޡࠩ • ༧બಥഁϨϕϧ • σʔλશ෦ϝϞϦʹΔ • ηογϣϯใͳͲ memcached • Nginx Ͱ੩తϑΝΠϧΛฦ͢ • ωοτϫʔΫελοΫɺNginx, MySQL ී௨ͷ νϡʔχϯά
Evaluation
• Nginx ͱ MySQL ΛͦΕͧΕDockerԽ • ҎԼͷ֤ํࣜΛnative(default)ͱൺֱ • Nginx͚ͩDockerԽ •
—net=host ͱ —net=bridge • MySQL͚ͩDockerԽ • storage-driver=devicemapper ͱ storage-driver=overlayfs • Volume ͷ ON/OFF
Result
EFGBVMU /HJOY OFUCSJEHF /HJOY OFUIPTU
/HJOYʹύέοτ͕ू͢Δ /"15͢ΔΦʔόϔου͕ߴ͍
EFGBVMU .Z42- EFWJDFNBQQFS WPMVNFP⒎ .Z42- EFWJDFNBQQFS WPMVNFPO .Z42- PWFSMBZGT WPMVNFP⒎
.Z42- PWFSMBZGT WPMVNFPO
7PMVNFͷ0/0''ͱ TUPSBHFESJWFSʹΑΔ ੑೳྼԽͳ͠
7PMVNF0''ͰมΘΒͳ͍ 3FBE*0ϝϞϦʹશ෦ͷΔ 8SJUF*0࠷্͚ͩ
NAPTͷߴԽ
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j
DOCKER
-A OUTPUT E -m addrtype --dst-type LOCAL -j DOCKER
127.0.0.1Ѽͩͱiptablesͷ DockerνΣʔϯʹೖΒͳ͍
docker-proxy EPDLFSQSPYZQSPUPUDQIPTUJQ IPTUQPSU DPOUBJOFSJQDPOUBJOFSQPSUA
docker-proxy EPDLFSQSPYZQSPUPUDQIPTUJQ IPTUQPSU DPOUBJOFSJQDPOUBJOFSQPSUA CPU 50%
benchmarker bench --host 172.31.8.235 --init ~/init.sh --workload 8
32172 37931
ͳͥ userland ͷ proxy ͕͍Δͷ͔
IUUQTHJUIVCDPNEPDLFSEPDLFSQVMM
Hairpin NAT
)PTU $POUBJOFS EPDLFS -*45&/ FUI FUI MP FUI FUI
ETU MP FUI FUI )PTU $POUBJOFS EPDLFS -*45&/ FUI
FUI
ETU "%0$,&3JEPDLFSQUDQNUDQEQPSU K%/"5UPEFTUJOBUJPO )PTU $POUBJOFS MP FUI FUI EPDLFS
-*45&/ FUI FUI
ETU "%0$,&3JEPDLFSQUDQNUDQEQPSU K%/"5UPEFTUJOBUJPO )PTU $POUBJOFS MP FUI FUI EPDLFS
-*45&/ -*45&/ Ծbridge(docker0)Λ Hairpin NAT modeʹ͠ͳ͍ͱ NAT͞Εͳ͍
FDIPTZTDMBTTOFUCSCSJGFUIIBJSQJO@NPEF
IUUQTHJUIVCDPNEPDLFSEPDLFSQVMM
None
3)&-BOE$FOU04 SFBEPOMZTZT
1. DockerͷύϑΥʔϚϯεʹ͍ͭͯ ॏཁͳࣄͳʹ͔ 2. DockerԽͨ͠ISUCONΞϓϦέʔ γϣϯͷϕϯνϚʔΫ
Linux Containers Docker Filesystem UNION Filesystem Storage drivers Volume Docker
Network Portmapper Host Networking
Linux Containers Docker Filesystem UNION Filesystem Storage drivers Volume Docker
Network Portmapper (Performance issue) Host Networking
None
IUUQIBUFOBDPSQKQSFDSVJUDBSFFSTBMFTFOHJOFFS ηʔϧεΤϯδχΞ৬
! 8FCΦϖϨʔγϣϯΤϯδχΞ Λืू͓ͯ͠Γ·͢