SlideShare uma empresa Scribd logo
1 de 55
Baixar para ler offline
Synchronous Kafka
Neil Buesing
Kafka Summit 2020
@nbuesing
Synchronous Commands over Apache Kafka
Producer
Messaging
Consumer
Command/
Response
• Something that should happen
• Tell others what to do
• Presumption of a response
• Ask questions from others
Request (Command) Driven
• Something that has happened
• Tell others what you did
• No presumption of a response
• Others determine what they do
Event Driven
Quizzer
Web
Application
Single Page
Application
Load
Balancer
Application Design
Quizzer
quiz-start
quiz-next
quiz-result
quiz-submit
Builder
questions
difficulty
quiz
quiz-status
API Database
Quizzer - Streams Application
Submit
Next
Result
Quiz
Users
Aggregate
(KTable)
Questions
Difficulty
Global KTable
KTable
KTable
Start
Status
Quizzer - Streams Application
• https://events.confluent.io/meetups

• "Building a Web Application with Kafka as your
Database", March 24th, 2020

• "Interactive Kafka Streams", May 21st, 2020
Load
Balancer
Web
Application
Web Application Design
Http Status
Request (Command) Driven Event Driven
Web
Application
Web Application Design
202
Accepted
200
OK
Event Driven Design
This is not always possible
Web
Application
Web Application Design
200 OK
201 CREATE
Blocking / Command Driven Design
When redesign is not an option
• Websockets
• Server Sent Events
Web
Application
Web Application Design
202
Accepted
CQRS / Command Driven Design
200
OK
Web
Application
Web Application Design
202
Accepted
200
OK
CQRS / Command Driven Design
Command Driven Design
the legacy app / blocking
The Legacy App
Web
Application
200
OK
200
OK
• How do you block in the web
application?
• How do you ensure the correct
web application instance that
publishes to Kafka is able to
consume the response topic.
Legacy Application, expects 200/OK Response
Blocking
Blocking
waiting for the response
Blocking Options
• Techniques to block for a response message in a
JVM Application.
• Countdown Latch
• Deferred Result (Spring MVC)
Blocking - Countdown Latch
• Algorithm
• Publish to Kafka
• Block on Latch
• Release Latch (Consumer from Kafka in separate thread)
Blocking - Countdown Latch
Object waitForResponse(String requestId) {
CountDownLatch l = new CountDownLatch(1);
CountDownLatch racer = latchByRequestId.putIfAbsent(requestId, l);
if (racer != null) l = racer;
//block
boolean success = l.await(timeoutMs, TimeUnit.MILLISECONDS);
if (success) {
//remove response from shared map
return responseByRequestId.remove(requestId);
} else {
throw new CorrelationException("Timeout: " + requestId);
}
}
Blocking - Countdown Latch
void addResponse(String id, Object response) {
CountDownLatch l = new CountDownLatch(1);
CountDownLatch r = latchByRequestId.putIfAbsent(id, l);
if (r != null) l = r; //usually
//make response available for blocking thread
responseByRequestId.put(id, response);
l.countDown(); //unblock
}
Blocking - Countdown Latch
• Pros
• Standard Java code Java code (since 1.5)
• Can be used anywhere
• Cons
• Blocks request thread
• Limits incoming requests (Servlet Container)
• Increases resource consumption
Blocking - Deferred Result
• Offloads to secondary thread
• Less coding
• Specific to Spring MVC
• CompletableFuture interface supported
• Other Web frameworks have this too
Blocking - Deferred Result
Cache<String, DeferredResult> cache =
CacheBuilder.newBuilder().maximumSize(1000).build();
DeferredResult waitForResponse(String requestId) {
DeferredResult deferredResult = new DeferredResult(5000L);
cache.put(requestId, deferredResult);
return deferredResult; //no actual waiting here, spring does that.
}
Blocking - Deferred Result
void addResponse(String requestId, JsonNode resp) {
DeferredResult result = cache.getIfPresent(requestId);
if (result != null) {
ResponseEntity<JsonNode> content = new ResponseEntity<>(resp, OK);
result.setResult(content); //unblocks response
cache.invalidate(requestId);
}
}
Consuming
consume from same instance
Solutions
• Single Topic & consumer.assign()

• Topics for each Web Application

• Single Topic & consumer.subscribe()
Consuming Response Topic
Web
Application
quiz-next-0
quiz-submit
200
OK
quiz-next-1
quiz-next-2
quiz-next-3
Single Topic 

consumer.assign()
Consuming - 1 Topic & Assignment
• every Web Application assigns themselves to all partitions

• request-id in Kafka Header

• response topic must have header (automatic in Kafka Streams)

• key free for other uses, doesn't have to be the request-id

• all web applications get all messages

• discard messages where request-id doesn't exist

