ããŒãžã§ã³2.1以éã Apache Igniteã«ã¯Persistenceã®ç¬èªã®å®è£ ããããŸãã
ææ°ã®èšèšã§ãã®ã¡ã«ããºã ãæ§ç¯ããããã«ã¯ãSQLãµããŒããåããåæ£ãã§ãŒã«ã»ãŒããã©ã³ã¶ã¯ã·ã§ã³ã¹ãã¬ãŒãžã®æ§ç¯ã«äž»ã«è²»ããããæ°å人åã®å·¥æ°ãããããŸããã
ãã¹ãŠã¯ã以åã®ã¡ã«ããºã ã®åºæ¬çãªåé¡ããå§ãŸããŸãããããã«ãããIn-Memory Data Gridãå€éšã®æ°žç¶ã¹ãã¬ãŒãžïŒCassandraãPostgresãªã©ïŒãšçµ±åã§ããŸããã
ãã®ã¢ãããŒãã¯ç¹å®ã®å¶éã課ããŸãã-ããšãã°ãã¡ã¢ãªã«ãªãããŒã¿ã®äžã§SQLãŸãã¯åæ£ã³ã³ãã¥ãŒãã£ã³ã°ãå®è¡ããããšã¯äžå¯èœã§ãããããã®ãããªå€éšã¹ãã¬ãŒãžã§ã¯ãå€§å¹ ãªè¿œå ã®è€éåãªãã«ã³ãŒã«ãã§äœRTOïŒå埩æéç®æšïŒãéå§ããããšã¯ã§ããŸããã§ããã
Apache Ignite Persistenceã䜿çšããå Žåã¯ãApache Igniteã®éåžžã®æ©èœïŒ ACID ãåæ£ãã©ã³ã¶ã¯ã·ã§ã³ãåæ£SQL99 ãJava / .NET APIãŸãã¯JDBC / ODBCã€ã³ã¿ãŒãã§ãŒã¹ãä»ããã¢ã¯ã»ã¹ãåæ£ã³ã³ãã¥ãŒãã£ã³ã°ãªã©ïŒããã¹ãŠäœ¿çšããŸãã ããããä»ã§ã¯ã䜿çšãããã®ãã¡ã¢ãªäžãšã1ã€ã®ããŒãããæ°åããŒããŸã§ã®ã€ã³ã¹ããŒã«ã®ã¡ã¢ãªãæ¡åŒµãããã£ã¹ã¯äžã§åäœããŸãã
Apache Ignite Persistenceãã©ã®ããã«æ§ç¯ãããŠããããèŠãŠã¿ãŸãããã ä»æ¥ã¯ããã®åºç€-èä¹ æ§ã®ããã¡ã¢ãªãããã³æ¬¡ã®åºçç©-ãã£ã¹ã¯ã³ã³ããŒãã³ãèªäœã«ã€ããŠæ€èšããŸãã
çšèª
çšèªã«ã€ããŠèª¬æããŸãã Apache Igniteã¯ã©ã¹ã¿ãŒã®ãã£ãã·ã¥ã®ã³ã³ããã¹ãã§ã¯ãããã£ãã·ã¥ããšãããŒãã«ãã®æŠå¿µãåãæå³ã§äœ¿çšããŸãã å
éšã¡ã«ããºã ãåç
§ããŠããã£ãã·ã¥ããããé »ç¹ã«äœ¿çšãããããŒãã«ããSQLã«äœ¿çšããŸãã äžè¬ã«ãApache Igniteã®å€éšã§ã¯ããããã®æŠå¿µã®æå³ã¯ãããã«ç°ãªãå Žåãããããã®èšäºã®å€éšã§ã¯åžžã«åçãšã¯éããŸããã ãã®ãããæ°žç¶çãªãã£ãã·ã¥ãå©çšã§ããããšãèãããšãApache Igniteã¯ããã®åèªã®äžè¬ã«åãå
¥ããããŠããã»ãã³ãã£ã¯ã¹ã«åžžã«é©åãããšã¯éããŸããã Apache Igniteãã£ãã·ã¥ã«åºã¥ããããŒãã«ãã«é¢ããŠã¯ãSQLã䜿çšããŠã¢ã¯ã»ã¹ã§ããè€æ°ã®ãããŒãã«ããå®çŸ©ããããããŒãã«ããŸã£ããå®çŸ©ã§ããŸããïŒJava / .NET / C ++ APIããã³ãã®æŽŸçç©ãä»ããŠã®ã¿ã¢ã¯ã»ã¹ã§ããŸãïŒ ïŒ
èä¹ æ§ã®ããã¡ã¢ãª
補åãµããŒãã®ã³ã¹ããå€§å¹ ã«å¢å€§ããã倧éã®ã³ãŒããè€è£œããããšãªããã¡ã¢ãªãšãã£ã¹ã¯äžã«å¹æçãªæ··åã¹ãã¬ãŒãžãæ§ç¯ããã«ã¯ãã¡ã¢ãªã«ããŒã¿ãæ ŒçŽããã¢ãŒããã¯ãã£ãå€§å¹ ã«åèšèšããå¿ èŠããããŸããã
æ°žç¶æ§ã®ãããªæ°ããã¢ãŒããã¯ãã£- èä¹ æ§ã¡ã¢ãª -ã¯ãæšå¹Žæ«ãã倧èŠæš¡ãªGridGainã¯ã©ã€ã¢ã³ãã§å®è¡ãããŠãããApache Ignite 2.0ããå ¬éãããŸããã ããŒãžåœ¢åŒã®ãªãããŒãããŒã¿ã¹ãã¬ãŒãžãæäŸããŸãã
ããŒãž/ã¡ã¢ãª
åºæ¬çãªã¹ãã¬ãŒãžãŠãããã¯ãå®éã®ããŒã¿ãŸãã¯ã¡ã¿ããŒã¿ãå«ããããŒãžãã§ãã
å²ãåœãŠãããã¡ã¢ãªã䜿ãæãããããšãããŒã¿ããã£ã¹ã¯ã«ããã·ã¥ããããšãããã¯ããŒãžããšã«çºçããŸãã ãããã£ãŠãããŒãžãµã€ãºã倧ããããŠã¯ãªããŸããããããªããšãæŒãåºãå¹çãäœäžããŸãã倧ããªããŒãžã§ã¯ããããããŒã¿ããããããŒã¿ãšæ··åãããããŒãžãåžžã«ã¡ã¢ãªã«ãã«ã¢ãããããå¯èœæ§ãé«ãããã§ãã
ããããããŒãžãå°ãããªããšã1ããŒãžã«åãŸããªã倧éã®ã¬ã³ãŒããä¿åããåé¡ããã¡ã¢ãªã®æçåãšå²ãåœãŠã®åé¡ããããŸãïŒ1ã2ã¬ã³ãŒããå«ãå°ããªããŒãžããšã«ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ããã¡ã¢ãªãèŠæ±ããã«ã¯é«ãããŸãïŒã
æåã®åé¡-倧èŠæš¡ãªé²é³ã®å Žå-ã¯ããã®ãããªã¬ã³ãŒããããã€ãã®ããŒãžã«ãã¹ãã¢ãããæ©èœã«ãã£ãŠè§£æ±ºãããŸããåããŒãžã«ã¯ããã€ãã®ã»ã°ã¡ã³ãã®ã¿ãä¿åãããŸãã ãã®ã¢ãããŒãã®éã¯ãå®å šãªæ å ±ãååŸããããã«è€æ°ã®ããŒãžãã¯ããŒã«ããå¿ èŠãããããããã®ãããªã¬ã³ãŒããæäœãããšãã®ããã©ãŒãã³ã¹ãäœäžããããšã§ãã ãããã£ãŠããããé »ç¹ã«çºçããå Žåã¯ã
MemoryConfiguration.setPageSize(âŠ)
䜿çšããŠããã©ã«ãã®ããŒãžãµã€ãºïŒæåã¯2 KiBã1ã16 KiBã®ç¯å²ã§å€æŽå¯èœïŒãå¢ããããšãæ€èšããã®ã¯çã«ããªã£ãŠããŸãã
ã»ãšãã©ã®å ŽåãããŒãžãµã€ãºãSSDã®ããŒãžãµã€ãºãšç°ãªãå ŽåïŒã»ãšãã©ã®å Žå4 KiBïŒã«ããããŒãžãµã€ãºãåå®çŸ©ããããšã¯çã«ããªã£ãŠããŸãã ããããªããšãããã©ãŒãã³ã¹ã®äœäžãèŠãããå ŽåããããŸãã
ãã©ã°ã¡ã³ããŒã·ã§ã³ã«é¢ãã2çªç®ã®åé¡ã¯ããã©ãããã©ãŒã ã«çµã¿èŸŒãŸãããªã³ã©ã€ã³ããã©ã°ã«ãã£ãŠéšåçã«è§£æ±ºãããããŒã¿ããŒãžã«ã¯å°ããªãèç«æ§ã®æ®çç©ãã®ã¿ãæ®ããŸãã
3çªç®ã®åé¡-å€æ°ã®ããŒãžãå«ãããŒãžã«ã¡ã¢ãªãå²ãåœãŠãã³ã¹ããé«ã-ã¯ã次ã®ã¬ãã«ã®æœè±¡åãã»ã°ã¡ã³ããã«ãã£ãŠè§£æ±ºãããŸãã
ã¡ã¢ãªã»ã°ã¡ã³ã
ã»ã°ã¡ã³ãã¯ãå²ãåœãŠãããã¡ã¢ãªã®ã¢ãããã¯åäœã§ããé£ç¶ããã¡ã¢ãªãããã¯ã§ãã å²ãåœãŠãããã¡ã¢ãªãçµäºãã䜿çšã®å¶éã«ãŸã éããŠããªãå ŽåãOSã¯è¿œå ã®ã»ã°ã¡ã³ããèŠæ±ããããã¯ããã«å éšã®ããŒãžã«åå²ãããŸãã
çŸåšã®å®è£ ã§ã¯ãå°ãªããšã256 MiBã®ã»ã°ã¡ã³ãããªã¥ãŒã ãæã€1ã€ã®é åã«æ倧16åã®ã¡ã¢ãªã»ã°ã¡ã³ããå²ãåœãŠãããšãèšç»ãããŠããŸãã ã»ã°ã¡ã³ãã®å®éã®ããªã¥ãŒã ã¯ãæ倧蚱容ã¡ã¢ãªãšæåã«å²ãåœãŠãããã¡ã¢ãªã®å·®ã15ã§å²ã£ããã®ãšããŠå®çŸ©ãããŸãïŒ16çªç®ã®ã»ã°ã¡ã³ãã¯æåã«å²ãåœãŠãããã¡ã¢ãªã§ãïŒã ããšãã°ãäžéãããŒãããã512 GiBã§ã16 GiBãæåã«å²ãåœãŠãããå Žåãå²ãåœãŠãããã»ã°ã¡ã³ãã®ãµã€ãºã¯ïŒ512-16ïŒ/ 15â33 GiBã«ãªããŸãã
ã»ã°ã¡ã³ãã«ã€ããŠè©±ããšãã¯ãã¡ã¢ãªæ¶è²»ã®å¶éã«ã€ããŠèšåãããããããŸããã ãããã®å®è£ ããã詳现ã«æ€èšããŠã¿ãŸãããã
ããŒã¿ã«ãã£ãŠã¹ãã¬ãŒãžèŠä»¶ãç°ãªãå Žåããããããé¢é£ãããã¹ãŠã®ãã©ã¡ãŒã¿ãŒïŒæ倧ããªã¥ãŒã ãšåæããªã¥ãŒã ãå€äœãªã©ïŒã®ã°ããŒãã«èšå®ãè¡ãããšã¯æé©ã§ã¯ãããŸããã 1ã€ã®äŸã¯ããªã³ã©ã€ã³ããã³ã¢ãŒã«ã€ãããŒã¿ã¹ãã¬ãŒãžã§ãã æšå¹Žã®æ³šæã¯ããããããŒã¿ãããå¯èœæ§ããããããã»ãšãã©ã®éšåãã¡ã¢ãªå ã«ãããªã³ã©ã€ã³ã¹ãã¬ãŒãžã«ä¿åãããå ŽåããããŸãããåæã«ãäžæçã§ãã£ãŠããå€ã泚æå±¥æŽãšéå»ã®å éšãã©ã³ã¶ã¯ã·ã§ã³ãä¿åãããå ŽåããããŸã貎éãªæãåºã
åãã£ãã·ã¥ã®ã¬ãã«ãå¶éããããšã¯å¯èœã§ãããæ°çŸãŸãã¯æ°åã®ããŒãã«ãå€æ°ããå Žåãããããããã€ãã®ã¡ã¢ãªãã³ãå²ãåœãŠããããªãŒããŒãããã³ã°ãå®è¡ããŠãããã«ã¡ã¢ãªäžè¶³ãšã©ãŒãååŸããå¿ èŠããããŸãã
ããŒãã«ã®ã°ã«ãŒãã®å¶éãå®çŸ©ã§ããæ··åã¢ãããŒããéžæããã次ã®ã¬ãã«ã®æœè±¡åãå¯èœã«ãªããŸããã
ã¡ã¢ãªã®é å/é å
Durable Memoryã¹ãã¬ãŒãžã¢ãŒããã¯ãã£ã®æäžäœã¬ãã«ã¯ãè«çãšã³ãã£ãã£ãã¡ã¢ãªé åãã§ããããã¯ãèšå®ãå¶éãªã©ã§åäžã®ã¹ãã¬ãŒãžé åãå ±æããããŒãã«ãã°ã«ãŒãåããŸãã
ããšãã°ãä¿¡é Œæ§ã®ããã®éèŠãªããŒã¿ãåããååã®ãã£ãã·ã¥ãšãã¢ã¯ãã£ãã§ã¯ãããæ倱ã«å¯ŸããŠããã»ã©éèŠã§ã¯ãªãå€ãã®æŽŸççãªéçŽãã£ãã·ã¥ãæã€ã¢ããªã±ãŒã·ã§ã³ã®ãã£ãã·ã¥ãããå Žåã2ã€ã®ã¡ã¢ãªé åãå®çŸ©ã§ããŸãïŒ1ã€ç®ã¯ã384 GiBã®æ¶è²»å¶éãšå³æ Œãªäžè²«æ§ã®ä¿èšŒãååã®ãã£ãã·ã¥ã®ãã€ã³ããããã³64 GiBã®å¶éãšåŒ±ããããä¿èšŒã®2çªç®ã®ãã£ãã·ã¥ã«ããããã®64 GiBã®ã¡ã¢ãªãå ±æãããã¹ãŠã®äžæãã£ãã·ã¥ããã€ã³ãããŸãã
ã¡ã¢ãªé åã¯å¶éã課ããã¹ãã¬ãŒãžèšå®ã決å®ããã¹ãã¬ãŒãžã«å²ãåœãŠãããã°ã«ãŒãã¹ããŒã¹ã«é¢ããŠãã£ãã·ã¥ãã°ã«ãŒãåããŸãã
ããŒãžã®çš®é¡ãšããŒã¿ã®ååŸ
ã¡ã¢ãªããŒãžã¯ããã€ãã®ã¿ã€ãã«åãããããã®ããŒã¯ããŒã¿ããŒãžãšã€ã³ããã¯ã¹ ããŒãžã§ãã
ããŒã¿ããŒãžã¯ããŒã¿ãçŽæ¥ä¿åããŸã;ãããã¯ãã§ã«äžã§åºãè°è«ãããŠããŸãã ã¬ã³ãŒãã1ããŒãžã«åãŸããªãå Žåãè€æ°ã®ã¬ã³ãŒãã«åæ£ãããŸãããããã¯ç¡æã®æäœã§ã¯ãããŸããã ãŸããã¢ããªã±ãŒã·ã§ã³ã·ããªãªã«å€§ããªã¬ã³ãŒããå€æ°ããå Žåã¯ã
MemoryConfiguration.setPageSize(âŠ)
ã
MemoryConfiguration.setPageSize(âŠ)
ãŠããŒãžãµã€ãºãå¢ããããšã¯çã«ããªã£ãŠããŸãã ããŒã¿ã¯ããŒãžããšã«ãã£ã¹ã¯ã«ããã·ã¥ãããŸããããŒãžã¯å®å šã«RAMã«ããããå®å šã«ãã£ã¹ã¯ã«ãããŸãã
ã€ã³ããã¯ã¹ããŒãžã¯B +ããªãŒãšããŠä¿åãããåããªãŒã¯è€æ°ã®ããŒãžã«åæ£ã§ããŸãã ã€ã³ããã¯ã¹ããŒãžã¯ãããŒã¿ãæ€çŽ¢ãããšãã«æ倧ã®ãªã³ã©ã€ã³ã¢ã¯ã»ã¹ã®ããã«åžžã«ã¡ã¢ãªå ã«ãããŸãã
ãã®ãããªã¹ããŒã ã§ã¯ãããŒããšã«ããŒã¿ãååŸããããã«ã次ã®ããã»ã¹ãå®è¡ããŸãã
-
cache.get(keyA);
ã¡ãœãããã¯ã©ã€ã¢ã³ãã§åŒã³åºãããŸãcache.get(keyA);
- ã¯ã©ã€ã¢ã³ãã¯ãçµã¿èŸŒã¿ã®ã¢ãã£ããã£æ©èœã䜿çšããŠãã®ããŒãæ åœãããµãŒããŒããŒãã決å®ãããããã¯ãŒã¯çµç±ã§ãã®ãµãŒããŒããŒãã«èŠæ±ãå§ä»»ããŸãã
- ãµãŒããŒããŒãã¯ããªã¯ãšã¹ããè¡ãããããŒã«ãã£ãŠãã£ãã·ã¥ãæ åœããã¡ã¢ãªé åã決å®ããŸã;
- 察å¿ããé åã§ã¯ããã®ãã£ãã·ã¥ã®äž»ããŒã䜿çšããŠB +ããªãŒãžã®ãšã³ããªãã€ã³ããå«ãã¡ã¿æ å ±ããŒãžã«ã¢ã¯ã»ã¹ããŠããŸãã
- ç¹å®ã®ããŒã®ç®çã®ã€ã³ããã¯ã¹ããŒãžãæ€çŽ¢ããŸãã
- ã€ã³ããã¯ã¹ããŒãžã¯å®éã«ããŒãæ€çŽ¢ããããŒãå«ãããŒã¿ããŒãžãšããã®ããŒãžã®ãªãã»ããã決å®ããŸãã
- ããŒã¿ããŒãžã«ã¢ã¯ã»ã¹ããŠãããããŒããå€ãèªã¿åãããŸãã
SQL
H2ã䜿çšããSQLã¯ãšãªã¯ã2段éã®å®è¡èšç»ïŒäžè¬çãªå ŽåïŒãçæããŸããããã¯ãåºæ¬çã«MapReduceã®ãããªã¢ãããŒãã«èŠçŽãããŸãã èšç»ã®æåã®æ®µéã¯ãããŒãã«ãæ åœãããã¹ãŠã®ããŒãã«ãæµåºãããŸããããã§ãããŒãã«ãæ åœããã¡ã¢ãªé åã®æ±ºå®ãåæ§ã«å®è¡ãããŸãã ããã«ãéžæãã€ã³ããã¯ã¹ã«ãããã®ã§ããå Žåãç®çã®ã€ã³ããã¯ã¹ããŒãžãæ€çŽ¢ãããéžæãããå€ã®å Žæã決å®ããããããã«å¯ŸããŠå埩ãå®è¡ãããŸãã ãã«ã¹ãã£ã³ã®å Žåããã©ã€ããªã€ã³ããã¯ã¹ã§å®å šãªå埩ãè¡ãããããã«å¿ããŠãã¹ãŠã®ããŒãžã«ã¢ã¯ã»ã¹ããŸãã
æ··é
ããŒãžã§ã³2.0以éãæŒãåºãã¯ããŒãžããšã«æ©èœããã¡ã¢ãªããããŒãžãåé€ãããŸãã æ°žç¶æ§ãèšå®ãããŠããå ŽåãããŒãžã®ã³ããŒãšã€ã³ããã¯ã¹ã®ãšã³ããªã¯å€æŽãããã«æ®ããåŸã§ããŒã«ã«ãã£ã¹ã¯ããå¿ èŠãªæ å ±ãååŸã§ããããã«ãªããŸãã æ°žç¶æ§ãæ瀺çã«ãªãã«ãªã£ãŠããå ŽåããŸãã¯æ§æãããŠããªãå Žåãã¯ã©ãŠãã¢ãŠãã¯ã¯ã©ã¹ã¿ãŒãã察å¿ããããŒã¿ãå®å šã«åé€ããŸãã
ããŒãžããŒã·ã§ã³ã¯ãããŒãšå€ã®ãã¢ãç°¡åã«æäœããããšãäžå¯èœã«ããŸãããæ°žç¶æ§ãã¯ããã«åªããŠãããååãªããŒãžãµã€ãºã§è¯å¥œãªçµæãåŸãããŸãã
ããŒãžã§ã³2.1 ã§ã¯ã3ã€ã®æŒãåºãã¢ãŒãããµããŒããããŠããŸãã
- ç¡å¹-æ··éã¯çºçãããååãªã¡ã¢ãªããªãå Žåã¯ãšã©ãŒãã¹ããŒãããŸãã
- ã©ã³ãã lru-ã«ãŒãã§ã®æŒãåºãäžã«ãã©ã³ãã ãª5ããŒãžã®ããŒã¿ãéžæãããåŸã1ã€ãåé€ãããŸãïŒã¢ã¯ã»ã¹ã¿ã€ã ã¹ã¿ã³ããæãé·ãïŒã¢ã¯ã»ã¹ãæãé·ãïŒïŒã 5ã€ã®ã©ã³ãã ããŒãžãéžæããã¢ãããŒããéžæãããã®ã¯ãã¢ã¯ã»ã¹ã¿ã€ã ããŒã¯ã®å®å šãªé åºä»ãã®é«æ§èœå®è£ ã®è€éãã®ããã§ãã
- random 2 lru-åã®ããŒãžã§ã³ã«äŒŒãŠããŸãããåããŒãžã«ã¯2ã€ã®ã¢ã¯ã»ã¹ã¿ã€ã ã¹ã¿ã³ãïŒæåŸãšæåŸãã2ã€ïŒãããããããã®æå°ã®ãã®ãéžæã«äœ¿çšãããŸãã ãã®ã¢ãããŒãã«ãããããšãã°ãããŒã¿é åã®å€§éšåã«å¯ŸãããŸããªãã«ã¹ãã£ã³ãŸãã¯ãŸããªã¯ãšãªãªã©ã®ç¶æ³ãããå¹æçã«åŠçã§ããŸãã
DataPageEvictionMode
/** * Defines memory page eviction algorithm. A mode is set for a specific * {@link MemoryPolicyConfiguration}. Only data pages, that store key-value entries, are eligible for eviction. The * other types of pages, like index or meta pages, are not evictable. */ public enum DataPageEvictionMode { /** Eviction is disabled. */ DISABLED, /** * Random-LRU algorithm. * <ul> * <li>Once a memory region defined by a memory policy is configured, an off-heap array is allocated to track * last usage timestamp for every individual data page. The size of the array is calculated this way - size = * ({@link MemoryPolicyConfiguration#getMaxSize()} / {@link MemoryConfiguration#pageSize})</li> * <li>When a data page is accessed, its timestamp gets updated in the tracking array. The page index in the * tracking array is calculated this way - index = (pageAddress / {@link MemoryPolicyConfiguration#getMaxSize()}</li> * <li>When it's required to evict some pages, the algorithm randomly chooses 5 indexes from the tracking array and * evicts a page with the latest timestamp. If some of the indexes point to non-data pages (index or system pages) * then the algorithm picks other pages.</li> * </ul> */ RANDOM_LRU, /** * Random-2-LRU algorithm: scan-resistant version of Random-LRU. * <p> * This algorithm differs from Random-LRU only in a way that two latest access timestamps are stored for every * data page. At the eviction time, a minimum between two latest timestamps is taken for further comparison with * minimums of other pages that might be evicted. LRU-2 outperforms LRU by resolving "one-hit wonder" problem - * if a data page is accessed rarely, but accidentally accessed once, it's protected from eviction for a long time. */ RANDOM_2_LRU; // ... }
* * *
次ã®åºçç©ã§ã¯ãDurable Memoryããã£ã¹ã¯ã¹ãã¬ãŒãžã®å®è£ ïŒ WAL +ãã§ãã¯ãã€ã³ãïŒã«ã©ã®ããã«äŸåããŠãããã詳ãã調ã¹ãç¬èªã®GridGainæ¡åŒµæ©èœãæäŸããã¹ãããã·ã§ãããäœæããå¯èœæ§ã«ã€ããŠã詳ãã説æããŸãã