Microservices with Kafka Ecosystem. Guido Schmutz

Similar documents
CON Apache Kafka

Empfehlungen vom BigData Admin

Cloud Acceleration. Performance comparison of Cloud vendors. Tobias Deml DOAG2017

Backup Methods from Practice

Data Vault Partitioning Strategies. Dani Schnider, Trivadis AG DOAG Conference, 23 November 2017

Best Practices for Testing SOA Suite 11g based systems

Analytic Views: Use Cases in Data Warehouse. Dani Schnider, Trivadis AG DOAG Conference, 21 November 2017

Database Sharding with Oracle RDBMS

Application Containers an Introduction

Domain Services Clusters Centralized Management & Storage for an Oracle Cluster Environment Markus Flechtner

Fluentd + MongoDB + Spark = Awesome Sauce

Application Containers an Introduction

Application Containers an Introduction

Online Operations in Oracle 12.2

Microservices Lessons Learned From a Startup Perspective

BUILDING MICROSERVICES ON AZURE. ~ Vaibhav

Managing Data at Scale: Microservices and Events. Randy linkedin.com/in/randyshoup

Oracle Database Service High Availability with Data Guard?

Data Acquisition. The reference Big Data stack

WELCOME. Unterstützung von Tuning- Maßnahmen mit Hilfe von Capacity Management. DOAG SIG Database

REALTIME WEB APPLICATIONS WITH ORACLE APEX

Data Acquisition. The reference Big Data stack

Designing for Performance: Database Related Worst Practices ITOUG Tech Day, 11 November 2016, Milano (I) Christian Antognini

The Microsoft Big Data architecture approach

Bloom Filters DOAG Webinar, 12 August 2016 Christian Antognini Senior Principal Consultant

Data pipelines with PostgreSQL & Kafka

Increase Value from Big Data with Real-Time Data Integration and Streaming Analytics

Transformation-free Data Pipelines by combining the Power of Apache Kafka and the Flexibility of the ESB's

Introduction in Eventing in SOA Suite 11g

Oracle In-Memory & Data Warehouse: The Perfect Combination?

Lecture 21 11/27/2017 Next Lecture: Quiz review & project meetings Streaming & Apache Kafka

A Distributed System Case Study: Apache Kafka. High throughput messaging for diverse consumers

Query Optimizer MySQL vs. PostgreSQL

MOM MESSAGE ORIENTED MIDDLEWARE OVERVIEW OF MESSAGE ORIENTED MIDDLEWARE TECHNOLOGIES AND CONCEPTS. MOM Message Oriented Middleware

Pimping up Industry Devices with Rasperry Pi, Vert.x und Java 8

Event Streams using Apache Kafka

Query Optimizer MySQL vs. PostgreSQL

An Information Asset Hub. How to Effectively Share Your Data

IBM Data Replication for Big Data

ZooKeeper. Table of contents

Using the SDACK Architecture to Build a Big Data Product. Yu-hsin Yeh (Evans Ye) Apache Big Data NA 2016 Vancouver

Data Replication With Oracle GoldenGate Looking Behind The Scenes Robert Bialek Principal Consultant Partner

Lenses 2.1 Enterprise Features PRODUCT DATA SHEET

Reactive Microservices Architecture on AWS

SOLUTION TRACK Finding the Needle in a Big Data Innovator & Problem Solver Cloudera

Database Rolling Upgrade with Transient Logical Standby Database DOAG Day High Availability Robert Bialek Principal Consultant

Oracle SOA Suite 11g: Build Composite Applications

Integration of Oracle VM 3 in Enterprise Manager 12c

Un'introduzione a Kafka Streams e KSQL and why they matter! ITOUG Tech Day Roma 1 Febbraio 2018

Death Stars & River Deltas. Toward a Functional Programming Analogy for Microservices

Big Data Technology Ecosystem. Mark Burnette Pentaho Director Sales Engineering, Hitachi Vantara

Introduc)on to Apache Ka1a. Jun Rao Co- founder of Confluent

Let the data flow! Data Streaming & Messaging with Apache Kafka Frank Pientka. Materna GmbH

Identifying Performance Problems in a Multitenant Environment

MariaDB MaxScale 2.0, basis for a Two-speed IT architecture

Introduction to Kafka (and why you care)

Innovatus Technologies

Big Data Infrastructure at Spotify

Deep Dive Amazon Kinesis. Ian Meyers, Principal Solution Architect - Amazon Web Services

Welcome. Oracle SOA Suite meets Java The best of both worlds. Guido Schmutz DOAG Konferenz 2013 Nürnberg,