• don't deserialize key/value before checking header
Consuming - 1 Topic & Assignment
• Pros

• Can spin up additional web-applications w/out creating
topics

• Not limited to the number of partitions

• Correlation ID (request Id) does not have 

to be key.

• No pause with a consumer group rebalancing.
Consuming - 1 Topic & Assignment
• Cons

• Every Web Application has to consume ever message

• Have to check and deserialize request-id header
quiz-next-2quiz-next-2quiz-next-2
quiz-next-1quiz-next-1quiz-next-1
quiz-next-a-1quiz-next-a-1quiz-next-a-1
Consuming Response Topic
Web
Application
quiz-next-a-0
quiz-submit
200
OK
quiz-next-b-0
quiz-next-c-0
Multiple Topics 

Topics for each 

Web Application
Consuming - Topic / Web App
• Every web application gets its own topic

• additional header, resp-topic.

• Streaming application responds to the topic defined in
the header

• TopicNameExtractor (access to headers)

.to((k, v, context) -> 

bytesToString(context.headers().lastHeader("resp-topic").value()));
Consuming - Topic / Web App
• Pros

• Only consume messages you produced

• No pause from a consumer group rebalancing

• no additional burden or assumption on

use of key.
Consuming - Topic / Web App
• Cons

• More work on streaming application to respond to the
proper topic.

• Must create a topic for every web application
instance

• Responses spanned across multiple topics
Consuming Response Topic
Web
Application
quiz-next-0
quiz-submit
200
OK
quiz-next-1
quiz-next-2
quiz-next-3
Single Topic

consumer.subscribe()
Consuming - 1 Topic & Subscribe
• consumer.subscribe("response-topic", rebalListener)
• considerations 

• is the topic key based on data from the

incoming request?

• how sophisticated is your Load Balancer?
Consuming - 1 Topic & Subscribe
• Topic Key is known value (quiz_id vs request_id)
• route to all, "Not Me"
• Topic Key is not a known value (request_id)
• round-robin route to web-service and check 

hash before using generated key.

• Have LB generate request-id and hash

performed before routing (LB needs more info)
Load Balancer - NGINX
server {
location / {
js_content content;
}
location /rh1 {
rewrite /rh1/(.*) /$1 break;
}
location /rh2 {
rewrite /rh2/(.*) /$1 break;
}
}
}
function content(r) {
function done(res) {
if (303 !== res.status) { // "Not Me" Check
for (var h in res.headersOut) {
r.headersOut[h] = res.headersOut[h];
}
r.return(res.status, res.responseBody);
}
}
r.subrequest('/rh1' + r.uri, {
args: r.variables.args,
body: r.requestBody,
method: 'POST'},
done);
r.subrequest('/rh2' + r.uri, {
args: r.variables.args,
body: r.requestBody,
method: 'POST'},
done);
}
Consuming - 1 Topic & Subscribe
• Pros

• Leverages most common Consumer Group Pattern

• No burden on streaming applications

• KIP-429

Kafka Consumer Incremental Rebalance Protocol

• Only a single consumer processes the message
Consuming - 1 Topic & Subscribe
• Cons

• More coordination depending on topic key

• Responses paused during a rebalancing

• Partitions moving consumers on rebalance

• Key and Partitioning concerns 

minimized when using with CQRS.
Command Driven Design
the interactive application
• No need to block in Web
application.
• No need to route request back
to specific instance
• Requires Fully Accessible State
Web
Application
Command Query Responsibility Segregation
200
OK
202
Accepted
Querying
• No need to block in Web
application.
• Route request back to same
instance
• State / Web Application State
Web
Application
Command Query Responsibility Segregation
202
Accepted
200
OK
Querying
Blocking Querying
getting for the response
Leveraging Http Redirects
• 303 See Other

• Client will redirect and convert to GET

• Unfortunately, browsers handle location, so AJAX
solutions require additional work.

• CORs and allowed headers

• Build your own rules requires specific API contract
Consuming
consume from state store
State Stores
• Global State Store

• Doesn't matter which Web Service handles the query

• examples

