patterns for distributed event processing - oracle coherence · 2020-07-01 · patterns for...

20
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Oracle Event Processing and Coherence Patterns for Distributed Event Processing Philip Aston Coherence SIG 15 th November 2012 1 / 20

Upload: others

Post on 01-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Oracle Event Processingand Coherence

Patterns for Distributed Event Processing

Philip Aston

Coherence SIG15th November 2012

1 / 20

Page 2: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Outline

Introduction

Continuous Aggregation

Product Integration

2 / 20

Page 3: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Coherence

I In-memory Data Grid

I Simple event model for change notificationI Mature clustering

I Partitioned scheme scales to large data setsI Transactional changesI High availability / recovery

3 / 20

Page 4: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Oracle Event Processing (OEP)

I Domain-specific Application ServerI Event processing frameworkI AdaptersI Tooling

I Continuous Query Language (CQL)

I Good Coherence integration

I Limited OOTB support for distributed event processing

4 / 20

Page 5: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

The Problem

I Continuously reduce an event stream,grouped by some attributes

E : (a, b, c, v)

select a, b, sum(v)

from E

group by a, b

I Do so in a distributed, efficient, and resilient manner

5 / 20

Page 6: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Processing partition (≡ shard)

I Large volume of events

I The event stream is distributed over hardware

6 / 20

Page 7: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Entity-level aggregation

I Events typically refer to identifiable objects or entities

I Changes are calculated at entity level

7 / 20

Page 8: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Tiered aggregation

We’ve identified three levels of aggregation

I Σ′′ Entity

I Σ′ Processing partition

I Σ Total result

8 / 20

Page 9: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Push or Pull?

I Continuous aggregation

I Query

I Hybrid

9 / 20

Page 10: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Coherence features?

Distributed aggregation queries, but not continuous aggregation

I EntryAggregatorI Reduce cache entries to a resultI Pull

I Continuous Query CacheI Filtered view of a cacheI PushI Not an aggregation mechanism

10 / 20

Page 11: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OEP features?

Continuous aggregation, but not aggregation by query

I Continuous Query Language

select a, b, myaggr(v) from E group by a, b

I Aggregations are incrementally evaluatedI Parallel evaluation, by groupI Supports User Defined Aggregations in Java

I Highly statefulI State is implicit and cannot be replicated atomicallyI Distributed aggregation is an exercise for the user

11 / 20

Page 12: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

OEP + Coherence = Win

I Use Coherence partitions for processing partitionsI Cheap event joins through key affinityI Partition-level transactions

I Store entities in CoherenceI No duplication of entity state in OEPI Coherence provides resilienceI Allows aggregation by query

I Use CQL for partition-level continuous aggregationI Declarative rulesI Results can be re-calculated after failure

12 / 20

Page 13: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Entity and partition-level aggregation

13 / 20

Page 14: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Final aggregation

I Partition-level results are placed in a Coherence cacheI Convenient publishing mechanism

I We query to produce the totalI Results cache partitioned by logical key for cheap

aggregation across processing partitions

I Alternative: continuously aggregate total using CQLI Appropriate if end-point is event-drivenI E.g. message bus, or dynamic user interface

14 / 20

Page 15: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Resilience

I Processing partitions are Coherence partitionsI Each processing partition produces an absolute result

I Output is a function of the partition contents

I A backing map listener tracks newly-owned entity keysI Scheduled EP flushes entity-level values for aggregation

15 / 20

Page 16: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Resilience

The actual CQL is a little more involved to discard aggregations for partitions we no longer own.

16 / 20

Page 17: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Two threading models

I Coherence service threadsI Blocking an EntryProcessor, EntryAggregator, or a

BackingMapListener will result in failure

I OEP threadsI Uses WebLogic’s self-tuning thread pool/work managersI Adjusts thread count for I/O or CPU bound work

17 / 20

Page 18: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Listening to a cache

Dispatch to the EPN must not result in I/O for every event

I OK? - use an EntryProcessor + asynchronous channel

I Otherwise, poll using the NamedCache API

18 / 20

Page 19: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Local processing

I Single distribution point when event enters systemI Subsequent processing kept within the JVM

I storageenabled=true

I Our events make idempotent changesI Enables resiliency through upstream backup

19 / 20

Page 20: Patterns for Distributed Event Processing - Oracle Coherence · 2020-07-01 · Patterns for Distributed Event Processing Philip Aston Coherence SIG 15th November 2012 1/20 ... I Reduce

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.

Queue Cache

20 / 20