Transcript
Page 1: 인메모리 클러스터링 아키텍처

인메모리 클러스터 아키텍처

JBoss 인피니스팬으로 살펴보는

인메모리 데이터그리드 아키텍처

전 재 홍

Dec 2013

Page 2: 인메모리 클러스터링 아키텍처

Agenda

In-Memory Data Grid

Infinispan

Case Study

References

Page 3: 인메모리 클러스터링 아키텍처

In-Memory Data Grid

Page 4: 인메모리 클러스터링 아키텍처

Distributed Cache

Fast access to data

Performance Boost

Eviction, Expiration

Scalability

High Availability

Page 5: 인메모리 클러스터링 아키텍처

Distributed Cache

Persistence (Database)

Distributed Cache Cluster

Node

Node

Node

App

App

App

Page 6: 인메모리 클러스터링 아키텍처

In-Memory Data Grid

Evolution of distributed caches

Clustered by nature

Scalability (with cost) – Horizontal scalability

– Design for elasticity

High Availability – No Single Point of Failure

– Redundancy + Load Balance

Querying

Task Execution (Map/Reduce)

Page 7: 인메모리 클러스터링 아키텍처

In-Memory Data Grid

Persistence (Database)

In-Memory Data Grid

Node

Node

Node

App

App

App

Page 8: 인메모리 클러스터링 아키텍처

For What

Sharing data (session, app state)

Toolkit for clustering

Performance (caching, in-memory processing)

Scalability

Database on cloud

Page 9: 인메모리 클러스터링 아키텍처

Products

Oracle Coherence

GridGain

HazelCast

IBM eXtreme Scale

GigaSpaces

VmWare GemFire

Terracotta

ScaleOut StateServer

JBoss Infinispan

Page 10: 인메모리 클러스터링 아키텍처

Cache vs. Data Grid

JSR 107 - Temporary Caching for the Java Platform – Basic interaction(read, write, expiry)

– Transactions with JTA compatibility

– Listener

– Persistence: write-through, write-behind

– Annotations

JSR 347 - Data Grids for the Java Platform – Asynchronous, non-blocking API

– Distributed code execution and map/reduce API

– Group API for co-location

– Annotations (CDI)

– Eventually Consistent API

– Querying

– Configuration

– javax.datagrid.*

Page 11: 인메모리 클러스터링 아키텍처

Infinispan

Page 12: 인메모리 클러스터링 아키텍처

Infinispan

Distributed In-memory key/value Data Grid/ Cache

org.infinispan.Cache Interface

Distributed as Library and Server (from 5.3)

High availability

Elasticity

Manageable – RHQ, JON

Open source – Apache v2 License

DefaultCacheManager manager = new DefaultCacheManager(); // Cache<Integer, Ticket> cache = manager.getCache(); Cache<Integer, Ticket> cache = manager.getCache(“myCache”);

Page 13: 인메모리 클러스터링 아키텍처

Architecture: Library

JCP-107 Style Cache just cache with advantages: expiry, j2ee transaction

Infinispan as Library - Standalone

Infinispan

JVM

App

Page 14: 인메모리 클러스터링 아키텍처

Architecture: (Clustered) Library

Infinispan as Library - Clustered

Cluster

Infinispan

JVM

App

Infinispan

JVM

App

Infinispan

JVM

App

Application doesn’t know it’s on cluster

Use as library – Easy deployment

– More features

– Richer APIs

– Programmatic/ Declarative configuration

– Extendable/ embeddable

– Faster (API call)

Page 15: 인메모리 클러스터링 아키텍처

Architecture: Server

Use as server – Protocols: Memc

ached, REST, Hot Rod, WebSocket

Good Isolation – App doesn’t

affect cluster

Data tier shared by multi-apps – Non-java client:

C++, .NET, Ruby, Python, Java

Infinispan as Server - Clustered

Cluster

Infinispan

JVM

Infinispan

JVM

Infinispan

JVM

App

App

App

Remote or embedded? – amount of data, etcs

Page 16: 인메모리 클러스터링 아키텍처

Architecture: Durability

Durability – By replication

– By persistence

– By replication to other cluster (topology aware)

An Example of Durability

Cluster

Infinispan

JVM

Infinispan

JVM

Cluster

Infinispan

JVM

Infinispan

JVM

persistence

Page 17: 인메모리 클러스터링 아키텍처

Cluster Mode: Replication(복제)