Security and Performance advances with Oracle Big Data SQL

HYBRID TRANSACTION/ANALYTICAL PROCESSING COLIN MACNAUGHTON

Apache Kafka a system optimized for writing. Bernhard Hopfenmüller. 23. Oktober 2018

Apache Tamaya Configuring your Containers...

Overview. Prerequisites. Course Outline. Course Outline :: Apache Spark Development::

Integration and Extensibility

Building loosely coupled and scalable systems using Event-Driven Architecture. Jonas Bonér Patrik Nordwall Andreas Källberg

Flash Storage Complementing a Data Lake for Real-Time Insight

Solace JMS Broker Delivers Highest Throughput for Persistent and Non-Persistent Delivery

SQT03 Big Data and Hadoop with Azure HDInsight Andrew Brust. Senior Director, Technical Product Marketing and Evangelism

Oracle Data Integrator 12c: Integration and Administration

A day in the life of a log message Kyle Liberti, Josef

WHITE PAPER. Reference Guide for Deploying and Configuring Apache Kafka

The Stream Processor as a Database. Ufuk

Managing data consistency in a microservice architecture using Sagas

Four times Microservices: REST, Kubernetes, UI Integration, Async. Eberhard Fellow

Oracle Big Data SQL. Release 3.2. Rich SQL Processing on All Data

The three investigators

Integrating Oracle Databases with NoSQL Databases for Linux on IBM LinuxONE and z System Servers

Nevin Dong 董乃文 Principle Technical Evangelist Microsoft Cooperation

@unterstein #bedcon. Operating microservices with Apache Mesos and DC/OS

Intra-cluster Replication for Apache Kafka. Jun Rao

Oracle Database 18c New Performance Features

WHITEPAPER. MemSQL Enterprise Feature List

Evaluation Guide for ASP.NET Web CMS and Experience Platforms

CQRS and Event Sourcing for Java Developers Markus Eisele

Container 2.0. Container: check! But what about persistent data, big data or fast data?!

Developing Microsoft Azure Solutions (70-532) Syllabus

The IBM MobileFirst Platform

Developing Enterprise Cloud Solutions with Azure

Microservices What, Why? ( 마이크로서비스를꼭써야하나 )

Developing Microsoft Azure Solutions (70-532) Syllabus

Oracle Database Failover Cluster with Grid Infrastructure 11g Release 2

BIG DATA COURSE CONTENT

Object-Relational Mapping Tools let s talk to each other!

AN EVENTFUL TOUR FROM ENTERPRISE INTEGRATION TO SERVERLESS. Marius Bogoevici Christian Posta 9 May, 2018

From Single Purpose to Multi Purpose Data Lakes. Thomas Niewel Technical Sales Director DACH Denodo Technologies March, 2019

MetaMatrix Enterprise Data Services Platform

Building Event Driven Architectures using OpenEdge CDC Richard Banville, Fellow, OpenEdge Development Dan Mitchell, Principal Sales Engineer

The SMACK Stack: Spark*, Mesos*, Akka, Cassandra*, Kafka* Elizabeth K. Dublin Apache Kafka Meetup, 30 August 2017.

Transcription:

Microservices with Kafka Ecosystem Guido Schmutz @gschmutz doag2017

Guido Schmutz Working at Trivadis for more than 20 years Oracle ACE Director for Fusion Middleware and SOA Consultant, Trainer Software Architect for Java, Oracle, SOA and Big Data / Fast Data Head of Trivadis Architecture Board Technology Manager @ Trivadis More than 30 years of software development experience Contact: guido.schmutz@trivadis.com Blog: http://guidoschmutz.wordpress.com Slideshare: http://www.slideshare.net/gschmutz Twitter: gschmutz 2

Our company. Trivadis is a market leader in IT consulting, system integration, solution engineering and the provision of IT services focusing on and technologies in Switzerland, Germany, Austria and Denmark. We offer our services in the following strategic business fields: O P E R A T I O N Trivadis Services takes over the interacting operation of your IT systems. 3

With over 600 specialists and IT experts in your region. COPENHAGEN HAMBURG 14 Trivadis branches and more than 600 employees 200 Service Level Agreements Over 4,000 training participants DÜSSELDORF Research and development budget: CHF 5.0 million FRANKFURT Financially self-supporting and sustainably profitable BASEL FREIBURG STUTTGART BRUGG ZURICH MUNICH VIENNA Experience from more than 1,900 projects per year at over 800 customers GENEVA BERN LAUSANNE 4

