ã¯ã¦ãª x DeNAååä¼ç»ãMobage éç¨æè¡åå¼·ä¼ã«è¡ã£ã¦ãã
ã¯ã¦ãª x DeNAååä¼ç»ãMobage éç¨æè¡åå¼·ä¼
2012.06.19
å°é¢¨ã§ããã決è¡ï¼ï¼çµãã£ãããSakura Cafeã§æ親ä¼ã
1. DeNAã¤ã³ãã©é¨éç°¡æç´¹ä»
ç»å£è ï¼DeNAå°éæ§
ã¤ã³ãã©é¨é
ãããã¯ã¼ã¯ã¨Mobageåºç¤
ãã©ãããã©ã¼ã ã¯ãæ¥æ¬ãUSãéå½ãä¸å½åãããã
ãµã¼ãã®æ ç¹ã¯ãåå¤å±ãæ±äº¬ããµã³ãã©ã³ã·ã¹ã³ãä¸æµ·
ç¹å¾´
1. é«ãã½ããã¦ã§ã¢éçºå
- Handler socket plugin
- MySQL-MHA
2. éå¯è±ªçæè¦
- ãµã¼ãå°æ°ã¯ãã°ãªã¼ã®ååãããã¨æããã
2. Mobageéç¨æè¡Webç·¨
Mobage Webãµã¼ãæ©ã®è³æºç®¡çã«ã¤ãã¦
ç»å£è ï¼DeNAæ¨å£æ§
2-1. Mobageã®ä½æ³¢é¡æ§æã«ã¤ãã¦
1. åºæ¬ãLAMP
2. Webãµã¼ãã¨DBãµã¼ãã大é¨å
3. Apache 㨠FastCGI ãåå±
4. FastCGIã¯ãã«ãããã»ã¹åãµã¼ã
5. ã²ã¼ã ãã¨ã«åé¢ããã¦ããããã§ã¯ãªã
- ã²ã¼ã éé£æºãç°¡åã«ã§ããã¡ãªããããã
6. ãªã¼ãã³ãã©ãããã©ã¼ã ã¯ã¢ããªãã¨ã«ç¬ç«ãã¦ãã
2-2. Webãµã¼ãæ©ã®è³æºæ¶è²»ã«ã¤ãã¦
- Webãµã¼ãæ©ã¯ãCPUã¾ãã¯ãã¡ã¢ãªãããã¯
- ã¡ã¢ãªä½¿ç¨éãã1Gbyteãè¶ ãã¦ãã¾ã
2-2-1. FastCGIã¯ã¼ã«æ°ã®ç®¡ç
- ãµã¼ã1å°ããã ã100ããã»ã¹ç¨åº¦
- CPUã³ã¢æ°ã®2,3åã¯å¿ è¦
- 1ã¤ã®ãªã¯ã¨ã¹ããå¦çããéã®åå以ä¸ã®æéã¯ãããã¯ã¼ã¯IOè¡ãªã©ã§sleepãã¦ãããã
- ã¯ã¼ã«ã¼ã¯ãå¤ãã»ã©ãèé害æ§ãé«ã¾ã
- å¤ãããã¨ã¡ã¢ãªä¸è¶³ã«ãªã
2-2-2. ãããã¬ã使ã£ãç¶æ³ã¢ãã¿ãªã³ã°
1. èµ°ã£ã¦ããããã»ã¹ã«ãããã¬ãã¢ã¿ããããã¢ã¿ãã¯ã¨ã¬ã¼ã¹ãã¨ããããã«ãã¿ãã
2. åããã»ã¹ã®ã¹ã¿ãã¯ãã¬ã¼ã¹ãä¸å®å¨æã§åå¾
3. httpdã¨FastCGIã対象
4. gdbã使ã£ã¦ããããbulkdbgã¨ãããã®ãä½æãå©ç¨ãã¦ãã
- ãã¿ãããããã¨ã«ã·ã³ãã«è§£æ±ºãã¦ãã
5. Mobageã§ã¯ãç´5ç§ããã«httpdã¨FastCGIã®åããã»ã¹ã®ã¹ã¿ãã¯ãã¬ã¼ã¹ãåå¾ããã°åºå
6. å©ç¨ç¶æ³ã¢ãã¿ãªã³ã°ã¨é害調æ»ã«å©ç¨
- ãªã¼ããããã¯ã»ã¨ãã©ãªã
7. accept()ã§ãããã¯ãã¦ããã¯ã¼ã«ã¼ã®æ°ãæ¸ã£ã¦ãããæ¯æ¸ãè¿ã
- ã¡ã¼ã«ã§è¦å
8. ãã°ãè¦ãã°åããç¶æ
2-2-3. é害調æ»ã®ææ³
- gdbçã§ç¢ºèªã§ããã®ã¯ãCã®ã¹ã¿ãã¯
- Perlã®ã¹ã¿ãã¯ãã¬ã¼ã¹ãè¦ãã
- gdbperl.pl ã¨ãããã®ãä½æ
- Perlããããã°ã·ã³ãã«ä»ãã§ã³ã³ãã¤ã«ããã¦ããªãã¨åããªã
- æ¬çªã§ã使ã£ã¦ãã
- NYTProfã§ãããã¡ã¤ã«ãã¼ã¿ã®åå¾
- ç¶æ³ãææ¡ã§ããªãããªèªä½ã¯ç¾ç¶ã»ã¼ãªããªã£ã
2-3. ã¡ã¢ãªå©ç¨å¹çå
åºæ¬
- ç¬ç«ããPerlã¢ã¸ã¥ã¼ã«ã«ãã¦ãã
Perlã¢ã¸ã¥ã¼ã«ããªãã¼ã
- æã®Mobage : forkãããåã¯ã¼ã«ãperlãexecãã¢ã¸ã¥ã¼ã«ãèªã¿è¾¼ã¿ãªã¯ã¨ã¹ãå¦ç
- ä»ã®Mobage : ã¢ããªã®ãã¦ã¼ã«ãèªã¿è¾¼ãã å¾ã«ã¯ã¼ã«ã¼ããã»ã¹ãforkããªã¯ã¨ã¹ãå¦ç
- forkã®ã¿ã¤ãã³ã°ã§ãSocketçãéããã¾ã¾ã ã¨åé¡ãèµ·ãããã¨ããã
- å¦çã®å®è¡é åºãå¤ãããã¨ã«ããå½±é¿ããã£ã
- 移è¡å¾ã¯ãã¡ã¢ãªã®ä½¿ç¨éã¯ååã«ãªã£ã
OSãã¼ã¸ãã£ãã·ã¥ã®å¹çå
- ã¢ããªãå±¥ããã°ãã¡ã¤ã«ããã£ãã·ã¥ããã¦ãã¾ã
- ã¡ã¢ãªããã¡ãã¨ããã°ååã®ã¿ã¤ãã³ã°ã§swapãã¦ãã
- posix_fadvise
- æ¬æ¥ãã¡ã¤ã«ãå©ç¨ããã¢ããªèªä½ã宣è¨ãããã®
- 10ç§ã«1åãdaemonãåããã¦ãã
- ãã°ãã¡ã¤ã«ããã£ãã·ã¥ã«ä¹ããªããªã£ã
3. Mobageéç¨æè¡DBç·¨
Mobage MySQLéç¨
ç»å£è ï¼DeNA岩永æ§
Many Servers
Master - Slave
critical SELECT -> master
non critical SELECT -> slave
ã¬ããªã±ã¼ã·ã§ã³ã¯ãéåæã¨ãªã£ã¦ãããææ°çã¯ã対å¿ã§ãã¦ããé¨åãããã
Sharding
+ divide per tables ( no join )
+ record sharding (difficult range scan)
ã¬ã³ã¼ãã§åããã®ã¯ãã¯ã©ã¤ã¢ã³ããµã¤ãã®ãã¸ãã¯ã§åããæ¹æ³ã¨ããããã³ã°æ
å ±ãå¥ãã¼ãã«ãç¨æããæ¹æ³ãããã
hash or mapping
ScaleOut
1. auto increment
- same schema - different database
2. MyISAM sequence table
ã¢ããªã±ã¼ã·ã§ã³å´ã§å¯¾å¦
Scale back
Reduce scale-outed servers
- 1ãµã¼ãã§è¤æ°ããã»ã¹èµ·åãã¦å¯¾å¿ãã¦ãã
- MySQLã¯ãã¹ã¿ã1ã¤ããæå®ãã§ããªã
- ä»®æ³IPã¢ãã¬ã¹ãå²ãå½ã¦ãããã®ã¿ãLISTENããããã«ãã(my.cnf)
- ãã¼ããå¤ããæ¹æ³ã¯ããã¼ã管çã大å¤
- ã¢ããªã±ã¼ã·ã§ã³å´ã§å¤æ´ããªããªãã®ã§ãä»®æ³IPã¢ãã¬ã¹ã®æ¹æ³ãè¡ãªã£ã¦ãã
Databackup
- ãã ã®ã¹ã¬ã¼ãããµã¼ãã¹ã«å ¥ã£ã¦ããªã
- mysqldumpã§è¡ãªã£ã¦ãã
- ããã使ã£ã¦ãslaveããã¤ã§ãä½ããã¨ãã§ãã
- slaveã®è¿½å ãããµã¼ãã¹ã«å½±é¿ãä¸ããã§ãã
MHA
- ãã¹ã¿ãè½ã¡ãéã«ãèªåã§ããã¹ã¿ææ ¼ããã¹ã¯ãªãã
Big Data
Purge
- ãããããã®ã¯ãå¤ããã¼ã¿ãæ¶ã
- å¤ããã¼ã¸ã§ã³ã§ã¯ãDELETEã§æ¶ãã¦ããæ¹æ³ãããªãã£ã
- DELETEã¯éãå¦ç
- 5.1以éã§ã¯ããã¼ãã£ã·ã§ã³æ©è½ã§ãã¼ãã«ã«ãã£ã¦ã¯ãç°¡åã«åé¤ã§ããããã«ãªã£ã
- range partition ã使ãã°ç°¡åã«åé¤ã§ãã
- drop table ã¨åãæè¦
High Traffic
- Range Scan ã¯æ°ãã¤ããã¹ã
- Primary Keyã§SELECTãããã¨ãå¤ã
- Handler socket plugin (made by higuchi)
- Too many UPDATE
- ããã¯ã®æéãã§ããã ãçããã
- SINãè½ã¡ããã¨ã¯ãã
- ã³ãã¯ã·ã§ã³ãã¯ã£ããã¨ã§ããã¯ãã¦ãã
- ããããªãã¹ã¿ã«å¯¾ãã1åã§æ´æ°ãè¡ããã
- 1ã¤ã®ãµã¼ãã§çºçããå ´åã¯ãæ¤ç¥ãã§ããããè¤æ°ãµã¼ãã§çºçããå ´åã¯ãè¨å®ãã¡ã¤ã«ã§åé¿ãããããªããâæéãããã
- ã¾ãã¯ããããããã¯ãèµ·ããªãããã«ãããã¥ã¼ãã³ã°
- 楽観çããã¯ããã¼ã¸ã§ã³ã«ã©ã ã¨ãããã®ãç¨æãã
- æ´æ°ããã¨ãã«ããã¼ã¸ã§ã³ã«ã©ã ãæ´æ°ãã
- ã¬ããªã±ã¼ã·ã§ã³é 延ãèµ·ãã¦ãã¾ã
- ãã®é 延ãã©ã®ããã«ãã¦è¨æ¸¬ããã
- ããã¯ã¢ãããµã¼ãã¯ãã¹ã¬ã¼ãããã¹ããã¯ãä½ããã¨ãå¤ã
- ããã¯ã¢ãããµã¼ãã§é 延ãçºçããããã¹ã¬ã¼ãã§ãçºçããã ããã¨ããèã
- ããã¯ã¢ãããµã¼ãã®ç¶æ ã確èªãããã¥ã¼ãã³ã°ãã¦ãã
- SSD ã¯ãã¬ããªã±ã¼ã·ã§ã³é 延ãçºçãã«ãã
- ã¬ããªã±ã¼ã·ã§ã³ã¯ã1ã¹ã¬ããã§è¡ããããã©ããã¦ãé 延ãããã
- HDDã§ã¯é 延ããããSSDã§ã¯ä½è£ã¨ããã±ã¼ã¹ã¯å¤ã ãã
- SATA-SSD is good
- SAS-SSD ã¯ãç¾æç¹ã§ã¯ã¾ã 使ããã¬ãã«ã§ã¯ãªãã¨èãã¦ãã