Have you ever imagined what it would be like to build a massively scalable streaming application on Kafka, the challenges, the patterns and the thought process involved? How much of the application can be reused? What patterns will you discover? How does it all fit together? Depending upon your use case and business, this can mean many things. Starting out with a data pipeline is one thing, but evolving into a company-wide real-time application that is business critical and entirely dependent upon a streaming platform is a giant leap. Large-scale streaming applications are also called event streaming applications. They are classically different from other data systems; event streaming applications are viewed as a series of interconnected streams that are topologically defined using stream processors; they hold state that models your use case as events. Almost like a deconstructed real-time database.
In this talk, I step through the origins of event streaming systems, understanding how they are developed from raw events to evolve into something that can be adopted at an organizational scale. I start with event-first thinking, Domain Driven Design to build data models that work with the fundamentals of Streams, Kafka Streams, KSQL and Serverless (FaaS).
Building upon this, I explain how to build common business functionality by stepping through the patterns for: – Scalable payment processing – Run it on rails: Instrumentation and monitoring – Control flow patterns Finally, all of these concepts are combined in a solution architecture that can be used at an enterprise scale. I will introduce enterprise patterns such as events-as-a-backbone, events as APIs and methods for governance and self-service. You will leave talk with an understanding of how to model events with event-first thinking, how to work towards reusable streaming patterns and most importantly, how it all fits together at scale.
4. 66
“We believe that the major
contributor to this complexity in
many systems is the handling of
state and the burden that this adds
when trying to analyse and reason
about the system.”
Out of the tar pit, 2006
6. 88
What are microservices?
Microservices are a software development
technique - a variant of the service-oriented
architecture (SOA) architectural style that
structures an application as a collection of
loosely coupled services.
https://en.wikipedia.org/wiki/Microservices
11. 13
● Scaling is hard
● Handling state is hard
● Sharing, coordinating is hard
● Run a database in each microservice - is hard
What have we learned about microservices?
22. Events
Why do you care?
Loose coupling, autonomy, evolvability, scalability, resilience, traceability, replayability
EVENT-FIRST CHANGES HOW YOU
THINK ABOUT WHAT YOU ARE BUILDING
...more importantly...
42. 49
Payments system: bounded context
[1] How much is being processed?
Expressed as:
- Count of payments inflight
- Total $ value processed
[2&3] Update the account balance
Expressed as:
- Debit
- Credit [4] Confirm successful payment
Expressed as:
- Total volume today
- Total $ amount today
52. 59
Instrumentation Plane (trust)
Goal: Prove the application is meeting business requirements
Metrics:
- Payments Inflight, Count and Dollar value
- Payment Complete, Count and Dollar value
67. {faas}
events as a backbone
appappappapp
Payments Department 2
{faas}appappappapp
Department 3 Department 4
Pattern: Events as a backbone
68. {faas}
What is going on here?
appappappapp
Payments Department 2
Patterns: Topic naming
bikeshedding (uncountable)
1. Futile investment of time and energy in
discussion of marginal technical issues.
2. Procrastination.
https://en.wiktionary.org/wiki/bikeshedding
Parkinson observed that a committee whose
job is to approve plans for a nuclear power
plant may spend the majority of its time on
relatively unimportant but easy-to-grasp
issues, such as what materials to use for the
staff bikeshed, while neglecting the design
of the power plant itself, which is far more
important but also far more difficult to
criticize constructively.
69. Patterns: Topic conventions
Don’t
1. Use fields that change
2. Use fields if data is available elsewhere
3. Tie topic names to consumers or producers
Do
<message type>.<dataset name>.<data name>
<app-context>.<message type>.<dataset name>.<data name>
Source: Chris Riccomini
https://riccomini.name/how-paint-bike-shed-kafka-topic-naming-conventions
● Logging
● Queuing
● Tracking
● etl/db
● Streaming
● Push
● user
70. 7777
What about that software crisis that started in
1968?
“We believe that the major contributor to this
complexity in many systems is the handling of state
and the burden that this adds when trying to analyse
and reason about the system.”
Out of the tar pit, 2006
71. Our mental model: Abstraction as an Art
Chained/Orchestrated
Bounded contexts
Stream processor
Stream
Event
Pillars
Business function Control plane Instrumentation Operations
Bounded context
72. Key takeaway (state)
Event streamingdriven microservices are the new atomic unit:
1. Provide simplicity (and time travel)
2. Handle state (via Kafka Streams)
3. Provide a new paradigm: convergent data and logic processing
Stream
processor
73. Key takeaway (complexity)
● Event-Streaming apps: model as bounded-context dataflows, handle
state & scaling
● Patterns: Build reusable dataflow patterns (instrumentation)
● Composition: Bounded contexts chaining and layering
● Composition: Choreography and Orchestration
The art of the event streaming application: streams, stream processors and scale
Have you ever imagined what it would be like to build a massively scalable streaming application on Kafka, the challenges, the patterns and the thought process involved? How much of the application can be reused? What patterns will you discover? How does it all fit together?Depending upon your use case and business, this can mean many things. Starting out with a data pipeline is one thing, but evolving into a company-wide real-time application that is business critical and entirely dependent upon a streaming platform is a giant leap. Large-scale streaming applications are also called event streaming applications. They are classically different from other data systems; event streaming applications are viewed as a series of interconnected streams that are topologically defined using stream processors; they hold state that models your use case as events. Almost like a deconstructed realtime database.In this talk I step through the origins of event streaming systems, understanding how they are developed from raw events to evolve into something that can be adopted at an organizational scale. I start with event-first thinking, Domain Driven Design to build data models that work with the fundamentals of Streams, Kafka Streams, KSQL and Serverless (FaaS).
Building upon this, I explain how to build common business functionality by stepping through patterns for
Scalable payment processing
Run it on rails: Instrumentation and monitoring
Control flow patterns (start, stop, pause)
Finally, all of these concepts are combined in a solution architecture that can be used at enterprise scale. I will introduce enterprise patterns such as events-as-a-backbone, events as APIs and methods for governance and self-service.
You will leave talk with an understanding of how to model events with event-first thinking, how to work towards reusable streaming patterns and most importantly, how it all fits together at scale.
The world has changed, so have we, but we still have many of the same problems
Complexity crisis since 1969
Large apps are hard - state is hard….doing stuff fast is hard
Unless you go back to first principles - events
Why events? Model the world, they are real… https://en.wikipedia.org/wiki/The_Million_Dollar_Homepage?
Events first - not event driven - event-streaming not event-driven
Event-driven microservices? - kafka events in between, time-travel, scale….
What about state…. KTables
KTable scaling - projections for CQRS or Interactive queries
Let’s build something…. Simple dataflow series of processors - payment processing -
Lets make this a picture: https://en.wikipedia.org/wiki/The_Million_Dollar_Homepage
Except…. We only have part of the picture. What about failure? Upgrades? How fast is it going? What is happening - is it working?
We need pillars to support the runtime: Instrumentation, Control, Operations
But how - remember events give us decoupling and SoC - separation of concerns
Instrumentation Pillar: what and why!
Control Pillar : what and why!
Operations Pillar : what and why!
Payment system (all 3 together)
Autoscaling based upon business metrics - instrumentation → control → business scaling up
Supporting A/B paths, logical evolution
(choreography versus orchestration)
Have we handled the complexity crisis? Have we handled scale? We only painted 1 part of the picture, a pixel on a screen.
We have provided a pattern to support architectural composition, multiple teams, decentralisation
Let’s paint more pixels - how do we do this?
Bounded context decomposition to an application, central nervous system
[microservices] 10 mins
Short history of microservices
Any language
Domain driven design
Event sourcing, domain driven design
So, what do I meant by an event?
Events are facts, immutable, accrue, many related events form a stream
Interconnected streams via stream processors
Interconnected streams via stream processors
Events -> streams -> behaviour -> what is the usecase we are modelling? What is the domain?
Interconnected streams via stream processors
Interconnected streams via stream processors
Interconnected streams via stream processors
Interconnected streams via stream processors
Interconnected streams via stream processors
Interconnected streams via stream processors
Determinism
Repeatability
Observability
Persona: Business, support, developers
Persona: Business, support, developers
Code format http://hilite.me/
Persona: Business, support, developers
Code format http://hilite.me/
Persona: Business, support, developers
Operations aren’t a new concept, however, the new age of no-ops, configuration management and automation etc encompass operational concerns under the banner of DevOps. I will limit this section and provide a view operation Operational dataflows that can be used to support this pillar. At the risk of pointing out the obvious, the Operational plane is entirely dependent on the instrumentation plane for observability, and control plane for coordination.
Application logs: Each microservice will use a log appender to selectively send log messages to a specific topic that is relevant to the application context. The log message will also contain metadata about the runtime, perhaps including the input-topic and output topic, consumer-group as well as the source event information. These logs are relevant to business events and should be tied to the bounded context..
Error/Warning logs: Similar to above, but focus on Error/Warning log events and send to relevant topic. It is also useful to build a log-context that accumulates relevant information to enrich the log message if an error/warning does occur.
Audit logs: Each microservice will capture a security context (user, group, credential, reason) as well as event-context (i.e. event-id, event-origin, source and destination topic) and emit to a relevant, contextually determined audit-log topic.
Lineage: Similar to above, except, the event will contain trace information about which processor, the context it has accessed or modified the event on its dataflow.
Dead-letter-queues: provide a place to store raw events that cannot be processed. Processing failure could be due to any number of reasons, from deserialization failure to invalid values or invalid references (join failure etc). In any case, the purpose is to provide the opportunity to become aware of the error and then fix it. The dead-letter-queue is the last failure scenario and indicative of a failing CI/CD process where a scenario has occurred that is not catered for. The dead-letter-queue should always be empty. In some cases a saga pattern will be needed to unwind the preceding state that caused the error; remember, events must be processed idempotently.
loggingFor logging data (slf4j, syslog, etc)
queuingFor classical queuing use cases.
trackingFor tracking events such as user clicks, page views, ad views, etc.
etl/dbFor ETL and CDC use cases such as database feeds.
streamingFor intermediate topics created by stream processing pipelines.
pushFor data that’s being pushed from offline (batch computation) environments into online environments.
userFor user-specific data such as scratch and test topics.
[microservices] 10 mins
Short history of microservices
Any language
Domain driven design
Event sourcing, domain driven design