Serverless functions or FaaS are all the rage.
By leveraging well established event-driven microservice design principles and applying them to serverless functions you can build a homogenous ecosystem to run FaaS applications. Kafka’s natural ability to store and replay events means serverless functions can not only be replayed, but they can also be used to choreograph call chains or driven using orchestration. Kafka also means you can democratize and organize FaaS environments in a way that scales across the enterprise. Underpinning this mantra is the use of Cloud Events by the CNCF serverless working group (of which Confluent is an active member).
3. 33
The New Business Reality
Past
Technology was
Innovation required for growth
Running the business on yesterday’s data was
“good enough”
Today
Technology
Innovation required for survival
Yesterday’s data = failure.
Modern, real-time data infrastructure
is required.
11. 1111
“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
15. 1515
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
16. 1616
structures an application as a collection of
loosely coupled services.
https://en.wikipedia.org/wiki/Microservices
this is new!
22. 22
● 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?
23. 2323
Microservices
We had it all wrong (again)
FIX: Make them asynchronous and use
streams of events
We didn’t really
know what they
were anyway
34. 34
Time travel user experience?
how many users
affected?has it happened
before?
Ask many questions of the same data, again and again
time
35. 35
Evolvability
user experience?
how many users
affected?
has it happened
before?
new old
supports data change, logic change, logic extension, schema
evolution, loose coupling, add processors, A/B path
36. {
user: 100
type: bid
item: 389
cat: bikes/mtb
region: dc-east
}
Kafka partitions give you horizontal scale
/bikes/ by item-id
key#
Key
space
{...}
{...}
{...}
Topic
Partition
Partition
assignment
Stream
processor
FaaS
function
38. 3838
Rate of adoption
● Serverless is the top-growing extended cloud service for the
second year in a row, with a 50 percent growth over 2018
24 to 36 percent adoption.
● Stream processing is tied for first, increasing from
20 to 30 percent adoption.
Rightscale cloud report 2019
55. 55
Kafka Streams: Fan out
{
StreamsBuilder builder = new StreamsBuilder();
KStream<String, Payment> incoming = builder.stream(TASK_TOPIC);
incoming.flatMapValues(payment -> {
ArrayList<String> fanTasks = new ArrayList<>();
for (int i = 0; i < payment.getAmount(); i++) {
fanTasks.add("fan-" + i);
}
return fanTasks;
}
).to(TASK_FANOUT); flatMapValues: Many V to the same K
Or
flatMap: Many K,V to one K,V pair
57. Streaming events to FaaS: Fan-out Fan-in
{...}
{...}
{...}
{ bid:100; sold:1000;}
/bid-history
{
stream-lib.TDigest(values[])
}
{
stream-lib.TDigest(values[])
}
{
stream-lib.TDigest(values[])
}
Calculating percentiles using a ‘unit-of-work’ pattern
{
digest.merge(digest)
}
Stream processor with
a session window to
join related events by
key (k, v[1-10])
Stream
processor
fan out is natural (data-driven)
OR
use a Stream processor flatMap()
59. {faas}
Central nervous system
appappappapp
Payments Department 2
{faas}appappappapp
Department 3 Department 4
Pattern: Central nervous system
Choreography
Choreography
Orchestration
Hierarchical topic naming
60. {faas}
What is the message format James?
appappappapp
Payments Department 2
Cloud Events: bringing order to chaos
I’m so confused!
63. ● Specification (an Event envelope)
● Transport Bindings (Kafka, AMQP, HTTP others)
● SDKs: Java, .NET, Go-lang etc
● Still early - nearly version 1.0
● Useful for exposing to external apps (Events as APIs)
● Support is coming for Kafka SerDes and CE.clients (sdk)
CloudEvents is a specification for describing event data in common formats
to provide interoperability across services, platforms and systems.
You will adopt CloudEvents
64. 6464
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