ã¨ã³ã¸ãã¢ãªã詳細ãæ°ã«ãªããã®ãã¨ããããã§ãå人ããã°ã®ã»ã㧠yrmcds 1.0.0 ãªãªã¼ã¹è¨äºã®æè¡çãªè£è¶³ããã¦ããã¾ãã
keepalived 使ãã®ãsplit brain ã«ãªãããããªãã®ï¼
ãã¦ã¯ããã®æ¹ã§ãããå°ãã¾ããªãããããçªã£è¾¼ã¿ã¯ï¼
æ°ã«ãªã人㯠split brain èµ·ãããªã heartbeat ããå©ç¨ãã ããã ç¨é次第ã§ã¾ãã©ãã§ããã£ããªã¼ã¨ãã人㯠keepalived ã®æ¹ãæ軽ãã¨æãã¾ãã
ãµã¼ãã¼ãµã¤ãããã¯ã¨ã¬ããªã±ã¼ã·ã§ã³
ããã¯ç¶æ ã¯ã¬ããªã±ã¼ã·ã§ã³ããã¾ãããéåæã¬ããªã±ã¼ã·ã§ã³ãªã®ã§ãã¦ãç¡é§ã¨ãããã ããã¨ããã¯ããå¾ããã§ã¤ã«ãªã¼ãã¼ããã¨ãªãã¸ã§ã¯ããããã¯ãããªãç¶æ ã«ãªãããã§ããå±éºã§ãã
対çã¨ãã¦å°å
¥ããã®ãããã¤ããªãããã³ã«ã® RaU (Replace and Unlock) ã§ãã
ãã®ã³ãã³ãã¯ããã¯ãã¦ããªããã°å¤±æããã®ã§ãééã£ã¦æ´æ°ããã£ã¦ãã¨ãé²æ¢ã§ãããã§ãããLaG (Lock and Get)ã¯å¿
é ã§ã¯ãªãã®ã§ãããRaU
ã¯å¿
é ãªã®ã§ãã
ããã¹ããããã³ã«ã«ã¯ RaU ã LaG ãåå¨ããªãã§ããææãã¾ããããã¤ããªãããã³ã«ä¸æ³ï¼
slab ãªãã§ã©ããã¦ãã®ï¼
tcmalloc ã«ã¡ã¢ãªç®¡çã¯ä¸¸æãã§ãã ãã㧠memcached ã¨äºè§ä»¥ä¸ã®é度ãã§ãããã§ããããèªåã¡ã¢ãªç®¡çãªãã¦ãããªãã£ããã ï¼ã¨æãã
ãã¥ã¼ãã³ã°ã¯ä½ãããã®ï¼
ãªã¢ã¯ã¿ã¼ã¹ã¬ãããããã«ããã¯ã«ãªã£ã¦ããã®ã§ããã®ä»äºãæ¸ããã¾ããã ä»ã epoll ã®éç¥ãã¯ã¼ã«ã¼ã¹ã¬ããã«ãã㨠lock-free ã§æãã¦ããã ãã§ããããªã¢ã¯ã¿ã¼ãããã«ããã¯ãªã®ã¯å¤ãã£ã¦ã¾ããã
ã¤ã¾ãããã以ä¸éããããªãè¤æ°ãªã¢ã¯ã¿ã¼ãªå®è£ ãå¿ è¦ã§ãã æ¥åä¸ã®å¿ è¦æ§ããªãã®ã§ããäºå®ã¯ããã¾ãããããã£ã¦ã¿ãã人ãããã°æè¿ãã¾ãã
éãã®å·¥å¤«ã«ã¤ãã¦ã¯å¥é誰å¾ãªè¨äºãæ¸ãã¤ããã§ãã
ãªãã§ã¯ã©ã¤ã¢ã³ãã©ã¤ãã©ãªãä½ã£ãã®ï¼
libmemcached ãæ¹é ãããã¨æã£ããã©ãã½ã¼ã¹ãèªã¿ã«ããã®ã§ããã¾ãããã¦ã¸ãºã(ã»Ï<)
æ¬é³ã§ããã¨ã³ã³ã·ã¹ãã³ãããã·ã³ã°ã¨ããããããçãããã³ã«ãªã©ã¤ãã©ãªã欲ããã£ããã§ãããUNIXæµã好ã¿ãªã®ã§ãã好ã¿ã«åãã°ã©ããã使ããã ããã
ä»å±ã® yc
ã³ãã³ãã yrmcds/memcached ã®å
¨æ©è½ã«ã¢ã¯ã»ã¹ã§ããã®ã§ä¾¿å©ã§ããã
SipHash ã©ããï¼
å ã¯éãã§ç¥ããã MurmurHash3 使ã£ã¦ããã®ã§ãæ§è½ãå¿é ã§ããã
ç½®ãæãã¦ãã³ããã¼ã¯ã¨ã£ãã¨ããã誤差ã¬ãã«ã§ã¯ããã¾ããè¥å¹²æ§è½åä¸ããã®ã§ã³ã£ããã§ãã éãã¦ã»ãã¥ã¢ãªãã¦ç´ æ´ããããSipHash ä¸æ³ï¼
å®è£ 㯠csiphash ãã¡ãã£ã´ãå¤æ´ãããã®ã使ã£ã¦ãã¾ãã
ã½ã¼ã¹ã³ã¼ã綺éº
åããã«ãææã¨ãã¦ã® yrmcdsãã¨ãæ¸ãã¦ã¾ãããã0.9.0 ã®æç¹ã§ã¯ã¯ã¼ã«ã¼ã¹ã¬ããã« memcached ã®å®è£
ãã¹ã£ãããã¦ãããããªã¢ã¯ã¿ã¼ãä¸éå端ã«æ¸ãè¾¼ã¿ãæ½è±¡åãã¦ããããã¦ãè¦è¦ããç¹ãããã¾ããããã¨ããã·ã¥å®è£
ã std::vector
ã使ã£ãææãã ã£ããã
1.0.0 ã¾ã§ã«ãããããè¦è¦ããã綺éºãã£ã±ãæ´çãã¾ãããã¯ã¼ã«ã¼ã®å®è£ ãããªã¢ã¯ã¿ã¼ããèªã¿ãããæ±ç¨æ§ãé«ããã®ã«ãªã£ã¦ã¾ããLock-free 㪠job dispatch ãã§ããæ±ç¨ã¯ã¼ã«ã¼ã¹ã¬ããå®è£ ã¯ç¹ã«æ°ã«å ¥ã£ã¦ãã®ã§ããã²ã覧ãã ããã
https://github.com/cybozu/yrmcds/blob/master/cybozu/worker.hpp
cybozu/ 以ä¸ã¯æ±ç¨ã©ã¤ãã©ãªã«ãªã£ã¦ããã®ã§ãããã C++11 ã®ãããã¯ã¼ã¯ã©ã¤ãã©ãªã¨ãã¦ç¬ç«ããã¦ãããããã§ãã
以ä¸ã§ããä¹±æ失礼ãã¾ããã