exactly once stateful streams the easy way
play

EXACTLY ONCE STATEFUL STREAMS THE EASY WAY COLIN MACNAUGTHON NEEVE - PowerPoint PPT Presentation

EXACTLY ONCE STATEFUL STREAMS THE EASY WAY COLIN MACNAUGTHON NEEVE RESEACH INTRODUCTIONS Based in Silicon Valley Creators of the X Platform- Memory Oriented Application Platform. Passionate about high performance computing for


  1. EXACTLY ONCE STATEFUL STREAMS THE EASY WAY COLIN MACNAUGTHON NEEVE RESEACH

  2. INTRODUCTIONS ¡ Based in Silicon Valley ¡ Creators of the X Platform™- Memory Oriented Application Platform. ¡ Passionate about high performance computing for mission critical enterprises.

  3. WHY DO WE CARE ABOUT STREAMING? WHY STREAMING? Loosely coupled, multi-agent micro services architectures are more agile, and reduce delivery risk. Coupled with the increasing amount of business valuable data it is important that we can move data between processes rapidly while at the same time maximizing hardware utilization to reduce cost. WHY EXACTLY ONCE? Reliability coupled with ease: the less developers have to focus on handling loss and duplicates the more robust our multi agent applications will be.

  4. AGENDA ¡ Why is Exactly Once Streaming Hard? ¡ How The X Platform tackles Streaming ¡ Streaming Usecase: IoT Fleet Tracking

  5. STREAM TRANSACTION PROCESSING APPLICATIONS What do they do? Consume Inbound Messages 1. Read / Update State 2. … and Produce Outbound Messages 3. Inbound Message Stream(s) Outbound Message Streams • Customer Traffic Shipping • Apps: Spark, Kafka … • Datasources: Flat files, RDBS etc. Order Manager • Devices (IoT) • Stock Ticker Compute Risk Analysis Application State (CRUD) Data Store

  6. THE IDEAL STREAMING FRAMEWORK Fast - 10s - 100k transactions/sec, response times in microseconds or milliseconds ¡ Stateful – Ability to operate on persistent state in a transactionally consistent fashion. ¡ Reliable - no dups / no loss / atomic across failures ¡ Available – handle process / infrastructure failures ¡ Scalable - scale on demand ¡ Manageable - integrate with CI (test, build, provision) ¡ Easy - trivial to author and drop in new stream processors without concern for the above. ¡

  7. MICROSECONDS MATTER A processing time of 1ms limits your throughput to 1000 messages / sec. Same applies to any synchronous callouts in the stream. T o achieve >10k Transactions/Second you must leverage In Memory technologies

  8. MICROSECONDS MATTER Storage Latency Ops/Sec MEMORY ORIENTED COMPUTING! L1 Cache ~1ns 1b L2 Cache ~3ns 333m L3 Cache ~12ns 83m Remote NUMA Node ~40ns 25m All State in Memory All The Time! Main Memory ~100ns 10m 100 μ s Network Read 10k 150 μ s Random SSD Read 4K 6.6k Non Starters For Performance 500 μ s* Data Center Read 2k We’re Talking About! Mechanical Disk Seek 10ms 100 Sources: https://gist.github.com/jboner/2841832 http://mechanical-sympathy.blogspot.com/2013/02/cpu-cache-flushing-fallacy.html

  9. THE CHALLENGES Exactly Once Semantics ¡ Messaging – No Loss / No Dups ¡ Storage and Access to State – No Loss / No Dups ¡ Atomicity between Message Streams and Data/Stream Stream ¡ Receive-Process-Send must be atomic for event processing ¡ consistency across failures. Storage is key - must remember: What events have already been ¡ processed Messages App Messages Process ! ! Changes in state as a result of processing ¡ Acks Acks What results have (and have not) been ¡ ! How long until app can sent to the world. process the next Data Store event?

  10. TRADITIONAL TP APPLICATION ARCHITECTURE (Choke Point!) Data Tier Ø Slow Relational Database (Transactional State Ø Complex Reference Data) Ø Does not scale with size or volume Ø Slow Application Tier (Business Logic) Ø Durable Wrong Scaling Strategy Ø Consistent Ø Does Not Scale Ø Complex Messaging Load Balanced, Ø Synchronous (HTTP, JMS) Sticky Routing Ø Slow Ø Poor Routing Ø Ordering Complexity

  11. LAUNCH DATA INTO MEMORY (Choke Point … still!) Data Tier Ø Better but still slower than memory In-Memory Replicated (Transactional State Ø Simpler but still not pure domain Reference Data) Ø Does not scale with size Ø Slow Application Tier (Business Logic) Ø Durable Wrong Scaling Strategy Ø Consistent Ø Does Not Scale Ø Complex Messaging Ø Synchronous (HTTP, JMS) Ø Slow Ø Poor Routing Ø Complex Ordering

  12. DATA GRAVITY (DATA STRIPING + SMART ROUTING) A MICRO SERVICE ARCHITECTURE In-Memory + Partitioned (Optimal ?) Data Tier (Transactional State Ø Better but still slower than memory Reference Data) Ø Simpler, but not “pure” data model Ø Scales with size and volume Ø Slow Application Tier (Business Logic) Ø Durable Ø Consistent Ø Scales Processing Swim-lanes (ordered) Messaging Ø Agile (Publish -Subscribe) Ø Complex Messaging Fabric Routing Strategy?

  13. WHY STILL SLOW AND COMPLEX How Slow? ¡ Latency ¡ 10s to 100s of milliseconds ¡ Throughput ¡ Not great with single pipe ¡ Few 1000s per second per partitioning ¡ Why Still Slow? ¡ Remoting out of process (data latency) ¡ Synchronous data updates and message acknowledgement ¡ Concurrent transactions are not cheap! ¡ Why Complex? ¡ Transaction Management still in business logic ¡ Thread management for concurrency (only way to scale) ¡ Complex Routing (how to load balance between swim lanes?) ¡ Data transformations due to lack of structured data models ¡

  14. STREAMING APPS ON THE X PLATFORM ü Message Driven ü Totally Available ü Stateful ü Horizontally Scalable ü Multi-Agent ü Ultra Performant

  15. THE X PLATFORM APPROACH In Application Memory Replicated + Partitioned Application State fully in Local Memory Pipelined Replication Ø Operate at memory speeds Hot Backup Primary Ø Plumbing free domain Application + Data Ø Scales with size and volume Tier! “Pure” Single-Threaded business Dispatch Ø Fast logic Ø Durable Processing Swim-lanes Messaging Ø Consistent (Publish -Subscribe) Ø Scales Ø Simple Solace, Kafka, Falcon, JMS 2.0… Smart Routing (messaging traffic partitioned to align with data partitions)

  16. NOW WHAT IS THE PERFORMANCE? How Fast? ¡ Latency ¡ ¡ 10s of microseconds to low milliseconds Throughput ¡ ¡ 100s of thousands of transactions per second How Easy? ¡ Model Objects and State in XML, generated into Java objects and collections. ¡ Annotate methods as event handlers for message types. ¡ Single threaded processing ¡ Work with state objects treating memory as durable. ¡ Send outbound messages as “Fire And Forget” ¡ Shard applications by state, messages routed to right app. ¡

  17. X PLATFORM TRANSACTION PIPELINING (HA) Application Handlers Inbound Message Stream Outbound Message Streams 2 4 1 Primary X 4 5 1 2 … Journal 3 Storage ü State as Java Backup Receive ü Messages as Java 1 X ü State 100% In Memory Process 2 ü Zero Loss or Duplication Replicate State Changes 1 2 … 3 Journal ü Pipelined Replication Storage Send Out / Ack 4 ü Async Journaling ü Pipelined Messaging Inbound Acks 5 ü Pooling for Zero Garbage

  18. THE FULL HA PICTURE REMOTE DATA DATA WAREHOUSE CENTER ASYNCHRONOUS REPLICATION: (i.e. no impact on system throughput) Concurrent, background operation ATOMIC, EXACTLY ONCE: Txn Loop from 1->4. 3 Application Logic Application Logic 2 ODS / CDC ICR CDC (Message Handler) (Message Handler) 3 Always Local State (POJO) No Remote Lookup, No Contention, In-memory In-memory Single Threaded storage storage Backup Primary Ack 3 4 1 ASYNCHRONOUS (i.e. no impact on system throughput) NO MESSAGING ASYNCHRONOUS, IN BACKUP ROLE Guaranteed Journal Storage Journal Storage Messaging Messaging Fabric

  19. DEVELOPER CONCERNS X Application = BUSINESS LOGIC (HANDLERS) MESSAGES STATE CONFIG EventHandler final public void onAuthRequest(AuthRequestMessage message Repository state) { // instantiate a new cc transaction final Transaction txn = Transaction.create(); // extract from message into a transaction AuthRequestMessageExtractor.extract(message, txn); + + + // update transaction state txn.setState(TransactionState.PendingAuth); Customer customer = state.getCustomers().get(txn.getCustomerId() customer.getTransactions().add(txn) // create a fraud detection request final FraudDetectionRequest req = FraudDetectionRequest.create(); // populate the request FraudDetectionRequestPopulator.populate(req, txn); // send the event sendMessage(req); } Not required for vertical Not required for specific models such as FIX Event Sourcing

  20. USE CASE - IOT Building a Fleet Tracking System with The X Platform

  21. IMPLEMENTING GEOFENCING We have a fleet of vehicles. ¡ (cars, trucks, whatever) § Each vehicle Should be following a route defined by Administrators ¡ Our Fleet Management System needs to: ¡ Track location of vehicles to ensure routes are being followed. § Monitor telemetry like speed, etc. § If a vehicle leaves its route, trigger alerts . §

  22. FLEET GEOFENCING Admin V E H I C L E M A S T E R In-Memory State Journal Based Storage V E H I C L E V E H I C L E From Vehicles E V E N T G A T E W A Y E V E N T P R O C E S S O R V E H I C L E A L E R T R E C E I V E R

  23. THE CODE Message State Management Plain Old Java Object Plain Old Java Objects Generated from XML Model Generated from XML Model Messaging Annotation based handler discovery, Single Threaded State Management Plain Old Java objects and Java Collections State Management State Changes transparently State Management Replicated to Hot Object Pooling and Backup and/or Disk Based Journal Preallocation for Zero Garbage Messaging Create and populate “Fire and Forget” Pure Business Logic – Exactly Once Processing

Recommend


More recommend