ãã£ãªãšetcdã«ã€ããŠã®çãç©èª
etcdã¯ã©ã¹ã¿ãŒã®ããã©ãŒãã³ã¹ã¯ãã¹ãã¬ãŒãžã®ããã©ãŒãã³ã¹ã«å€§ããäŸåããŸãã etcdã¯ãããã€ãã®ã¡ããªãã¯ãPrometheusã«ãšã¯ã¹ããŒãããŠãã¹ãã¬ãŒãžããã©ãŒãã³ã¹ã«é¢ããå¿
èŠãªæ
å ±ãæäŸããŸãã ããšãã°ãã¡ããªãã¯wal_fsync_duration_secondsã etcdã®ããã¥ã¡ã³ãã«ã¯ãã¹ãã¬ãŒãžãååã«é«éã§ãããšèŠãªãããã«ã¯ããã®ã¡ããªãã¯ã®99ããŒã»ã³ã¿ã€ã«ã10ããªç§æªæºã§ããå¿
èŠããããŸãã Linuxãã·ã³ã§etcdã¯ã©ã¹ã¿ãŒãå®è¡ããäºå®ã§ãã¹ãã¬ãŒãžãïŒSSDãªã©ã®ïŒååã«é«éãã©ãããè©äŸ¡ããå Žåã¯ãI / Oæäœããã¹ãããããã®äžè¬çãªããŒã«ã§ããfioã䜿çšã§ããŸãã 次ã®ã³ãã³ããå®è¡ããŸããtest-dataã¯ãã¹ãã¬ãŒãžããŠã³ããã€ã³ãã®äžã®ãã£ã¬ã¯ããªã§ãã
fio --rw=write --ioengine=sync --fdatasync=1 --directory=test-data --size=22m --bs=2300 --name=mytest
çµæãèŠãŠã fdatasyncæéã®99ããŒã»ã³ã¿ã€ã«ã10ããªç§æªæºã§ããããšã確èªããã ãã§ãã ã¯ãã®å Žåãããªãé«éã®ã¹ãã¬ãŒãžããããŸãã çµæã®äŸã次ã«ç€ºããŸãã
sync (usec): min=534, max=15766, avg=1273.08, stdev=1084.70 sync percentiles (usec): | 1.00th=[ 553], 5.00th=[ 578], 10.00th=[ 594], 20.00th=[ 627], | 30.00th=[ 709], 40.00th=[ 750], 50.00th=[ 783], 60.00th=[ 1549], | 70.00th=[ 1729], 80.00th=[ 1991], 90.00th=[ 2180], 95.00th=[ 2278], | 99.00th=[ 2376], 99.50th=[ 9634], 99.90th=[15795], 99.95th=[15795], | 99.99th=[15795]
泚é
- ç¹å®ã®ã·ããªãªçšã«--sizeããã³--bsãªãã·ã§ã³ãæ§æããŸããã fioããæçšãªçµæãåŸãã«ã¯ãå€ãå
¥åããŸãã ã©ãã§å
¥æã§ããŸããïŒ fioã®èšå®æ¹æ³ãåŠãã æ¹æ³ããèªã¿ãã ããã
- ãã¹ãäžãI / Oè² è·å
šäœã¯fioããçºçããŸãã å®éã®ã·ããªãªã§ã¯ãwal_fsync_duration_secondsã«é¢é£ãããã®ãé€ããä»ã®æžã蟌ã¿èŠæ±ããªããžããªã«å±ãå¯èœæ§ããããŸãã è¿œå ã®è² è·ã«ãããwal_fsync_duration_secondsã®å€ãå¢å ããŸãã ãããã£ãŠã99ããŒã»ã³ã¿ã€ã«ãã»ãŒ10ããªç§ã«éããå Žåãã¹ãã¬ãŒãžã®é床ã¯ååã§ã¯ãããŸããã
- 3.5以äžã®fioããŒãžã§ã³ã䜿çšããŸãïŒä»¥åã®ããŒãžã§ã³ã§ã¯fdatasyncæéã®ããŒã»ã³ã¿ã€ã«ã衚瀺ãããŸããïŒã
- äžèšã§ã¯ãfioã®çµæã®ã¹ããããã®ã¿ã瀺ãããŠããŸãã
ãã£ãªãšetcdã«ã€ããŠã®é·ã話
etcdã®WALãšã¯
ããŒã¿ããŒã¹ã¯éåžžã å
è¡æžã蟌ã¿ãã°ã䜿çšããŸãã etcdãããã䜿çšããŸãã ããã§ã¯ãå
è¡æžã蟌ã¿ãã°ïŒWALïŒãã°ã®è©³çŽ°ã«ã€ããŠã¯èª¬æããŸããã ç¥ã£ãŠããå¿
èŠãããã®ã¯ãetcdã¯ã©ã¹ã¿ãŒã®åã¡ã³ããŒãæ°žç¶ã¹ãã¬ãŒãžã«ãããç¶æããŠããããšã ãã§ãã etcdã¯ãåããŒãšå€ã®ãã¢ã®æäœïŒæŽæ°ãªã©ïŒãWALã«æžã蟌ãã§ããããªããžããªã«é©çšããŸãã ã¹ãããã·ã§ããéã§ã¹ãã¬ãŒãžã¡ã³ããŒã®1ã€ãã¯ã©ãã·ã¥ããŠåèµ·åãããšãWALã³ã³ãã³ãã䜿çšããŠæåŸã®ã¹ãããã·ã§ãããããã©ã³ã¶ã¯ã·ã§ã³ãããŒã«ã«ã§å埩ã§ããŸãã
ã¯ã©ã€ã¢ã³ããããŒãšå€ã®ãã¢ã®ã¹ãã¢ã«ããŒãè¿œå ããããæ¢åã®ããŒã®å€ãæŽæ°ããããããšãetcdã¯ãã®æäœãæ°žç¶ã¹ãã¬ãŒãžã®éåžžã®ãã¡ã€ã«ã§ããWALã«èšé²ããŸãã ç¶è¡ããåã«ãetcdã¯WALãžã®æžã蟌ã¿ãå®éã«è¡ãããããšãå®å
šã«ç¢ºèªããå¿
èŠããããŸãã Linuxã§ã¯ãå®éã®ç©çã¹ãã¬ãŒãžãžã®æžã蟌ã¿ãé
延ããå¯èœæ§ããããããåäžã®æžã蟌ã¿ã·ã¹ãã ã³ãŒã«ã§ã¯ããã«ã¯äžååã§ãã ããšãã°ãLinuxã¯ã«ãŒãã«ã¡ã¢ãªå
ã®ãã£ãã·ã¥ïŒããŒãžãã£ãã·ã¥ãªã©ïŒã«WALã¬ã³ãŒããä¿åããå ŽåããããŸãã ãŸããããŒã¿ãæ°žç¶ã¹ãã¬ãŒãžã«æ£ç¢ºã«æžã蟌ãã«ã¯ãæžã蟌ã¿åŸã«fdatasyncã·ã¹ãã ã³ãŒã«ãå¿
èŠã§ããetcdã¯ããã䜿çšããã ãã§ãïŒ straceã®çµæãããããããã«ã8ã¯WALãã¡ã€ã«èšè¿°åã§ãïŒã
21:23:09.894875 lseek(8, 0, SEEK_CUR) = 12808 <0.000012> 21:23:09.894911 write(8, ".\0\0\0\0\0\0\202\10\2\20\361\223\255\266\6\32$\10\0\20\10\30\26\"\34\"\r\n\3fo"..., 2296) = 2296 <0.000130> 21:23:09.895041 fdatasync(8) = 0 <0.008314>
æ®å¿µãªãããæ°žç¶ã¹ãã¬ãŒãžãžã®æžã蟌ã¿ã¯ããã«å€±æããŸãã fdatasyncåŒã³åºããé
ãå Žåãetcdã·ã¹ãã ã®ããã©ãŒãã³ã¹ãäœäžããŸãã etcdã®ããã¥ã¡ã³ãã§ã¯ãfdatasyncåŒã³åºãã®99ããŒã»ã³ã¿ã€ã«ã§WALãã¡ã€ã«ã«æžã蟌ãã®ã«10ããªç§ãããããªãå Žåããªããžããªã¯ååã«é«éã§ãããšèŠãªãããŠããŸãã ã¹ãã¬ãŒãžã«ã¯ä»ã«ã䟿å©ãªã¡ããªãã¯ããããŸããããã®æçš¿ã§ã¯ãã®ã¡ããªãã¯ã«ã€ããŠã®ã¿èª¬æããŸãã
fioã§ã¹ãã¬ãŒãžãè©äŸ¡ãã
ãªããžããªãetcdã«é©ããŠãããã©ãããè©äŸ¡ããå¿
èŠãããå Žåã¯ãéåžžã«äººæ°ã®ããI / Oè² è·ãã¹ãããŒã«ã§ããfioã䜿çšããŸãã ãã£ã¹ã¯æäœã¯éåžžã«ç°ãªãå Žåãããããšã«æ³šæããŠãã ããïŒåæãšéåæãå€ãã®ã¯ã©ã¹ã®ã·ã¹ãã ã³ãŒã«ãªã©ããã®çµæãfioã®äœ¿çšã¯éåžžã«å°é£ã§ãã ããã«ã¯å€ãã®ãã©ã¡ãŒã¿ãŒãããããããã®å€ã®ç°ãªãçµã¿åããã«ããããŸã£ããç°ãªãI / Oã¯ãŒã¯ããŒããçæãããŸãã etcdã®é©åãªæ°å€ãååŸããã«ã¯ãfioããã®ãã¹ãèšé²ã®è² è·ããWALãã¡ã€ã«ãæžã蟌ããšãã®etcdããã®å®éã®è² è·ã«ã§ããã ãè¿ãããšã確èªããå¿
èŠããããŸãã
ãããã£ãŠãfioã¯å°ãªããšããã¡ã€ã«ãžã®äžé£ã®é 次æžã蟌ã¿æäœã®åœ¢åŒã§ããŒããäœæããå¿
èŠããããåã¬ã³ãŒãã¯æžã蟌ã¿ã·ã¹ãã ã³ãŒã«ãšããã«ç¶ãfdatasyncã·ã¹ãã ã³ãŒã«ã§æ§æãããŸãã é 次æžã蟌ã¿æäœã®å Žåãfioã«ã¯--rw =æžã蟌ã¿ãªãã·ã§ã³ãå¿
èŠã§ãã fioãèšé²æã«pwriteã§ã¯ãªãwriteã·ã¹ãã ã³ãŒã«ã䜿çšããã«ã¯ã-ioengine = syncãã©ã¡ãŒã¿ãŒãæå®ãã䟡å€ããããŸãã æåŸã«ãåã¬ã³ãŒãã®åŸã«ââfdatasyncãåŒã³åºãã«ã¯ã-fdatasync = 1ãã©ã¡ãŒã¿ãŒãè¿œå ããå¿
èŠããããŸãã ãã®äŸã®ä»ã®2ã€ã®ãªãã·ã§ã³ïŒ--sizeããã³--bsïŒã¯ã·ããªãªåºæã§ãã 次ã®ã»ã¯ã·ã§ã³ã§ã¯ããããã®èšå®æ¹æ³ã瀺ããŸãã
ãªãFIOã§ãããã©ã®ããã«èšå®ããããåŠãã æ¹æ³
ãã®æçš¿ã§ã¯ãå®éã®ã±ãŒã¹ã«ã€ããŠèª¬æããŸãã Probertheusã䜿çšããŠç£èŠããKubernetes v1.13ã¯ã©ã¹ã¿ãŒããããŸããã etcd v3.2.24ã¯SSDã§ãã¹ããããŠããŸããã Etcdã¡ããªãã¯ã¹ã¯ãã¯ã©ã¹ã¿ãŒãäœãå®è¡ããŠããªãå Žåã§ããfdatasyncã®åŸ
æ©æéãé·ãããããšã瀺ããŸããã ã¡ããªãã¯ã¯å¥åŠã§ãç§ãã¡ã¯ããããäœãæå³ããã®ãæ¬åœã«ç¥ããŸããã§ããã ã¯ã©ã¹ã¿ãŒã¯ä»®æ³ãã·ã³ã§æ§æãããŠãããããç©çSSDãŸãã¯ä»®æ³åã¬ã€ã€ãŒã®åé¡ãç解ããå¿
èŠããããŸããã ããã«ãããŒããŠã§ã¢ãšãœãããŠã§ã¢ã®æ§æãé »ç¹ã«å€æŽãããã®çµæãè©äŸ¡ããæ¹æ³ãå¿
èŠã§ããã åæ§æã§etcdãå®è¡ããPrometheusã¡ããªãã¯ã確èªã§ããŸãããããã¯é¢åã§ãã ç¹å®ã®æ§æãè©äŸ¡ããããã®ããªãç°¡åãªæ¹æ³ãæ¢ããŠããŸããã etcdã®Prometheusã¡ããªãã¯ãæ£ããç解ããŠãããã©ããã確èªãããã£ãã®ã§ãã
ãããããã®ããã«ã¯2ã€ã®åé¡ã解決ããå¿
èŠããããŸããã ãŸããWALãžã®æžã蟌ã¿æã«etcdãäœæããI / OããŒãã¯ã©ã®ããã«èŠããŸããïŒ ã©ã®ã·ã¹ãã ã³ãŒã«ã䜿çšãããŠããŸããïŒ ã¬ã³ãŒãã®ãµã€ãºã¯ïŒ 次ã«ããããã®è³ªåã«çããå Žåãfioã§åæ§ã®ã¯ãŒã¯ããŒããã©ã®ããã«åçŸããã°ããã§ããïŒ fioã¯å€ãã®ãªãã·ã§ã³ãåããéåžžã«æè»ãªããŒã«ã§ããããšãå¿ããªãã§ãã ããã lsofã³ãã³ããšstraceã³ãã³ãã䜿çšããŠã1ã€ã®ã¢ãããŒãã§äž¡æ¹ã®åé¡ã解決ããŸããã lsofã¯ãããã»ã¹ãšãã®é¢é£ãã¡ã€ã«ã§äœ¿çšããããã¹ãŠã®ãã¡ã€ã«èšè¿°åã衚瀺ããŸãã straceã䜿çšãããšããã§ã«å®è¡äžã®ããã»ã¹ã調æ»ããããããã»ã¹ãéå§ããŠèª¿æ»ãããã§ããŸãã straceã¯ã調æ»äžã®ããã»ã¹ïŒããã³ãã®åããã»ã¹ïŒããã®ãã¹ãŠã®ã·ã¹ãã ã³ãŒã«ã衚瀺ããŸãã etcdã¯åæ§ã®ã¢ãããŒãããšãã ããªã®ã§ãåŸè
ã¯éåžžã«éèŠã§ãã
ãŸããstraceã䜿çšããŠãã¯ã©ã¹ã¿ãŒã«è² è·ãããã£ãŠããªããšãã«Kubernetesã®etcdãµãŒããŒãåŠç¿ããŸããã ã»ãŒãã¹ãŠã®WALã¬ã³ãŒããã»ãŒåããµã€ãºïŒ2200ã2400ãã€ãïŒã§ããããšãããããŸããã ãããã£ãŠãæçš¿ã®æåã®ã³ãã³ãã§ããã©ã¡ãŒã¿ãŒ--bs = 2300ãæå®ããŸããïŒbsã¯åfioãšã³ããªã®ãµã€ãºããã€ãåäœã§æå³ããŸãïŒã etcdã¬ã³ãŒãã®ãµã€ãºã¯etcdã®ããŒãžã§ã³ãé
ä¿¡ããã©ã¡ãŒã¿ãŒå€ãªã©ã«äŸåããfdatasyncã®æéã«åœ±é¿ããããšã«æ³šæããŠãã ããã åæ§ã®ã·ããªãªãããå Žåã¯ãstraceã䜿çšããŠetcdããã»ã¹ã調ã¹ãæ£ç¢ºãªæ°ãèŠã€ããŠãã ããã
次ã«ãetcdãã¡ã€ã«ã·ã¹ãã ã®ã¢ã¯ã·ã§ã³ãç解ããããã«ãstraceãš-ffttTãªãã·ã§ã³ã䜿çšããŠéå§ããŸããã ãã®ãããåããã»ã¹ã調æ»ããããããã®åºåãåå¥ã®ãã¡ã€ã«ã«æžã蟌ã¿ãåã·ã¹ãã ã³ãŒã«ã®éå§ãšç¶ç¶æéã«é¢ãã詳现ãªã¬ããŒããååŸããããšããŸããã lsofã䜿çšããŠstraceåºåã®åæã確èªããã©ã®ãã¡ã€ã«èšè¿°åãã©ã®ç®çã«äœ¿çšããããã確èªããŸããã straceã䜿çšãããšãäžèšã®çµæãåŸãããŸããã åææéã®çµ±èšã«ãããetcdããã®ææ°wal_fsync_duration_secondsãWALãã¡ã€ã«èšè¿°åã䜿çšããfdatasyncåŒã³åºãã«å¯Ÿå¿ããŠããããšã確èªãããŸããã
fioãetcdãšåæ§ã®è² è·ãçæããããã«ãfioã®ããã¥ã¡ã³ãã調æ»ããã¹ã¯ãªããã®ãªãã·ã§ã³ãéžæããŸããã etcdãšåæ§ã«ãstraceããfioãå®è¡ããŠãã·ã¹ãã ã³ãŒã«ãšãã®ç¶ç¶æéããã§ãã¯ããŸããã
--sizeãã©ã¡ãŒã¿ãŒã®å€ãæ
éã«éžæããŸãããããã¯ãfioããã®I / Oè² è·å
šäœãè¡šããŸãã ç§ãã¡ã®å Žåãããã¯ã¹ãã¬ãŒãžã«æžã蟌ãŸãããã€ãã®ç·æ°ã§ãã æžã蟌ã¿ïŒããã³fdatasyncïŒã·ã¹ãã ã³ãŒã«ã®æ°ã«çŽæ¥æ¯äŸããããšãå€æããŸããã ç¹å®ã®bså€ã®å Žåãfdatasyncã®åŒã³åºãåæ°=ãµã€ãº/ bsã ããŒã»ã³ã¿ã€ã«ã«èå³ããã£ãã®ã§ãä¿¡é Œæ§ã®ããã«ååãªãµã³ãã«ãå¿
èŠã ã£ãã¯ãã§ããã10 ^ 4ã§ååã§ãããšèšç®ããŸããïŒ22ã¡ããã€ããåŸãããŸãïŒã --sizeãå°ããå Žåãå€ãå€ãçºçããå¯èœæ§ããããŸãïŒããšãã°ãããã€ãã®fdatasyncåŒã³åºããéåžžãããé·ãæ©èœãã99ããŒã»ã³ã¿ã€ã«ã«åœ±é¿ããŸãïŒã
èªåã§è©ŠããŠã¿ãŠãã ãã
fioã®äœ¿çšæ¹æ³ã瀺ããã¹ãã¬ãŒãžã®ããã©ãŒãã³ã¹ãååã§ãããã©ãããªã©ã確èªããŸããã IBM Cloudã® SSDã¹ãã¬ãŒãžãåããä»®æ³ãã·ã³ãªã©ã䜿çšããŠãå®éã«è©ŠããŠã¿ãŠãã ããã