Replication Mode

Cache on Server 1 K,V

Cache on Server 2 K,V

Cache on Server 4 K,V

Cache on Server 3 K,V

cache.put(K,V)

Page 18: 인메모리 클러스터링 아키텍처

Cluster Mode: Distribution(분산)

Distribution Mode(numOwners=2)

Cache on Server 1 K,V

Cache on Server 2 K,V

Cache on Server 4

Cache on Server 3

cache.put(K,V)

cache.get(K,V)

Page 19: 인메모리 클러스터링 아키텍처

Cluster Mode: Invalidation(무효화)

Invalidation Mode

Cache on Server 1 K,V2

Cache on Server 2 K,V

Cache on Server 4

Cache on Server 3

cache.put(K,V2)

DB

Page 20: 인메모리 클러스터링 아키텍처

Key Features: Persistence

Used for durability

Cache Store - Persistence Storage – File System, Cloud, Remote, JDBC, JPA, LevelDB, Cassandra,

– HBase, MongoDB, BerkeleyDB, JDBM, REST

CacheLoader, CacheStore(CacheWriter from 6.0)

Read-through, Write-through, write-behind

Store chain

Shared store

Page 21: 인메모리 클러스터링 아키텍처

Key Features: Transactions

JTA Transaction Support

Support MVCC (Multi-Versioned Concurrency Control)

Isolation Level – READ_COMMITTED (default)

– REPEATABLE_READ

Locking Mode – Optimistic Lock (default)

– Pessimistic Lock

Locking – Lock timeout

– Lock striping

Page 22: 인메모리 클러스터링 아키텍처

Key Features: Query

JBoss Hibernate Search + Apache Lucene

Query on values

Index Directory – Lucene Directory: in-memory, file system, JDBC

– Infinispan Directory

Distributed queries

Page 23: 인메모리 클러스터링 아키텍처

Distributed Execution

Executes codes on distributed nodes

Through a standard JDK ExecutorService interface

Use DistributedCallable extends java.util.concurrent.Callable

Page 24: 인메모리 클러스터링 아키텍처

Key Features: Map/Reduce

Based on Distributed Execution Framework

Mapper, Reducer, Collator, MapReduceTask

public interface Callator<KOut, VOut, R> { R collate(Map<KOut, VOut>); }

public interface Mapper<KIn, VIn, KOut, VOut> extends Serializable { void map(KIn key, VIn value, Collector<KOut, VOut> collector); }

public interface Reducer<KOut, VOut> extends Serializable { VOut reduce(KOut reducedKey, Iterator<VOut> iter); }

Page 25: 인메모리 클러스터링 아키텍처

Common Features

Listeners

Hibernate L2 Cache

Near/Local Cache

Serialization

Page 26: 인메모리 클러스터링 아키텍처

JDG

Red Hat JBoss Data Grid

Infinispan-based

JON

All the benefits of subscription, including Red Hat world class support and services

Page 27: 인메모리 클러스터링 아키텍처

Case Study

Page 28: 인메모리 클러스터링 아키텍처

Case Study: Session Clustering

Store session information into cache

in Spring MVC Interceptor

Page 29: 인메모리 클러스터링 아키텍처

Case Study: Session Clustering

- SecurityContextRepository를 구현한

CacheSecurityContextRepository 작성 - loadContext, saveContext를 오버라이드하여

인피니스팬 사용 - Spring cache abstraction 사용

Store session information into cache in Spring Security Filter

Page 30: 인메모리 클러스터링 아키텍처

Use Cases: Storm Processing State Store

Infinispan Data Grid

Page 31: 인메모리 클러스터링 아키텍처

Use Cases: Data Grid Platform

In-Memory 대용량 데이터 처리를 위한 아키텍쳐 구조 제시 및 적용 사례, 제 6회 한국 소프트웨어 아키텍트 대회 최우수상, 2013

Page 32: 인메모리 클러스터링 아키텍처

References

github.com/datagrids/spec/wiki

groups.google.com/group/jsr347

groups.google.com/group/jsr107

www.sap.com/inmemory

red.ht/data-grid

architects.dzone.com/articles/memory-data-grids-explained

www.gridgain.com/blog/fyi/cache-data-grid-database/

infinispan.org

infinispan-ko.blogspot.com

Page 33: 인메모리 클러스터링 아키텍처

http://www.slideshare.net/jaehongc

Thank you!


Top Related