Agenda 1. Where do we come from? 2. What are Microservices? 3. Why not Event Driven? 4. Why Kafka for Event-Driven Microservices? 5. Asynchronous Microservices in Enterprise Architecture 6. References 5

Where do we come from? 6

Traditional Approach Customer Fat Client App Data Storage Customer UI GUI Customer BO Data Shop Backend Application Shop Rich UI Search Facade Order DAO Shared Database Shop UI GUI UI Logic Customer DAO sync request/response Order Facade Business Product DAO Data 7

SOA Approach Shop Web App Business Activity Service Business Entity Service Data Storage SOAP SOAP Shop UI GUI UI Logic Custer BAS Customer BES SOAP Customer Database Shop UI App SOAP Search BAS Payment BES Order DAO SOAP Shop UI GUI UI Logic SOAP Order BAS Product Customer BES DAO SOAP Order and Product DB Service Product DAO Order BES Data 8

Virtualized SOA Approach Service Virtualization Layer Shop Web App Business Activity Service Business Entity Service Data Storage Shop UI GUI UI Logic SOAP SOAP Service Bus Custer BAS Customer BES SOAP Customer Database Shop UI App SOAP Payment BES Order DAO SOAP Shop UI GUI UI Logic Search BAS SOAP Product Customer BES DAO SOAP Order and Product DB 9 Order BAS Order BES

What are Microservices? 10

Key Principles of Microservices Tightly Scoped Tightly Encapsulated behind concrete interfaces Responsible for managing their own data Highly cohesive Highly decoupled Independently deployable, self-contained and autonomous 11

Microservice Approach Customer Microservice REST Customer API Customer Logic Customer Shop Web App Order Microservice REST Shop UI GUI UI Logic Order API Order Logic Order Product Microservice REST Product API Product Logic Product Stock Microservice REST Stock API Stock Logic Stock 12

Microservice Approach with API Gateway Customer Microservice REST Customer API Customer Logic Customer Shop Web App API Gateway Order Microservice REST Shop UI GUI UI Logic Order API Order Logic Order Product Microservice REST Product API Product Logic Product Stock Microservice REST Stock API Stock Logic Stock 13

Synchronous World of Request-Response leads to tight, point-to-point couplings Service 1 Service 2 Service 3 Service 4 API Logic API Logic API Logic API Logic State State State State problem in lower end of chain have a ripple effect on the other service crash of service overloaded service / slow response time change of interface Service 5 API Logic Service 6 API Logic Service 7 API Logic State State State 14

Why not Event-Driven? 15

3 mechanisms through which services interact Request-Driven Event Driven Command Order IPad order(ipad) Service Event Consume IPad OrderedEvent Event Broker Query Retrieve my Orders) getallorders(myself) Logic State Event Publish OrderValidatedEvent 16

3 mechanisms through which services interact Commands represents an action request for some operation to be performed in another service Something that will change the state of the system Commands expect a response. Events represent both a Fact and a Trigger Something that has happened, expressed as a notification Queries represent a request to look something up Importantly, queries are side effect free; they leave the state of the system unchanged 17

Request-Driven Communication Highest Coupling Shop UI Application Order Microservice UI Logic Call PlaceOrderAPI API Logic State Call UpdateStockAPI Stock Microservice Maybe Call Reorder API API Logic State 18

Decoupling through Events Lowest Coupling 1) Raise OrderRequested Event Order Microservice 2) Listen to OrderRequested Event Event Broker 4) Listen to OrderConfirmed Event Stock Microservice API Logic State 3) Raise OrderConfirmed Event 5) Maybe Raise Reorder Event API Logic State sync request/response async, event pub/sub async request/response 19

Event-Driven (Async) Microservice Approach Customer Microservice REST Customer API Customer Logic Customer Shop Web App API Gateway Order Microservice Shop UI GUI UI Logic REST Order API Order Logic Order Event Broker Product Microservice REST Product API Product Logic Product sync request/response async, event pub/sub async request/response Stock Microservice REST Stock API Stock Logic Stock 20

Process & Virtualized SOA Approach Sync & Async Service Virtualization Layer Shop Web App Orchestration Business Activity Service Business Entity Service Data Storage Shop UI UI Logic GUI Service Bus Custer BAS Customer BES Customer Database Shop UI App Payment BES Order DAO Shop UI GUI UI Logic Search BAS Product Customer BES DAO Order and Product DB 21 Order BAS Order BES

