This document discusses the benefits of combining domain-driven design (DDD) and reactive programming approaches with an in-memory data grid like Apache Geode or Pivotal GemFire. It notes that DDD helps reduce complexity by developing a shared domain language within bounded contexts, while reactive programming allows different bounded contexts to integrate via domain events. The document then demonstrates how to use these techniques with GemFire/Geode for a high-speed algorithmic trading system, including converting price quotes to bars, calculating analytics, and submitting orders.
37. One Transaction Saves Aggregate and Event
Other Bounded Contexts react to Domain Events
38. How Can You Use These Techniques
To Reduce Time-to-Market and
Improve Quality as You Build
Software That is More Flexible, More
Scalable, and More Tightly Aligned to
Business Goals?
40. Software Quality is Enhanced and Business Goals
Achieved Through the Bounded Context and
Ubiquitous Language
41. Software is More Scalable Through Smaller
Focused Bounded Contexts
42. How Can In-Memory Data Grids Like Open
Source Apache Geode and Pivotal GemFire
(Based on Apache Geode) Fit With These
Modern Concepts?
43. Pivotal Software
Wes Williams
Pivotal Data Engineering
wwilliams@pivotal.io
Largest startup in history of Silicon Valley
Helping enterprises scale with
Process + OS Software + Data Engineering
44. Reactor & DDD - Demo
High-speed
Price Feed
Pivotal
GemFire
Execution
Management
System
Algorithmic
Trading System
DDD Style
https://github.com/reactor/reactor-kafka
Stream – convert quotes to price bars
Wall Street
Automated Trading Strategy
https://github.com/VaughnVernon/IDDD_NYSE
45. Reactive Kafka – Why?
High-speed
streaming
transactions
Pivotal
GemFire
High-speed
streaming
transactions
Pivotal
GemFire
20,000 txns/ sec on a 4-core 2.8 GHz MAC
1,000,000 txn / sec on
a 4-core 2.8 GHz MAC
Asynch put
micro-batches
Auto-replay batches in
case of commit failure
47. GemFire – Eventing Architecture
Applicatio
n
Applicatio
n
DB or other
Data Store
Orders
Update!
Continuous Query
Select * from /EventStore where type
= “Buy Order”
Cache
Write
Algorithmic Orders
EventStore
Listening for
new orders
Built-in Event-Driven
Architecture
48. GemFire – Fast Calculations
High-speed
calculations
Algorithmic Trading
System
Pivotal
GemFire
Flight Scheduler Target Marketing
<Your company’s
analytic here>
49. Demo Features
1. Windowing – Convert a stream of quotes into a 1-second price bar.
2. Analytics – Calculate the Volume-Weighted Average Price on each bar
3. Submit Buy Order for 25,000 shares
4. Algorithmically execute the order in 1,000-share “slices” until filled
Using DDD & Reactor technology with an In-memory Data Grid
50. Demo – Convert Prices to …
High-speed
Price Feed
Pivotal
GemFire
Price feed - emits price
quotes in a pseudo-random
wave pattern with a 5%
range
5-second price bars for AAPL
Creating price bars in a
1-second window
open
highclose
low
51. Demo - Analytics
Volume-Weighted Average Price
Execute trade when VWAP < target price
open
close
Calculate VWAP Evaluate Trade
Σ (price * volume)
________________________________________________________
Σ (volume)
VWAP =
52. GemFire – Eventing Architecture
Applicatio
n
Applicatio
n
Orders
Update!
Continuous Query
Select * from /EventStore
where type = “Buy Order”
Algo Orders
EventStore
Listening for
new orders
Submit a “Buy”
request for
25,000 shares
Submit Order to
trade
algorithmically
Will submit orders 1,000
shares at a time until the
entire order is filled
54. Demo Summary
1. DDD and Reactor – Powerful best practices and practical for the
enterprise
2. GemFire – A natural complement to DDD due to being an object IMDG,
built-in eventing. Can use with Reactor streaming for Fast Analytics.
3. Reactor Kafka - Enables extremely high throughput
Thanks to Vaughn Vernon for modifying the trading system to DDD style