2018.03.26 Mon.
Apache GEODE Meetup #4
#geode_jp
自己紹介
山河 征紀
ウルシステムズ株式会社
マネージングコンサルタント
{
“分野”:”金融系”
“得技”:[“分散処理”,
“インメモリー処理”]
“趣味”:”マラソン”
}
1
一応、Apache GeodeのContributorです
ただし、サンデープログラマー
本日お話すること
2
イベントの全体感
セッション内容
イベント概要
Part 1
SpringOne Platform 2017
4
Springとそのエコシステムをフィーチャーしたイベント
2016年よりSpringOne Platformとしてリブランド
SpringOne Platform 2017
• MOSCONE WEST@SFO
• JavaOne 2017と同じ会場
• 2017/12/4(月)~12/7(木)
• 日、月でトレーニングとPreEvent
• 月曜の夜が前夜祭
• 規模感
5
Moscone写真
Agenda
6
イベント本編
How to spend a day
7
How to spend a day
8
How to spend a day
9
セッション
Part 2
Sessions
11
Agile, PM,
Methodology, 9
Cloud-Native
Platform, 22
Core Spring,
12
Data,
Databases, 16
DevOps, CI, CD, 20
Geode, 12
Microservices,
Serverless, 16
Reactive, Event
Driven, 17
Transformation,
Case Studies, 26
Web,
JavaScript, 11
全体を通して12のApache Geodeセッション!
1. Apache Geode: How Pymma Uses it as an Efficient Alternative to Kafka-Storm-Spark
2. Apache Geode Test Automation and Continuous Integration & Deployment (CI-CD)
3. Caching for Microservices - Introduction to Pivotal Cloud Cache
4. Cloud-Native Data: What is it? Will it Solve the Data-DevOps Divide?
5. Enable SQL/JDBC Access to Apache Geode/GemFire Using Apache Calcite
6. Exploring Data-Driven, Cognitive Capabilities in Pivotal Cloud Foundry
7. High Performance Cloud Native APIs Using Apache Geode
8. RDBMS and Apache Geode Data Movement: Low Latency ETL Pipeline By Using Cloud-
Native Event Driven Microservices
9. Real-Time Analytics for Data-Driven Applications
10. Scaling Spring Boot Applications in Real-Time
11. Simplifying Apache Geode with Spring Data
12. Spring Driven Industrial IoT Utilizing Edge, Fog, and Cloud Computing 12
セッション
- Apache Geode: How Pymma Uses it
as an Efficient Alternative to Kafka-Storm-Spark -
Part 2
KafkaやSparkを使用したストリーム処理
14
• ストリームデータを処理して永続化したい
Spout
Persistence
Bolt
BPEL
complete
BPEL
start
Compute
duration
Average
per sec
Average
per min
Average
per hour
Average
per day
Too complex
Need more simpler solution
Topology
ストリームデータ
ソース 処理 処理 処理 処理 処理
• 強力なイベント処理とスケーラビリティ
に優れるが、インストールが複雑で多く
のスキルが必要
• もっとシンプルなソリューションが欲しい
Kafka+Storm/SparkをGeodeのみで
シンプルなアーキテクチャーにした
• Geodeは1つのプロダクトでストリーム処理と永続化が実現出来る
• AsyncEventQueueで非同期イベントを処理しリージョンへ永続化する
15
Asynchronous event frameworkを使用したストリーム処理
• リージョンのイベントをAsyncEventQueueに入れて非同期に処理する
16
イベントハンドラ
AsyncEventQueue
リージョン ・・・
処理結果をリージョン
に書き込む等
create region ¥
--name=IncomingRegion ¥
--type=PARTITION ¥
--async-event-queue-id
=AsyncEventQueue
create async-event-queue ¥
--id=AsyncEventQueue ¥
--parallel=true ¥
--batch-size=1 ¥
--batch-time-interval=0 ¥
--listener
=AsyncEventListener
public class AsyncEventListener
implements AsyncEventListener {
@Override
public boolean processEvents(List<AsyncEvent> events) {
for (AsyncEvent<Integer, String> event : events) {
Cache cache =
(Cache) event.getRegion().getRegionService();
Region<Integer, String> region =
cache.getRegion("OutgoingRegion");
region.put(event.getKey(), event.getSerializedValue());
}
return true;
}
}
AsyncEventQueueの設定で
パラレル処理とシリアル処理を使い分ける
17
Server#1
イベント
ハンドラ
Async
EventQueue
パーティション
リージョン
Server#2
イベント
ハンドラ
Async
EventQueue
パーティション
リージョン
Server#3
イベント
ハンドラ
Async
EventQueue
パーティション
リージョン
APP
シリアルモード
Parallel=false
イベントの順序が保障される
パラレルモード
Parallel=true
スケーラビリティがある
Server#1
パーティション
リージョン
Server#2
イベント
ハンドラ
Async
EventQueue
パーティション
リージョン
Server#3
パーティション
リージョン
APP
Kafka + Storm vs. Apache Geode
18
Kafka + Storm + Zookeeper Apache Geode
Performance Good! Good!
Deployment Complex Simple
Scalability
Complex
 Combination Kafka, Storm, Zookeper
 Storm: Fine grain scalablility