Command Query Responsibility Segregation (CQRS) Optimize different nonfunctional requirements for read and write behavior App Service Data Storage interface to the service is split between commands that trigger changes in state queries that provide read access to the state of resources UI Command Service Write Data Store UI Logic used to support services with higher performance and capacity requirements for reading data than for writing data Projection Service number of instances supporting queries can be scaled up independently of instance supporting commands Query Service Read Data Store (Materialized Views) 22

Event Sourcing persists the state of a business entity as a sequence of state-changing events App Service Data Storage Whenever state of business entity changes, a new event is appended to the list of events UI Event Service Since saving an event is a single operation, it is inherently atomic UI Logic Replayer The application reconstructs an entity s current state by replaying the events Other App Event Store Publisher 23

Event Sourcing & CQRS Event sourcing is commonly combined with the CQRS pattern App Service Data Storage materializing views from the stored events UI Command Service Event Store Optionally Commands can be stored in event store and transformed into events by the command handler UI Logic Command Handler Projection Service Query Service Read Data Store (Materialized Views) 24

Using Event Sourcing with Microservices Event sourcing enables building a forward-compatible application architecture the ability to add more applications in the future that need to process the same event but create a different materialized view. Microservice Event Subscribe REST Command Handler Event Store Neha Narkhede, Confluent Blog API Event Handler(s) Projection Handler(s) Query Logic State 25

How many Event Stores do we need? OR Microservice Event Store Microservice REST REST API Logic State Event API Logic State Microservice Event Store Microservice Event Store REST REST API Logic State Event API Logic State Event Microservice Event Store Microservice REST REST API Logic State Event API Logic State 26

Have one source of truth Avoid double write! Would need distributed transactions Write Event first then consume it from same micro service eat your own dog food Microservice Microservice REST API Logic State REST API Publisher Consumer State Event Store Event Store Event Event 27

Publish Event through Database Customer Fat Client App Data Store Integration Customer UI Customer BO CDC Customer CDC Connector Event Store Microservice Event Logic State 28

Why Kafka for Event-Driven Microservices? 29

Apache Kafka - Unix Analogy KSQL Kafka Connect API Kafka Streams API Kafka Connect API $ cat < in.txt grep "kafka" tr a-z A-Z > out.txt Kafka Core (Cluster) Adapted from: Confluent 30

Kafka High Level Architecture The who is who Producers write data to brokers. Consumers read data from brokers. All this is distributed. The data Data is stored in topics. Topics are split into partitions, which are replicated. Zookeeper Ensemble Producer Producer Producer Kafka Cluster Broker 1 Broker 2 Broker 3 Consumer Consumer Consumer 31

Leverage the Log at the heart of Apache Kafka sits a distributed log collection of messages, appended sequentially to a file log-structured character makes Kafka well suited to performing the role of an Event Store in Event Sourcing service seeks to the position of the last message it read, then scans sequentially, reading messages in order Reads are a single seek & scan Writes are append only Event Hub 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 32

Scale-Out Architecture Kafka Cluster Broker 1 Consumer Group 1 Consumer 1 topic consists of many partitions Producer 1 Consumer 2 producer load load-balanced over all partitions Producer 2 Broker 2 Consumer 3 consumer can consume with as many threads as there are partitions Producer 3 Broker 3 Consumer Group 2 Consumer 4 33

Strong Ordering Guarantees most business systems need strong ordering guarantees messages that require relative ordering need to be sent to the same partition supply same key for all messages that require a relative order Producer 1 Key-1 Key-2 Key-3 Key-4 Key-5 Broker 1 Broker 2 Key-1 Key-3 Consumer 1 Consumer 2 Consumer 3 To maintain global ordering use a single partition topic Key-6 Broker 3 34

Durable and Highly Available Messaging Broker 1 Broker 1 Producer 1 Broker 2 Broker 2 Consumer 1 Consumer 1 Producer 1 Consumer 2 Consumer 2 Broker 3 Broker 3 35

Durable and Highly Available Messaging (II) Broker 1 Broker 1 Producer 1 Broker 2 Broker 2 Consumer 1 Consumer 1 Producer 1 Broker 3 Consumer 2 Broker 3 Consumer 2 36

Replay-ability Logs never forget by keeping events in a log, we have a version control system for our data if you were to deploy a faulty program, the system might become corrupted, but it would always be recoverable sequence of events provides an audit point, so that you can examine exactly what happened rewind and reply events, once service is back and bug is fixed Rewind Service Event Hub Replay Logic State 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 37