• microservice (web service doesn't need to know)

• ksqlDB (while it might Shard the data, it is queries as a single
unit)

• any key=value datastore (Cassandra, Mongo, MemCache)
State Stores
• Embedded Shard State Store

• Need to route/reroute query to the correct Web Service

• Leverage Load Balancer

• Inter web-service communication (as in Kafka Streams Metadata
API)

• Kafka Streams Examples / Microservices / OrderService.java /
fetchFromOtherHost

https://github.com/confluentinc/kafka-streams-examples/blob/master/src/main/java/io/confluent/examples/streams/microservices/OrdersService.java



Kafka Streams State Stores
• 1 Topic & subscribe() streams consumer within Web Service

• KIPS

• KIP-429 (Kafka 2.4)

Kafka Consumer Incremental Rebalance Protocol

• Allow consumer.poll() to return data in the middle of rebalance (https://issues.apache.org/jira/
browse/KAFKA-8421) (Kafka 2.5)

• KIP-535 (Kafka 2.5)

Allow state stores to serve stale reads during rebalance

• KIP-562 (Kafka 2.5)

Allow fetching a key from a single partition rather than iterating over all the stores on an instance

• KIP-441 (Expected, Kafka 2.6)

Smooth Scaling Out for Kafka Streams
Kafka Streams State Stores
• Things to consider

• Minimize duration of data being stored

• Isolate (minimize) topologies, reduce
session.timeout.ms

• stand by replicas
ksqldb State Store
• leverage client for table queries

• Table must be created by KSQL operation

• latest_by_offset() function works well for this

• want state-stores to be self cleaning

• leverage windowing

• ksql state store queries handles all windowed stores
ksqldb State Store
create stream QUIZ_NEXT with (KAFKA_TOPIC='quiz_next', VALUE_FORMAT='avro');
create table KSQL_QUIZ_NEXT as 

select request_id, 

latest_by_offset(quiz_id) as quiz_id,

latest_by_offset(user_id) as user_id,

latest_by_offset(question_id) as question_id,

latest_by_offset(statement) as statement,

latest_by_offset(a) as a,

latest_by_offset(b) as b,

latest_by_offset(c) as c,

latest_by_offset(d) as d,

latest_by_offset(difficulty) as difficulty

from QUIZ_NEXT

window tumbling (size 30 seconds)

group by request_id;
ksqldb State Store
create stream QUIZ_RESULT with (KAFKA_TOPIC='quiz_result', VALUE_FORMAT='avro');



create table KSQL_QUIZ_RESULT as 

select request_id, 

latest_by_offset(quiz_id) as quiz_id, 

latest_by_offset(user_id) as user_id, 

latest_by_offset(user_name) as user_name, 

latest_by_offset(questions) as questions, 

latest_by_offset(correct) as correct 

from QUIZ_RESULT

window tumbling (size 30 seconds)

group by request_id;
BatchedQueryResult result = 

client.executeQuery(

"SELECT * FROM KSQL_QUIZ_NEXT where " +

"REQUEST_ID='" + requestId + "';");
List<Row> list = result.get();
int last = list.size() - 1;



map.put("quiz_id", list.get(last).getString("QUIZ_ID"));

...
ksqldb Queries
Final Thoughts
• if using consumer groups, design with rebalancing in mind.

• Explore options with your Load Balancer.

• CQRS w/ Kafka Streams as your State Store

• 2.5+

• Minimize Topology Complexity

• Minimize changelog data by leveraging windowing or proper
tombstoning.
Resources
• Book Event Driven Systems

• https://www.confluent.io/wp-content/uploads/
confluent-designing-event-driven-systems.pdf

• Source Code

• http://github.com/nbuesing/quizzer
Thanks
Kafka Summit
Confluent
Object Partners, Inc.
Questions
@nbuesing
https://buesing.dev/post/ks2020
nbuesing http://www.objectpartners.com

Mais conteúdo relacionado

Mais procurados

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisDvir Volk
 
Solving PostgreSQL wicked problems
Solving PostgreSQL wicked problemsSolving PostgreSQL wicked problems
Solving PostgreSQL wicked problemsAlexander Korotkov
 
Faster, better, stronger: The new InnoDB
Faster, better, stronger: The new InnoDBFaster, better, stronger: The new InnoDB
Faster, better, stronger: The new InnoDBMariaDB plc
 
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...HostedbyConfluent
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeperSaurav Haloi
 
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and PinotExactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and PinotFlink Forward
 
Kafka at Peak Performance
Kafka at Peak PerformanceKafka at Peak Performance
Kafka at Peak PerformanceTodd Palino
 
Performance Tuning RocksDB for Kafka Streams’ State Stores
Performance Tuning RocksDB for Kafka Streams’ State StoresPerformance Tuning RocksDB for Kafka Streams’ State Stores
Performance Tuning RocksDB for Kafka Streams’ State Storesconfluent
 
Kafka Streams State Stores Being Persistent
Kafka Streams State Stores Being PersistentKafka Streams State Stores Being Persistent
Kafka Streams State Stores Being Persistentconfluent
 
MongoDB WiredTiger Internals: Journey To Transactions
MongoDB WiredTiger Internals: Journey To TransactionsMongoDB WiredTiger Internals: Journey To Transactions
MongoDB WiredTiger Internals: Journey To TransactionsMydbops
 
Common issues with Apache Kafka® Producer
Common issues with Apache Kafka® ProducerCommon issues with Apache Kafka® Producer
Common issues with Apache Kafka® Producerconfluent
 
Percona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimizationPercona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimizationmysqlops
 
Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...Flink Forward
 
A Deep Dive into Kafka Controller
A Deep Dive into Kafka ControllerA Deep Dive into Kafka Controller
A Deep Dive into Kafka Controllerconfluent
 
ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!Guido Schmutz
 
Exactly-once Stream Processing with Kafka Streams
Exactly-once Stream Processing with Kafka StreamsExactly-once Stream Processing with Kafka Streams
Exactly-once Stream Processing with Kafka StreamsGuozhang Wang
 
Kafka Connect and Streams (Concepts, Architecture, Features)
Kafka Connect and Streams (Concepts, Architecture, Features)Kafka Connect and Streams (Concepts, Architecture, Features)
Kafka Connect and Streams (Concepts, Architecture, Features)Kai Wähner
 

Mais procurados (20)

Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Solving PostgreSQL wicked problems
Solving PostgreSQL wicked problemsSolving PostgreSQL wicked problems
Solving PostgreSQL wicked problems
 
Faster, better, stronger: The new InnoDB
Faster, better, stronger: The new InnoDBFaster, better, stronger: The new InnoDB
Faster, better, stronger: The new InnoDB
 
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
The Log of All Logs: Raft-based Consensus Inside Kafka | Guozhang Wang, Confl...
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
 
Kafka internals
Kafka internalsKafka internals
Kafka internals
 
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and PinotExactly-Once Financial Data Processing at Scale with Flink and Pinot
Exactly-Once Financial Data Processing at Scale with Flink and Pinot
 
Kafka at Peak Performance
Kafka at Peak PerformanceKafka at Peak Performance
Kafka at Peak Performance
 
Performance Tuning RocksDB for Kafka Streams’ State Stores
Performance Tuning RocksDB for Kafka Streams’ State StoresPerformance Tuning RocksDB for Kafka Streams’ State Stores
Performance Tuning RocksDB for Kafka Streams’ State Stores
 
Kafka Streams State Stores Being Persistent
Kafka Streams State Stores Being PersistentKafka Streams State Stores Being Persistent
Kafka Streams State Stores Being Persistent
 
MongoDB WiredTiger Internals: Journey To Transactions
MongoDB WiredTiger Internals: Journey To TransactionsMongoDB WiredTiger Internals: Journey To Transactions
MongoDB WiredTiger Internals: Journey To Transactions
 
Common issues with Apache Kafka® Producer
Common issues with Apache Kafka® ProducerCommon issues with Apache Kafka® Producer
Common issues with Apache Kafka® Producer
 
Envoy and Kafka
Envoy and KafkaEnvoy and Kafka
Envoy and Kafka
 
Percona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimizationPercona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimization
 
Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...Building a fully managed stream processing platform on Flink at scale for Lin...
Building a fully managed stream processing platform on Flink at scale for Lin...
 
A Deep Dive into Kafka Controller
A Deep Dive into Kafka ControllerA Deep Dive into Kafka Controller
A Deep Dive into Kafka Controller
 
Apache Kafka Best Practices
Apache Kafka Best PracticesApache Kafka Best Practices
Apache Kafka Best Practices
 
ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!ksqlDB - Stream Processing simplified!
ksqlDB - Stream Processing simplified!
 
Exactly-once Stream Processing with Kafka Streams
Exactly-once Stream Processing with Kafka StreamsExactly-once Stream Processing with Kafka Streams
Exactly-once Stream Processing with Kafka Streams
 
Kafka Connect and Streams (Concepts, Architecture, Features)
Kafka Connect and Streams (Concepts, Architecture, Features)Kafka Connect and Streams (Concepts, Architecture, Features)
Kafka Connect and Streams (Concepts, Architecture, Features)
 

Semelhante a Synchronous Commands over Apache Kafka (Neil Buesing, Object Partners, Inc) Kafka Summit 2020

Building a Web Application with Kafka as your Database
Building a Web Application with Kafka as your DatabaseBuilding a Web Application with Kafka as your Database
Building a Web Application with Kafka as your Databaseconfluent
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileAmazon Web Services Japan
 
Rails Request & Middlewares
Rails Request & MiddlewaresRails Request & Middlewares
Rails Request & MiddlewaresSantosh Wadghule
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1Mohammad Qureshi
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackChiradeep Vittal
 
How to Contribute to Apache Usergrid
How to Contribute to Apache UsergridHow to Contribute to Apache Usergrid
How to Contribute to Apache UsergridDavid M. Johnson
 
Jdbc presentation
Jdbc presentationJdbc presentation
Jdbc presentationnrjoshiee
 
Spring Cloud: API gateway upgrade & configuration in the cloud
Spring Cloud: API gateway upgrade & configuration in the cloudSpring Cloud: API gateway upgrade & configuration in the cloud
Spring Cloud: API gateway upgrade & configuration in the cloudOrkhan Gasimov
 
Building production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stackBuilding production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stackCellarTracker
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experiencereeder29
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
London React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor CharyparLondon React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor CharyparReact London Community
 
Nordic APIs - Automatic Testing of (RESTful) API Documentation
Nordic APIs - Automatic Testing of (RESTful) API DocumentationNordic APIs - Automatic Testing of (RESTful) API Documentation
Nordic APIs - Automatic Testing of (RESTful) API DocumentationRouven Weßling
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Sam Muhanguzi
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationStuart (Pid) Williams
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...Malin Weiss
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...Speedment, Inc.
 

Semelhante a Synchronous Commands over Apache Kafka (Neil Buesing, Object Partners, Inc) Kafka Summit 2020 (20)

Building a Web Application with Kafka as your Database
Building a Web Application with Kafka as your DatabaseBuilding a Web Application with Kafka as your Database
Building a Web Application with Kafka as your Database
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
Rails Request & Middlewares
Rails Request & MiddlewaresRails Request & Middlewares
Rails Request & Middlewares
 
Intro to node and mongodb 1
Intro to node and mongodb   1Intro to node and mongodb   1
Intro to node and mongodb 1
 
StackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStackStackMate - CloudFormation for CloudStack
StackMate - CloudFormation for CloudStack
 
How to Contribute to Apache Usergrid
How to Contribute to Apache UsergridHow to Contribute to Apache Usergrid
How to Contribute to Apache Usergrid
 
Jdbc presentation
Jdbc presentationJdbc presentation
Jdbc presentation
 
Exploring Relay land
Exploring Relay landExploring Relay land
Exploring Relay land
 
Spring Cloud: API gateway upgrade & configuration in the cloud
Spring Cloud: API gateway upgrade & configuration in the cloudSpring Cloud: API gateway upgrade & configuration in the cloud
Spring Cloud: API gateway upgrade & configuration in the cloud
 
Building production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stackBuilding production websites with Node.js on the Microsoft stack
Building production websites with Node.js on the Microsoft stack
 
JavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User ExperienceJavaScript Service Worker Design Patterns for Better User Experience
JavaScript Service Worker Design Patterns for Better User Experience
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
London React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor CharyparLondon React August - GraphQL at The Financial Times - Viktor Charypar
London React August - GraphQL at The Financial Times - Viktor Charypar
 
Nordic APIs - Automatic Testing of (RESTful) API Documentation
Nordic APIs - Automatic Testing of (RESTful) API DocumentationNordic APIs - Automatic Testing of (RESTful) API Documentation
Nordic APIs - Automatic Testing of (RESTful) API Documentation
 
Intro to sbt-web
Intro to sbt-webIntro to sbt-web
Intro to sbt-web
 
Gwt and rpc use 2007 1
Gwt and rpc use 2007 1Gwt and rpc use 2007 1
Gwt and rpc use 2007 1
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
How to JavaOne 2016 - Generate Customized Java 8 Code from Your Database [TUT...
 
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
JavaOne2016 - How to Generate Customized Java 8 Code from Your Database [TUT4...
 

Mais de confluent

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Santander Stream Processing with Apache Flink
Santander Stream Processing with Apache FlinkSantander Stream Processing with Apache Flink
Santander Stream Processing with Apache Flinkconfluent
 
Unlocking the Power of IoT: A comprehensive approach to real-time insights
Unlocking the Power of IoT: A comprehensive approach to real-time insightsUnlocking the Power of IoT: A comprehensive approach to real-time insights
Unlocking the Power of IoT: A comprehensive approach to real-time insightsconfluent
 
Workshop híbrido: Stream Processing con Flink
Workshop híbrido: Stream Processing con FlinkWorkshop híbrido: Stream Processing con Flink
Workshop híbrido: Stream Processing con Flinkconfluent
 
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...confluent
 
AWS Immersion Day Mapfre - Confluent
AWS Immersion Day Mapfre   -   ConfluentAWS Immersion Day Mapfre   -   Confluent
AWS Immersion Day Mapfre - Confluentconfluent
 
Eventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalkEventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalkconfluent
 
Q&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent CloudQ&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent Cloudconfluent
 
Citi TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep DiveCiti TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep Diveconfluent
 
Build real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with ConfluentBuild real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with Confluentconfluent
 
Q&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service MeshQ&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service Meshconfluent
 
Citi Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka MicroservicesCiti Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka Microservicesconfluent
 
Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3confluent
 
Citi Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging ModernizationCiti Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging Modernizationconfluent
 
Citi Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time dataCiti Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time dataconfluent
 
Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2confluent
 
Data In Motion Paris 2023
Data In Motion Paris 2023Data In Motion Paris 2023
Data In Motion Paris 2023confluent
 
Confluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with SynthesisConfluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with Synthesisconfluent
 
The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023confluent
 
The Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data StreamsThe Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data Streamsconfluent
 

Mais de confluent (20)

Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Santander Stream Processing with Apache Flink
Santander Stream Processing with Apache FlinkSantander Stream Processing with Apache Flink
Santander Stream Processing with Apache Flink
 
Unlocking the Power of IoT: A comprehensive approach to real-time insights
Unlocking the Power of IoT: A comprehensive approach to real-time insightsUnlocking the Power of IoT: A comprehensive approach to real-time insights
Unlocking the Power of IoT: A comprehensive approach to real-time insights
 
Workshop híbrido: Stream Processing con Flink
Workshop híbrido: Stream Processing con FlinkWorkshop híbrido: Stream Processing con Flink
Workshop híbrido: Stream Processing con Flink
 
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
Industry 4.0: Building the Unified Namespace with Confluent, HiveMQ and Spark...
 
AWS Immersion Day Mapfre - Confluent
AWS Immersion Day Mapfre   -   ConfluentAWS Immersion Day Mapfre   -   Confluent
AWS Immersion Day Mapfre - Confluent
 
Eventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalkEventos y Microservicios - Santander TechTalk
Eventos y Microservicios - Santander TechTalk
 
Q&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent CloudQ&A with Confluent Experts: Navigating Networking in Confluent Cloud
Q&A with Confluent Experts: Navigating Networking in Confluent Cloud
 
Citi TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep DiveCiti TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep Dive
 
Build real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with ConfluentBuild real-time streaming data pipelines to AWS with Confluent
Build real-time streaming data pipelines to AWS with Confluent
 
Q&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service MeshQ&A with Confluent Professional Services: Confluent Service Mesh
Q&A with Confluent Professional Services: Confluent Service Mesh
 
Citi Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka MicroservicesCiti Tech Talk: Event Driven Kafka Microservices
Citi Tech Talk: Event Driven Kafka Microservices
 
Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3Confluent & GSI Webinars series - Session 3
Confluent & GSI Webinars series - Session 3
 
Citi Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging ModernizationCiti Tech Talk: Messaging Modernization
Citi Tech Talk: Messaging Modernization
 
Citi Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time dataCiti Tech Talk: Data Governance for streaming and real time data
Citi Tech Talk: Data Governance for streaming and real time data
 
Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2Confluent & GSI Webinars series: Session 2
Confluent & GSI Webinars series: Session 2
 
Data In Motion Paris 2023
Data In Motion Paris 2023Data In Motion Paris 2023
Data In Motion Paris 2023
 
Confluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with SynthesisConfluent Partner Tech Talk with Synthesis
Confluent Partner Tech Talk with Synthesis
 
The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023The Future of Application Development - API Days - Melbourne 2023
The Future of Application Development - API Days - Melbourne 2023
 
The Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data StreamsThe Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data Streams
 

Último

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Synchronous Commands over Apache Kafka (Neil Buesing, Object Partners, Inc) Kafka Summit 2020

  • 1. Synchronous Kafka Neil Buesing Kafka Summit 2020 @nbuesing Synchronous Commands over Apache Kafka
  • 2. Producer Messaging Consumer Command/ Response • Something that should happen • Tell others what to do • Presumption of a response • Ask questions from others Request (Command) Driven • Something that has happened • Tell others what you did • No presumption of a response • Others determine what they do Event Driven
  • 4. API Database Quizzer - Streams Application Submit Next Result Quiz Users Aggregate (KTable) Questions Difficulty Global KTable KTable KTable Start Status
  • 5. Quizzer - Streams Application • https://events.confluent.io/meetups • "Building a Web Application with Kafka as your Database", March 24th, 2020 • "Interactive Kafka Streams", May 21st, 2020
  • 6. Load Balancer Web Application Web Application Design Http Status Request (Command) Driven Event Driven
  • 7. Web Application Web Application Design 202 Accepted 200 OK Event Driven Design This is not always possible
  • 8. Web Application Web Application Design 200 OK 201 CREATE Blocking / Command Driven Design When redesign is not an option • Websockets • Server Sent Events
  • 11. Command Driven Design the legacy app / blocking
  • 12. The Legacy App Web Application 200 OK 200 OK • How do you block in the web application? • How do you ensure the correct web application instance that publishes to Kafka is able to consume the response topic. Legacy Application, expects 200/OK Response Blocking
  • 14. Blocking Options • Techniques to block for a response message in a JVM Application. • Countdown Latch • Deferred Result (Spring MVC)
  • 15. Blocking - Countdown Latch • Algorithm • Publish to Kafka • Block on Latch • Release Latch (Consumer from Kafka in separate thread)
  • 16. Blocking - Countdown Latch Object waitForResponse(String requestId) { CountDownLatch l = new CountDownLatch(1); CountDownLatch racer = latchByRequestId.putIfAbsent(requestId, l); if (racer != null) l = racer; //block boolean success = l.await(timeoutMs, TimeUnit.MILLISECONDS); if (success) { //remove response from shared map return responseByRequestId.remove(requestId); } else { throw new CorrelationException("Timeout: " + requestId); } }
  • 17. Blocking - Countdown Latch void addResponse(String id, Object response) { CountDownLatch l = new CountDownLatch(1); CountDownLatch r = latchByRequestId.putIfAbsent(id, l); if (r != null) l = r; //usually //make response available for blocking thread responseByRequestId.put(id, response); l.countDown(); //unblock }
  • 18. Blocking - Countdown Latch • Pros • Standard Java code Java code (since 1.5) • Can be used anywhere • Cons • Blocks request thread • Limits incoming requests (Servlet Container) • Increases resource consumption
  • 19. Blocking - Deferred Result • Offloads to secondary thread • Less coding • Specific to Spring MVC • CompletableFuture interface supported • Other Web frameworks have this too
  • 20. Blocking - Deferred Result Cache<String, DeferredResult> cache = CacheBuilder.newBuilder().maximumSize(1000).build(); DeferredResult waitForResponse(String requestId) { DeferredResult deferredResult = new DeferredResult(5000L); cache.put(requestId, deferredResult); return deferredResult; //no actual waiting here, spring does that. }
  • 21. Blocking - Deferred Result void addResponse(String requestId, JsonNode resp) { DeferredResult result = cache.getIfPresent(requestId); if (result != null) { ResponseEntity<JsonNode> content = new ResponseEntity<>(resp, OK); result.setResult(content); //unblocks response cache.invalidate(requestId); } }
  • 23. Solutions • Single Topic & consumer.assign()
 • Topics for each Web Application
 • Single Topic & consumer.subscribe()
  • 25. Consuming - 1 Topic & Assignment • every Web Application assigns themselves to all partitions • request-id in Kafka Header • response topic must have header (automatic in Kafka Streams) • key free for other uses, doesn't have to be the request-id • all web applications get all messages • discard messages where request-id doesn't exist • don't deserialize key/value before checking header
  • 26. Consuming - 1 Topic & Assignment • Pros • Can spin up additional web-applications w/out creating topics • Not limited to the number of partitions • Correlation ID (request Id) does not have 
 to be key. • No pause with a consumer group rebalancing.
  • 27. Consuming - 1 Topic & Assignment • Cons • Every Web Application has to consume ever message • Have to check and deserialize request-id header
  • 29. Consuming - Topic / Web App • Every web application gets its own topic • additional header, resp-topic. • Streaming application responds to the topic defined in the header • TopicNameExtractor (access to headers)
 .to((k, v, context) -> 
 bytesToString(context.headers().lastHeader("resp-topic").value()));
  • 30. Consuming - Topic / Web App • Pros • Only consume messages you produced • No pause from a consumer group rebalancing • no additional burden or assumption on
 use of key.
  • 31. Consuming - Topic / Web App • Cons • More work on streaming application to respond to the proper topic. • Must create a topic for every web application instance • Responses spanned across multiple topics
  • 33. Consuming - 1 Topic & Subscribe • consumer.subscribe("response-topic", rebalListener) • considerations • is the topic key based on data from the
 incoming request? • how sophisticated is your Load Balancer?
  • 34. Consuming - 1 Topic & Subscribe • Topic Key is known value (quiz_id vs request_id) • route to all, "Not Me" • Topic Key is not a known value (request_id) • round-robin route to web-service and check 
 hash before using generated key. • Have LB generate request-id and hash
 performed before routing (LB needs more info)
  • 35. Load Balancer - NGINX server { location / { js_content content; } location /rh1 { rewrite /rh1/(.*) /$1 break; } location /rh2 { rewrite /rh2/(.*) /$1 break; } } } function content(r) { function done(res) { if (303 !== res.status) { // "Not Me" Check for (var h in res.headersOut) { r.headersOut[h] = res.headersOut[h]; } r.return(res.status, res.responseBody); } } r.subrequest('/rh1' + r.uri, { args: r.variables.args, body: r.requestBody, method: 'POST'}, done); r.subrequest('/rh2' + r.uri, { args: r.variables.args, body: r.requestBody, method: 'POST'}, done); }
  • 36. Consuming - 1 Topic & Subscribe • Pros • Leverages most common Consumer Group Pattern • No burden on streaming applications • KIP-429
 Kafka Consumer Incremental Rebalance Protocol • Only a single consumer processes the message
  • 37. Consuming - 1 Topic & Subscribe • Cons • More coordination depending on topic key • Responses paused during a rebalancing • Partitions moving consumers on rebalance • Key and Partitioning concerns 
 minimized when using with CQRS.
  • 38. Command Driven Design the interactive application
  • 39. • No need to block in Web application. • No need to route request back to specific instance • Requires Fully Accessible State Web Application Command Query Responsibility Segregation 200 OK 202 Accepted Querying
  • 40. • No need to block in Web application. • Route request back to same instance • State / Web Application State Web Application Command Query Responsibility Segregation 202 Accepted 200 OK Querying
  • 42. Leveraging Http Redirects • 303 See Other • Client will redirect and convert to GET • Unfortunately, browsers handle location, so AJAX solutions require additional work. • CORs and allowed headers • Build your own rules requires specific API contract
  • 44. State Stores • Global State Store • Doesn't matter which Web Service handles the query • examples • microservice (web service doesn't need to know) • ksqlDB (while it might Shard the data, it is queries as a single unit) • any key=value datastore (Cassandra, Mongo, MemCache)
  • 45. State Stores • Embedded Shard State Store • Need to route/reroute query to the correct Web Service • Leverage Load Balancer • Inter web-service communication (as in Kafka Streams Metadata API) • Kafka Streams Examples / Microservices / OrderService.java / fetchFromOtherHost https://github.com/confluentinc/kafka-streams-examples/blob/master/src/main/java/io/confluent/examples/streams/microservices/OrdersService.java
 

  • 46. Kafka Streams State Stores • 1 Topic & subscribe() streams consumer within Web Service • KIPS • KIP-429 (Kafka 2.4)
 Kafka Consumer Incremental Rebalance Protocol • Allow consumer.poll() to return data in the middle of rebalance (https://issues.apache.org/jira/ browse/KAFKA-8421) (Kafka 2.5) • KIP-535 (Kafka 2.5)
 Allow state stores to serve stale reads during rebalance • KIP-562 (Kafka 2.5)
 Allow fetching a key from a single partition rather than iterating over all the stores on an instance • KIP-441 (Expected, Kafka 2.6)
 Smooth Scaling Out for Kafka Streams
  • 47. Kafka Streams State Stores • Things to consider • Minimize duration of data being stored • Isolate (minimize) topologies, reduce session.timeout.ms • stand by replicas
  • 48. ksqldb State Store • leverage client for table queries • Table must be created by KSQL operation • latest_by_offset() function works well for this • want state-stores to be self cleaning • leverage windowing • ksql state store queries handles all windowed stores
  • 49. ksqldb State Store create stream QUIZ_NEXT with (KAFKA_TOPIC='quiz_next', VALUE_FORMAT='avro'); create table KSQL_QUIZ_NEXT as 
 select request_id, 
 latest_by_offset(quiz_id) as quiz_id,
 latest_by_offset(user_id) as user_id,
 latest_by_offset(question_id) as question_id,
 latest_by_offset(statement) as statement,
 latest_by_offset(a) as a,
 latest_by_offset(b) as b,
 latest_by_offset(c) as c,
 latest_by_offset(d) as d,
 latest_by_offset(difficulty) as difficulty
 from QUIZ_NEXT
 window tumbling (size 30 seconds)
 group by request_id;
  • 50. ksqldb State Store create stream QUIZ_RESULT with (KAFKA_TOPIC='quiz_result', VALUE_FORMAT='avro');
 
 create table KSQL_QUIZ_RESULT as 
 select request_id, 
 latest_by_offset(quiz_id) as quiz_id, 
 latest_by_offset(user_id) as user_id, 
 latest_by_offset(user_name) as user_name, 
 latest_by_offset(questions) as questions, 
 latest_by_offset(correct) as correct 
 from QUIZ_RESULT
 window tumbling (size 30 seconds)
 group by request_id;
  • 51. BatchedQueryResult result = 
 client.executeQuery(
 "SELECT * FROM KSQL_QUIZ_NEXT where " +
 "REQUEST_ID='" + requestId + "';"); List<Row> list = result.get(); int last = list.size() - 1;
 
 map.put("quiz_id", list.get(last).getString("QUIZ_ID"));
 ... ksqldb Queries
  • 52. Final Thoughts • if using consumer groups, design with rebalancing in mind. • Explore options with your Load Balancer. • CQRS w/ Kafka Streams as your State Store • 2.5+ • Minimize Topology Complexity • Minimize changelog data by leveraging windowing or proper tombstoning.
  • 53. Resources • Book Event Driven Systems • https://www.confluent.io/wp-content/uploads/ confluent-designing-event-driven-systems.pdf • Source Code • http://github.com/nbuesing/quizzer