Easy
 Just add new members
Reliability Presumed SPOF with Storm/Nimbus No SPOF
Architecture High resource and buget required More flexible architecture
セッション
- Enable SQL/JDBC Access to Apache Geode/GemFire
Using Apache Calcite -
Part 2
Object Query Language(OQL)
• GeodeはKVSであるが、データを取得する際にSQLライクなOQLを実行することも出来る
20
Client
Apache Geodeクラスター
Apache Geode
(DataServer)
Apache Geode
(DataServer)
Apache Geode
(DataServer)
・・・
public class Order {
private int ordreId;
private String customerId;
private String productCd;
private Date orderDate;
private int amount;
private double price;
・・・
・・・
}
SELECT
*
FROM
/Order ord
WHERE
ord.amount >= 500
500以上の注文データを取得する場合のクエリー
クエリー対象のオブジェクト
OQL
OQLの課題
• データが複数ノードに跨るパーティションリージョンの場合には制約がある
# 制約
1 結合(join)
パーティションリージョン同士の結合は、結合条件として指定するカ
ラムをco-locationによりパーティショニングしなければいけない
2 Order by
Order byを使用する場合はOrder byで指定した項目をdistinct
で指定しなければいけない
3 複雑なクエリ
通常のSQLのようにサブクエリや結合、UNIONを多様した複雑な
クエリは使用出来ない
21
Apache Calcite
22
22
Calcite Geode Adapter
• CalciteはGeodeを隠蔽し、標準的なSQLでデータへのアクセスを可能とする
• Geodeの課題であるクエリーの柔軟性についても解消することが出来る
Client
Apache Geodeクラスター
Apache Geode
(DataServer)
Apache Geode
(DataServer)
Apache Geode
(DataServer)
・・・
Apache
Calcite
Enumerable
Adapter
GeodeAdapter
(GeodeClient)
SQL/JDBC
Calcite-Geode-Embedded(e.g.JDBC.jar)
OQL
Parse SQL into
relational expression
and optimizes
Push down all supported
expressions to Geode
OQL and fall back to
Calcite Enumerable for
the rest
Convert
relational
expressions into
OQL queries
23
Geode Model Mapping
• Geode AdapterがGeodeのデータモデルをRelational Modelにマッピング
24
Cache
Region
Key Value
Region
・・・
Schema
Table
Col1
(Key)
Col2
(Val1)
Col3
(Val2)
Col4
(Val3)
Table
・・・
Geode Model
・・・ ・・・
Relational Model(Calcite)
Cache into Schema
Regions into Tables
Key/Value into Table Row
Column types inferred
from PDX fields
Key Value
Col1
(Key)
Col2
(Val1)
Col3
(Val2)
Col4
(Val3)
Pros & Cons
• Ad-hoc data exploration
• JDBC integration with 3rd party tools
• Data Federation, correlate Geode with
other data sources
• SQL Streaming as CQ++
• No-intrusive and extensible approach
• What happened with SQLFire?
• Geode == Transactional System!
SQL+Geode <> Analytical System!
• Key/Value vs. Full Scan
• Overhead: SQL > OQL > Functions
• Data at Rest (Table) vs. Data at Motion
(Stream)
25
Federation: Unified Query Interface
26
セッション
- Real-Time Analytics for Data-Driven Applications -
Part 2
リアルタイム分析の課題
28
ampoolはリアルタイム分析の課題を解消する!
29
ampoolのアプローチ
• ampoolを使用することで、データを蓄積、提供するサイクルと分析するサイクルがひとつにな
り、リアルタイム名データ分析が出来る
30
APP
Persistence
Store
Serve
Analyze
Serve processed data
(aggregates or insights)
at scale and speed
Flexibility in storing data
Keep-up with fast ingestion needs
Support streaming,
batch / macheine learning
& interactive querying
APP
Long-term
Persistence
Store
Analyze
Serve
Manage hot data
in-memory
Process where
data is stored
Primary store
not a cache!
従来のデータ分析 ampoolを使用したリアルタイムデータ分析
ampoolはGeodeをベースに独自機能を拡張
• Powered by Apache Geode
31
Tunable Consistency
In-Memory Distirbuted Sys
Low-latency Comms.
Key-Value Store
Mature Event Model
Function Pushdown
Metadata / Catalog
Smart Data Tiering
High Throughput
Table Abstcactions
Native InterfacePluggable Persistence
Security AuthZ
MASH (CLI Ext)
Java API
Java API
様々なデータをampoolにリアルタイムに集約することで
高速な分析を可能に
① Ampool Core
• Object & Structure
• Region, MTable, FTable
• APIs for extending capabilities
• Compute, strage & import / export
• User defined functions
② Pre-built connectors for
• Data ingest / export paths
• Kafka Sink, Java API, REST, Spark DF
• Data processing (compute f/works)
• HiveQL, SparkSQL, APIs
③ Pre-built extensions for persistence
• From on-premise shared FS to Cloud
strage
32
①
Ampool
Core
③
Pre-built
Persistence
②
Pre-built
Connectors
ampoolは同時アクセスが多い場合の性能に優れる!
33
セッション
- Simplifying Apache Geode with Spring Data -
Part 2
Spring Data Geodeの歴史
35
Spring Data
GemFire
1.7.0.RELEASE
1 Sep 2015
Spring Data
Geode
Branch for Apache Geode
2.0.0.RELEASE
2 Oct 2017
2.0.0.RELEASE
2 Oct 2017
1.8.0.RELEASE
6 Apr 2016
1.9.0.RELEASE
26 Jan 2017
Apache
Geode
1.0.0-incubating
15 Oct 2016
1.1.0
9 Feb 2017
1.2.0
12 Jul 2017
Spring Data GeodeもSpring Data Release TrainにJoin!
36
Spring Data GemFireとSpring Data Geodeの違いは?
• 2つのプロダクトに差異はない
• Spring Data GemFireからSpring Data Geodeへの移行を最小限にすることを優先
37
Apache Geode 1.2.1
Pivotal GemFire 9.1.1
Spring Data Geode 2.0.0
Spring Data GemFire 2.0.0
対応する
Spring Dataバージョン
違いはない
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-gemfire</artifactId>
↓
<artifactId>spring-data-geode</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
SpringData GemFireからSpringData Geodeへ
の移行に必要なのはMaven、Gradleの依存設定
を変更するのみ
Spring Data Geode 2.0 Kay
• Upgrades to Apache Geode 1.2.0 (GA) release.
• Upgrades to Spring Framework 5.0.0.RELEASE.
• Upgrades to Spring Data Commons Kay.
• Additional improvements in the new Annotation-based
configuration model.
• Support Apache Geode’s Apache Lucene Integration.
38
Spring Data Geodeが面白いのはこれから!
• Function Execution from Repositry
• Paging support in Repositry
• Query Projections
• Reactive Repository extension for CQ
• Spring Security support
• Annotaion support for CacheCallbacks
• Auto-generated IDs (Region keys)
• New Spring-driven Test (Context) Framework
39
Spring Data
Release Train 2.1 (Lovelace)
サマリー
Part 3
サマリー
1. Asynchronous Event Frameworkを使用することで
シンプルな構成でストリーム処理ができる
2.Calciteは標準SQLを使用してGeodeのデータにアクセ
スできる
3.ampoolはリアルタイム分析向けのプロダクト。特に同
時アクセスが多い場合の性能が優れている
4.Spring Data for Apache Geodeが面白いのはこれ
から
41
Next!

Apache geode at-s1p