why domain-driven design and reactive programming?

Post on 15-Apr-2017

972 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Why Domain-Driven Design and Reactive Programming?

Vaughn Vernon – Distinguished Author and ConsultantWes Williams – Pivotal Software Designer & Architect

My Best Selling Books

@VaughnVernon

What Causes Software Projects to Lack Well-Designed Domains?

Data-Only Focus When You Should Aim Higher to Capitalize on Your Unique Business Drivers

Business Concepts are Seen Only as Data-Centric Anemic Entities

Here’s How it Happens

Oh Yeah, and …

Well, There are Also …

Don’t Forget …

Wouldn’t That Be …

Don’t Limit

It’s Getting Muddy

Cavaet: Big Ball of Mud

Your entities grow in number until no one understands the tangled web.

Team is Blinded by Data and Lack of Core Business Knowledge and Collaboration

What is a Good Domain Model and How Does it Help with Reducing Complexity?

Invest in Business Knowledge

Developers Domain Experts

Business Value: Unify Mental Models Through a Team-Developed Domain Language

??????

Segregate the Language Into a Well-Defined Software Model

Strategic Design Tool: Bounded Context

Strategic Design Tool: Bounded Context

Inside the Boundary the Concepts Have Well Defined Context

Outside The Boundary Other Concepts Will Not Adhere to The Context of our Model

Using These Principles We Can Challenge The Tangle and Identify Our Core Language

Actual Core

Multiple Bounded Contexts

What is Reactive Software and How Does it Help Developers Solve

Complex Application and Integration Problems?

Must Integrate Multiple Bounded Contexts

Inside Bounded Contexts Are Aggregate Components

Aggregates Produce Facts: Domain Events

In App: Cross-Aggregates are Reactive

new

One Transaction Saves Aggregate and Event

Other Bounded Contexts react to Domain Events

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?

Time-to-Market is Reduced Through Modeling with Business Knowledge

Software Quality is Enhanced and Business Goals Achieved Through the Bounded Context and Ubiquitous Language

Software is More Scalable Through Smaller Focused Bounded Contexts

How Can In-Memory Data Grids Like Open Source Apache Geode and Pivotal GemFire (Based on Apache Geode) Fit With These

Modern Concepts?

Pivotal Software

Wes WilliamsPivotal Data Engineering

wwilliams@pivotal.io

Largest startup in history of Silicon Valley

Helping enterprises scale withProcess + OS Software + Data Engineering

Reactor & DDD - Demo

High-speedPrice 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

Reactive Kafka – Why?

High-speedstreaming transactions

Pivotal GemFire

High-speedstreaming 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

GemFire – Why?

Region

get(key)

Aggregate

In-memory object grid

Business logic and data are co-located

DDD + GemFire =A natural complement!

Data must be serialized first from across network.

GemFire – Eventing ArchitectureApplicatio

nApplicatio

n

DB or other Data Store

Orders

Update!Continuous QuerySelect * from /EventStore where type = “Buy Order”Cache

Write

Algorithmic Orders

EventStore

Listening for new orders

Built-in Event-Driven Architecture

GemFire – Fast Calculations

High-speedcalculations

Algorithmic Trading System

Pivotal GemFire

Flight Scheduler Target Marketing

<Your company’s analytic here>

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 filledUsing DDD & Reactor technology with an In-memory Data Grid

Demo – Convert Prices to …

High-speedPrice 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

Demo - Analytics

Volume-Weighted Average Price

Execute trade when VWAP < target price

open

close

Calculate VWAP Evaluate Trade

Σ (price * volume)________________________________________________________

Σ (volume)VWAP =

GemFire – Eventing ArchitectureApplicatio

nApplicatio

n

Orders

Update!

Continuous QuerySelect * 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

Demo

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

Next Steps

My Best Selling Books

@VaughnVernon

http://idddworkshop.com

Pivotal Resources• Pivotal GemFire

• Features, Benefits, Use Cases:https://pivotal.io/big-data/pivotal-gemfire

• Free Intro Online Course: https://pivotal.io/academy/course/introduction-to-gemfire

• Today’s Demo:https://github.com/VaughnVernon/IDDD_NYSEhttps://github.com/reactor/reactor-kafka

• Apache Geode• Site: http://geode.apache.org/• Geode Summit: https://2016.event.geodesummit.com/schedule• Upcoming Community Discussion with Vaughn Vernon: Weds, Sept 21, 9AM

PacificMeeting URL: https://pivotal.zoom.us/j/540483502

top related