ç¾å®çãªWebãµã¼ãã¹ç°å¢ã«ããã¦ãDockeråã«ããããã©ã¼ãã³ã¹ä½ä¸ãã©ã®ç¨åº¦ã®ãã®ã調æ»ããããã«ã ISUCON4 の予選問題ã®ãã¡ãNginx 㨠MySQL é¨åã Docker åãã¦ãã³ããã¼ã¯ãã¨ã£ã¦ã¿ãã å ¸åçãªWebãµã¼ãã¹ã·ã¹ãã ã®3層æ§é ï¼Proxy, App, DBï¼ãæ§ç¯ãããã³ããã¼ã«ã¼ã«ããé«ã¯ã¼ã¯ãã¼ããå®ç¾ã§ããã®ã§ãISUCON ã®äºé¸åé¡ã¯é©å½ãªé¡æã¨ãããã Docker ã®ããã©ã¼ãã³ã¹ã«ã¤ãã¦çæãããã¨ã¯å æ¥æ¸ããã¨ã³ããªã«å ¨ã¦æ¸ãã¦ãã
ä¸è¨ã®ã¨ã³ããªãè¦ç´ããã¨ãDocker ã®ããã©ã¼ãã³ã¹ã«ã¤ãã¦éè¦ãªãã¨ã¨ã¯
- storage-driver ã®é¸æ (AUFS or Device mapper or ...)
- Volume ã® ON / OFF
- AUFS ãªã©ã®å·®åãã¡ã¤ã«ã·ã¹ãã ããã¤ãã¹ãããããªãã
- Host networking ã® ON / OFF
- NAPTï¼ãã¼ããããã³ã°ï¼ ããªããããã
ã®3ã¤ã§ãããåè 2ã¤ããããã¯I/Oéç´ãªã¢ããªã±ã¼ã·ã§ã³ãå¾è ããããã¯ã¼ã¯I/Oéç´ãªã¢ããªã±ã¼ã·ã§ã³ã«ããã¦ç¹ã«éè¦ã§ãããã¨ãããã£ãã äºé¸ã§ã¯ãèªãã¼ã ã¯Nginx, MySQL, memcached, Perl(Webã¢ããªãµã¼ã)ã使ã£ã¦ããããå ¨é¨ Docker åããã®ãé¢åãªã®ã§ãä¸è¿°ã®ã¨ã³ããªã®ç¥è¦ããããããã¯I/Oéç´ãª MySQL 㨠ãããã¯ã¼ã¯I/Oéç´ãª Nginx ã Docker åããã°ååã ããã¨èããã
ãã³ããã¼ã¯æ¡ä»¶
åºæ¬çã«ãISUCON4äºé¸ã®ã¬ã®ã¥ã¬ã¼ã·ã§ã³ã«åã£ã¦ãã
ã¤ã³ã¹ã¿ã³ã¹ã¿ã¤ã: m3.xlarge CPU: Xeon E5-2670 v2 @ 2.50GHz 4 vCPU ã¡ã¤ã³ã¡ã¢ãª: 16GB RAM ã¹ãã¬ã¼ã¸: EBS Magnetic volumes OS: Amazon Linux 3.14.19-17.43
èªãã¼ã ã®ISUCON4äºé¸æã®æ§æãåºæºã«ãã¦ããã(Dockeråããé½åä¸ãUNIXãã¡ã¤ã³ã½ã±ãããåã£ã¦ããã®ã§ãã¹ã³ã¢ã¯å¤å°è½ã¡ã¦ãï¼
- ã¹ã³ã¢ 39982 (ç´ 3000 req/s)
- 試è¡ãã¨ã« +-1000 ã¹ã³ã¢ç¨åº¦ã®èª¤å·®ã¯ã§ã
- äºé¸çªç ´ã¬ãã«
- ãã¼ã¿ã¯å ¨é¨ã¡ã¢ãªã«ä¹ã
- ã»ãã·ã§ã³æ å ±ãªã©ã¯ memcached
- Nginx ã§éçãã¡ã¤ã«ãè¿ã
- ãããã¯ã¼ã¯ã¹ã¿ãã¯ãNginx, MySQL ã¯æ®éã®ãã¥ã¼ãã³ã°
ãã³ããã¼ã¯çµæã¨èå¯
- MySQL 㨠Nginx 両æ¹ã®ã§ Host Networking on/off æ¯è¼
- Volume ã® on/off æ¯è¼ã¯ MySQL ã®ã¿
- benchmarker ã® workload æå®ã¯å ¨ã¦ 22 (ä¸å®)
- Docker 1.2.0
- Docker ã®ãªã³ã¯æ©è½ã¯ä½¿ã£ã¦ãªã
- storage-driver ã«ã¯ device-mapper ãé¸æ
- æ¬å½ã¯ AUFS ã¨æ¯è¼ããã¹ãã ããAmazon Linux ã§ã¯ AUFS ã®ã¤ã³ã¹ãã¼ã«ãé¢å...
çµæã¯ä»¥ä¸ã®ã¨ãããnet=bridge 㯠Host Networking ã OFFãnet=host 㯠ON ã«ãã¦ããç¶æ ã§ããã
æ§æ | ã¹ã³ã¢ |
---|---|
default | 39982 |
Nginx(net=bridge) | 32368 |
Nginx(net=host) | 38976 |
MySQL(net=bridge) | 38346 |
MySQL(net=host) | 40802 |
MySQL(net=host, no-volume) | 39335 |
ã¾ããNginx(net=bridge) ã20%ã»ã©é ãã ããã¯NAPTå¦çã®ãªã¼ããããã«ãããã®ã¨æ¨æ¸¬ã§ããã ä¸æ¹ã§ãMySQL(net=bridge) ã®å ´åã¯ããã©ã«ãã¨ã»ã¨ãã©å¤ãããªãã¨ãããã¿ãã¨ããªãã¼ã¹ãããã·ã®ãããªãããã¯ã¼ã¯I/Oéç´ãªã¯ã¼ã¯ãã¼ãã®ã¢ããªã±ã¼ã·ã§ã³ã®å ´åããªã¼ããããããã大ããã¨è¨ããã
次ã«ãMySQL(net=host, no-volume)ã®ã¹ã³ã¢ãããã©ã«ããã¾ãå¤ãããªãã http://yuuki.hatenablog.com/entry/docker-performance ã®ã¨ã³ããªã§ã¯ãI/Oéç´ãªã¢ããªã±ã¼ã·ã§ã³ã§ã¯ Volume ã使ããªãã¨ãAUFS ã®å ´åãI/Oã¬ã¤ãã³ã·ã大ããã¨ããçµè«ã«ãªã£ãã ä»å使ã£ã Device mapper ã ã¨ããããã¯ããã¤ã¹ãæãã¦å±¤ãä½ãå®è£ ãªã®ã§ãAUFSã®ããã«ããããI/Oè¦æ±ãå層ãééãããªã¼ããããããªãå¯è½æ§ãããã ã¨ã¯ãããä»åã¯æ¸ãè¾¼ã¿I/Oãããã»ã©å¤ããªãããã¼ã¿ãã¡ã¢ãªã«å ¨ã¦ã®ã£ã¦ããã®ã§ããã¡ã¤ã«ã·ã¹ãã 層ããã¤ãã¹ãã¦ããã¾ãå¹æããªãã£ãã®ãããããªãã
ãã®ä»ã«ã¤ãã¦ã¯ãnet=host ã ã¨NAPTãªã¼ããããããªããããããã©ã«ãã¨ã»ã¼å¤ãããªããªã©ãäºæ³ã©ããã®çµæã ã£ãã ISUCONã®ãããªé«è² è·ç°å¢ã«ããã¦ãããªãã·ã§ã³ãé©åã«é¸ã¹ã°Dockeråã«ãããããã©ã¼ãã³ã¹ãè½ã¡ããã¨ã¯ããã»ã©ãªãã¨ãããã¨ãããã£ãã
ãè£è¶³ã docker-proxy ã«ã¤ãã¦
Nginx(net=bridge) ã®ã¨ããdocker-proxy ã¨ãããããã»ã¹ã top ã§ã¿ã¦ CPU 45%æ¶è²»ãã¦ãããããé ãã¯ãã ã
docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip x.x.x.x -container-port 80
docker-proxy 㯠Docker 1.2.0 ããå°å ¥ãããã¢ã¦ããã³ããã©ãã£ãã¯ãåã³ã³ããã¸ã«ã¼ãã£ã³ã°ãããã®ãããã
The Docker userland proxy that routes outbound traffic to your containers now has its own separate process (one process per connection). This greatly reduces the load on the daemon, which considerably increases stability and efficiency.
ãã¼ããããã³ã°ããã¦ã¼ã¶ã©ã³ãããã»ã¹ãDockeræ¬ä½ã¨å¥ããã»ã¹ã§èµ·åãããããã«ãªã£ãã1ã³ãã¯ã·ã§ã³ããã1ããã»ã¹ã¨ãããã©ãHTTP keepalive åã£ã¦ãããã³ããã¼ã«ã¼ããã¦ã1ããã»ã¹ããä¸ãã£ã¦ãªãã£ããããªã®ã§ãã©ã¡ããã¨ãã㨠one process per port ãªæ°ãããï¼è¦èª¿æ»ï¼ã Docker 1.2.0 以åãªãã°ãã£ã¨é ãã£ãã¨ãããã¨ã«ãªãã ããããããã¼ããããã³ã°ã£ã¦ã¦ã¼ã¶ã©ã³ãã§ãããªãã¨ãã¡ãªã®ãããã®ãããã¯ã¾ã ããããã£ã¦ãªãã
å®è£ ã¯ãã®è¾ºãhttps://github.com/docker/docker/blob/master/daemon/networkdriver/portmapper/proxy.go
ãã®ä»
ãã®å 容㯠第5回 コンテナ型仮想化の情報交換会@大阪 - connpass ã§ãçºè¡¨ããã¦ããã ããã @tenforward ããã® Linuxコンテナの基本と最新情報 (2014-11-14) // Speaker Deck ãLinuxã³ã³ãããç解ããä¸ã§åèã«ãªã£ãã
ã¡ãªã¿ã«ãISUCONã¯ä»å¹´ååºå ´ãã¦æ¬æ¦ã§è² ããã
ãã¼ã ã¡ã³ãã¼ããªãã³ã«éå¶ã®çæ§ãæ¬å½ã«ãã¤ãããã¾ã§ããã