Hold Data for Long-Term Data Retention 1. Never Broker 1 2. Time based (TTL) log.retention.{ms minutes hours} 3. Size based log.retention.bytes Producer 1 Broker 2 4. Log compaction based (entries with same key are removed): kafka-topics.sh --zookeeper zk:2181 \ --create --topic customers \ --replication-factor 1 \ --partitions 1 \ --config cleanup.policy=compact Broker 3 38

Keep Topics in Compacted Form 0 1 2 3 4 5 6 7 8 9 10 11 K1 K2 K1 K1 K3 K2 K4 K5 K5 K2 K6 K2 V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 Offset Key Value Compaction Offset Key Value 3 4 6 8 9 10 K1 K3 K4 K5 K2 K6 V4 V5 V7 V9 V10 V11 K1 K2 K3 K4 K5 K6 V4 V10 V5 V7 V9 V11 V3 V6 V8 V1 V2 39

Topic Viewed as Event Stream or State Stream (Change Log) Event Stream State Stream (Change Log Stream) 2017-10-02T20:18:46 2017-10-02T20:18:55 2017-10-02T20:18:59 2017-10-02T20:19:01 2017-10-02T20:19:02 2017-10-02T20:19:23 11,Normal,41.87,-87.67 11,Normal,40.38,-89.17 21,Normal,42.23,-91.78 21,Normal,41.71,-91.32 11,Normal,38.65,-90.2 21,Normal41.71,-91.32 11 2017-10-02T20:18:46,11,Normal,41.87,-87.67 11 2017-10-02T20:18:55,11,Normal,40.38,-89.17 21 2017-10-02T20:18:59, 21,Normal,42.23,-91.78 21 2017-10-02T20:19:01,21,Normal,41.71,-91.32 11 2017-10-02T20:19:02,11,Normal,38.65,-90.2 21 2017-10-02T20:19:23,21,Normal41.71,-91.32 40

Keep Topics both in Original and Compacted Form OR Producer TX Kafka Broker A B C B A E K A E A C K Producer Kafka Broker A B C B A E K A E A C K B E A C K B E A C K Consume and Produce 41

Change Data Capture (CDC) Legacy Microservice RDBMS cdc-source trucking_ driver Driver Topic elasticsearch -sink NoSQL 42

Enrich Stream with Static Data with Kafka Streams Movement Topic Consume and Produce Join Movement & Driver Topic Driver Topic Driver Handler Driver Table Driver Local State 43

Building Embedded, Materialized View with Kafka Streams Movement & Driver Topic Join Consume and Produce Window Aggregation Engine Metric Topic Join Store Result Store Result State Join State 44

Building Embedded, Queryable Materialized View with Kafka Streams Movement & Driver Topic Join Consume and Produce Window Aggregation API Application Engine Metric Topic Join Store Result Store Result State Join State 45

Asynchronous Microservices in Enterprise Architecture 46

Asynchronous Microservices in Enterprise Architecture Billing & Ordering CRM / Profile Marketing Campaigns File Import / SQL Import Raw Refined Hadoop Clusterd Hadoop Cluster Big Data Cluster Storage Storage Results Parallel Processing SQL Enterprise Data Warehouse BI Tools Location Mobile Apps Event Hub Event Stream Stream Analytics Cluster Search Search / Explore Social Click stream Weather Data Call Center Stream Processor State Microservice Cluster API Service Online & Mobile Apps 47 Sensor Data Event Stream Microservice State API

References 48

References Microservices Blog Series, Ben Stopford, Confluent: https://www.confluent.io/blog/tag/microservices Apache Kafka for Microservices: A Confluent Online Talk Series: https://www.confluent.io/landing-page/microservices-online-talk-series/ Turning the database inside-out with Apache Samza, Martin Kleppmann, Con https://www.confluent.io/blog/turning-the-database-inside-out-with-apache-samza/ Event sourcing, CQRS, stream processing and Apache Kafka: What s the connection?, Neha Narkhede, Confluent: https://www.confluent.io/blog/event-sourcing-cqrs-stream-processing-apache-kafka-whats-connection/ Immutability Changes Everything, Pat Helland, Salesforce: http://cidrdb.org/cidr2015/papers/cidr15_paper16.pdf Commander: Better Distributed Applications through CQRS and Event Sourcing, Bobby Calderwood: https://www.youtube.com/watch?v=b1-gs0oetyc 49

Technology on its own won't help you. You need to know how to use it properly. 50

Trivadis @ DOAG 2017 #opencompany Booth: 3rd Floor next to the escalator We share our Know how! Just come across, Live-Presentations and documents archive T-Shirts, Contest and much more We look forward to your visit 51