SlideShare a Scribd company logo
Adding some Rust to your
Kafka
About me
Gerard Klijs
● @GKlijs
● https://github.com/gklijs
● Java developer with
● Used Kafka several times
● Author of
schema_registry_converter
● Living in Papendrecht
Contents
● Test setup
● 3 languages
● 4 Implementations
● Results of the tests
● Conclusion
● Questions
Bank simulation with end-to-end performance test
Overview of the whole system
Every yellow component will be explained in details. We use the schema registry
for schema management. All messages will have string as key and avro as value
type. No d
Meaning of the colors:
● Orange are the Confluent platform parts
● Yellow are the parts of open bank mark
● Green is an NginX instance
● Light blue are PostgreSQL databases
Topology
Common dependency of the other parts.
Several functions:
● One way to set the logging for all components.
● All components have knowledge over the topics and data types without
needing to connect.
● Will generate Avro object for (de)serialization.
● Functions wrapping the (Java) Kafka Consumer and Producer.
● Functions for dealing with IBAN and UUID.
Synchronizer
Makes sure both the correct topics and schema’s are set.
Checks if it’s possible to set the replication factor to what’s in the config, takes the
minimum of the available nodes and the config.
Note that this has been used only on a clean Kafka cluster, and there is currently
no check for topic properties being correct.
Heartbeat
Just a simple producer for easy debugging.
Used a simple message with just a long value.
Exposes and nrepl. A nrepl is a network repl, which can be used to execute code
remotely and get the result back. This is a powerful concept, making it possible to
apply fixes as the code runs, or interactively solve bugs. With the nrepl the pace of
the send messages can be changed.
Command generator
Consumes the heartbeats and generates a command for each received heartbeat.
This will be ConfirmAccountCreation first, as it runs there will be less of these. It
rondomly ceates different kinds of ConfirmMoneyTransfer which might fail
because it would cause the balance to become below the limit.
Command handler
Handles the different kinds of command.
● AccountCreationCommand: generates a new iban, if it not already exists
creates a balance using the default values, if it does exists gives back an
AccountCreationFailed.
● ConfirmMoneyTransfer: if the supplied token is correct, and there is enough
money, makes the transfer. Updates both to and form if they are ‘open-bank’
ibans. And creates a BalanceChanged event for each changed balance.
GraphQL-endpoint
GraphQL-endpoint
Exposes a GraphQL endpoint to make it easy to issue commands and get the
results back in the frontend. All services have there own consumer, and share the
producer and the database.
● Transaction service: makes it possible to query or subscribe to balance
changed events.
● Account creation service: used to create an account. Will link the username
used to log in with the uuid send for the account creation, in order to get the
same iban back should the user log in at another time.
● Money transfer service: tries to transfer money, and provides feedback.
Frontend
Frontend
The frontend is build on several parts that all end up in a NginX container to be
served.
● The javascript part is build using clojurescript, an important part is the re-
graph library. For clojurescript re-frame is often used, which uses react to
update the dom depending on a global state. Clojurescript is using the Google
Closure compiler to reduce the size of the resulting javascript.
● Bulma is used for the css with just the colors set differently and some
additional animations.
● The output from the tests are added to NginX to make them easily accessible.
Running a test
When the test is run it will do several kind of transaction that either increase or
lower the money on the balance in such a way as much goes in as goes out after
10 runs. It measures the time till the new balance comes in.
During the test the load of the system is increased by using the nrepl of the
heartbeat. Increasing the number of heartbeats which in turn will trigger additional
commands to be processed.
Also during the test using lispyclouds/clj-docker-client both the cpu and memory of
parts of the system are measured.
Al the data is written into a file so it can be analyzed later on.
Output a test
The generated files can be compared to other files to generate graphs.
All the data is combined, and for each point with the same load some statistics are
calculated. Most often the mean and the standard error.
For different values graphs are generated in the public folder for the frontend so
they can be easily viewed. They are available at the background tab at open-bank.
Clojure
Clojure and Kafka
● Rich Hickley is the creator and Benevolent Dictator for Life.
● Runs on the jvm, and has interop with Java.
● Cognitect is the company behind Clojure, it has several product around
Clojure, like Datomic an elastic scaling transactional database.
● Multiple recent libraries, besides the consumer and the producer sometimes
also supporting streams, the admin client and avro.
● At the time I started the project the latest Clojure was still java 6 compatible,
and there was no recent Clojure Kafka client.
● Some fuss with Jackson in combination with other libraries, using explicit
Jackson versions to make it work.
Code example producer
Code example start consuming
Kotlin
Kotlin with Spring and Kafka
● Kotin is closely tied to the IntelliJ IDEA.
● Can change java code to Kotlin automatically.
● Bit more functional then Java, and often immutable defaults.
● Spring makes it easy to set up and have something working fast.
● Getting Avro serializers to work was a puzzle, getting the right properties to
use Avro serialisation.
● With Spring Cloud Streams is using Kafka Streams Api under the hood.
● Easiest it to start on Spring Initializr.
● Make sure to use the kotlin-maven-allopen and kotlin-maven-noarg plugin to
compile.
Code example money transfer
Rust
Rust and Kafka
● System programming language with focus on safety and speed.
● Mozilla was the first investor for Rust and continues to sponsor the work of
the open source project.
● Used by dropbox in production.
● Two libraries, one that recently is getting more active, bumped to 1.0.0 of
librdkafka, another one using pure rust, but has little activity and little features.
● No support for avro when I started.
● Created library to use the schema registry to transform bytes to Value and the
other way around, and also to set a schema in the schema registry.
● Library is more low level than Java, things like logging have to be setup.
Some examples are available making it easy.
Dockerfile pure rust library
Database update
Code example money transfer
Some results of the 10 runs on TravisCI (2 cpu)
Language Clojure Kotlin Rust(rdkafka) Rust(kafka)
Docker image size (MB) 152 206 102 8
Average start (ms) 2988 12878 2222 1929
Max load reached (msg/s) 310 330 260 220
Some graphs, more available at https://open-bank.gklijs.tech/
Latency
● Rust-kafka quickly rises because only sending one message at a time.
● Rust-rdkafka goes up eventually is stressing the Kafka broker more than the
jvm languages.
● Both jvm languages are pretty close.
Cpu load Kafka broker
● Rust-kafka is causing high cpu because every message is send seperately.
● Rust-rdkafka goes up eventually is stressing the Kafka broker more than the
jvm languages, I don’t know why.
● Both jvm languages are pretty close.
Cpu command handler
● Rust-kafka is the lowest, is pretty simple and bare docker image
● Rust-rdkafka only needs slightly more.
● Clojure is pretty close to rust, after jit has kicked in.
● Kotlin jit seems effective about the same but more overhead because of
Spring.
Conclusion, use Rust when:
● Startup time is important, but other options for the JVM with GraalVM like
Quarkus or Micronaut.
● Memory footprint matters.
● A small Docker image is important.
● Memory safety is important.
But:
● Be sure to test if in your case the broker can keep up.
● What the application needs to do can be done with Rust.
● Development may take a bit longer.
Questions? Code available at open-bank-mark

More Related Content

What's hot

End to end testing a web application with Clojure
End to end testing a web application with ClojureEnd to end testing a web application with Clojure
End to end testing a web application with Clojure
Gerard Klijs
 
RESTEasy Reactive: Why should you care? | DevNation Tech Talk
RESTEasy Reactive: Why should you care? | DevNation Tech TalkRESTEasy Reactive: Why should you care? | DevNation Tech Talk
RESTEasy Reactive: Why should you care? | DevNation Tech Talk
Red Hat Developers
 
Event machine
Event machineEvent machine
Event machine
almeidaricardo
 
Ractor's speed is not light-speed
Ractor's speed is not light-speedRactor's speed is not light-speed
Ractor's speed is not light-speed
SATOSHI TAGOMORI
 
Stateful stream processing with kafka and samza
Stateful stream processing with kafka and samzaStateful stream processing with kafka and samza
Stateful stream processing with kafka and samza
George Li
 
How to manage large amounts of data with akka streams
How to manage large amounts of data with akka streamsHow to manage large amounts of data with akka streams
How to manage large amounts of data with akka streams
Igor Mielientiev
 
Let the alpakka pull your stream
Let the alpakka pull your streamLet the alpakka pull your stream
Let the alpakka pull your stream
Enno Runne
 
Introduction Apache Kafka
Introduction Apache KafkaIntroduction Apache Kafka
Introduction Apache Kafka
Joe Stein
 
Reactive database access with Slick3
Reactive database access with Slick3Reactive database access with Slick3
Reactive database access with Slick3
takezoe
 
Lessons from managing a Pulsar cluster (Nutanix)
Lessons from managing a Pulsar cluster (Nutanix)Lessons from managing a Pulsar cluster (Nutanix)
Lessons from managing a Pulsar cluster (Nutanix)
StreamNative
 
Kafka At Scale in the Cloud
Kafka At Scale in the CloudKafka At Scale in the Cloud
Kafka At Scale in the Cloud
confluent
 
Integrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetesIntegrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetes
Claus Ibsen
 
Docker and Fluentd
Docker and FluentdDocker and Fluentd
Docker and Fluentd
N Masahiro
 
Samza at LinkedIn: Taking Stream Processing to the Next Level
Samza at LinkedIn: Taking Stream Processing to the Next LevelSamza at LinkedIn: Taking Stream Processing to the Next Level
Samza at LinkedIn: Taking Stream Processing to the Next Level
Martin Kleppmann
 
All of the thing about Postman
All of the thing about PostmanAll of the thing about Postman
All of the thing about Postman
Alihossein shahabi
 
Apache pulsar
Apache pulsarApache pulsar
Apache pulsar
Kotireddy Sareddy
 
Apache samza
Apache samzaApache samza
Apache samza
Humberto Streb
 
Zero mq logs
Zero mq logsZero mq logs
Zero mq logs
Tomas Doran
 
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
Monitoring, the Prometheus Way - Julius Voltz, Prometheus Monitoring, the Prometheus Way - Julius Voltz, Prometheus
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
Docker, Inc.
 
Fluentd v1 and future at techtalk
Fluentd v1 and future at techtalkFluentd v1 and future at techtalk
Fluentd v1 and future at techtalk
N Masahiro
 

What's hot (20)

End to end testing a web application with Clojure
End to end testing a web application with ClojureEnd to end testing a web application with Clojure
End to end testing a web application with Clojure
 
RESTEasy Reactive: Why should you care? | DevNation Tech Talk
RESTEasy Reactive: Why should you care? | DevNation Tech TalkRESTEasy Reactive: Why should you care? | DevNation Tech Talk
RESTEasy Reactive: Why should you care? | DevNation Tech Talk
 
Event machine
Event machineEvent machine
Event machine
 
Ractor's speed is not light-speed
Ractor's speed is not light-speedRactor's speed is not light-speed
Ractor's speed is not light-speed
 
Stateful stream processing with kafka and samza
Stateful stream processing with kafka and samzaStateful stream processing with kafka and samza
Stateful stream processing with kafka and samza
 
How to manage large amounts of data with akka streams
How to manage large amounts of data with akka streamsHow to manage large amounts of data with akka streams
How to manage large amounts of data with akka streams
 
Let the alpakka pull your stream
Let the alpakka pull your streamLet the alpakka pull your stream
Let the alpakka pull your stream
 
Introduction Apache Kafka
Introduction Apache KafkaIntroduction Apache Kafka
Introduction Apache Kafka
 
Reactive database access with Slick3
Reactive database access with Slick3Reactive database access with Slick3
Reactive database access with Slick3
 
Lessons from managing a Pulsar cluster (Nutanix)
Lessons from managing a Pulsar cluster (Nutanix)Lessons from managing a Pulsar cluster (Nutanix)
Lessons from managing a Pulsar cluster (Nutanix)
 
Kafka At Scale in the Cloud
Kafka At Scale in the CloudKafka At Scale in the Cloud
Kafka At Scale in the Cloud
 
Integrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetesIntegrating microservices with apache camel on kubernetes
Integrating microservices with apache camel on kubernetes
 
Docker and Fluentd
Docker and FluentdDocker and Fluentd
Docker and Fluentd
 
Samza at LinkedIn: Taking Stream Processing to the Next Level
Samza at LinkedIn: Taking Stream Processing to the Next LevelSamza at LinkedIn: Taking Stream Processing to the Next Level
Samza at LinkedIn: Taking Stream Processing to the Next Level
 
All of the thing about Postman
All of the thing about PostmanAll of the thing about Postman
All of the thing about Postman
 
Apache pulsar
Apache pulsarApache pulsar
Apache pulsar
 
Apache samza
Apache samzaApache samza
Apache samza
 
Zero mq logs
Zero mq logsZero mq logs
Zero mq logs
 
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
Monitoring, the Prometheus Way - Julius Voltz, Prometheus Monitoring, the Prometheus Way - Julius Voltz, Prometheus
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
 
Fluentd v1 and future at techtalk
Fluentd v1 and future at techtalkFluentd v1 and future at techtalk
Fluentd v1 and future at techtalk
 

Similar to Rust kafka-5-2019-unskip

14th Athens Big Data Meetup - Landoop Workshop - Apache Kafka Entering The St...
14th Athens Big Data Meetup - Landoop Workshop - Apache Kafka Entering The St...14th Athens Big Data Meetup - Landoop Workshop - Apache Kafka Entering The St...
14th Athens Big Data Meetup - Landoop Workshop - Apache Kafka Entering The St...
Athens Big Data
 
Netty training
Netty trainingNetty training
Netty training
Marcelo Serpa
 
Netty training
Netty trainingNetty training
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
javier ramirez
 
Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
confluent
 
Netflix Data Pipeline With Kafka
Netflix Data Pipeline With KafkaNetflix Data Pipeline With Kafka
Netflix Data Pipeline With Kafka
Allen (Xiaozhong) Wang
 
Netflix Data Pipeline With Kafka
Netflix Data Pipeline With KafkaNetflix Data Pipeline With Kafka
Netflix Data Pipeline With Kafka
Steven Wu
 
It's Time To Stop Using Lambda Architecture
It's Time To Stop Using Lambda ArchitectureIt's Time To Stop Using Lambda Architecture
It's Time To Stop Using Lambda Architecture
Yaroslav Tkachenko
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
Eugene Yokota
 
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, Shopify
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, ShopifyIt's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, Shopify
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, Shopify
HostedbyConfluent
 
Nodejs
NodejsNodejs
Real time data pipline with kafka streams
Real time data pipline with kafka streamsReal time data pipline with kafka streams
Real time data pipline with kafka streams
Yoni Farin
 
Demo 0.9.4
Demo 0.9.4Demo 0.9.4
Demo 0.9.4
eTimeline, LLC
 
Kotlin REST & GraphQL API
Kotlin REST & GraphQL APIKotlin REST & GraphQL API
Kotlin REST & GraphQL API
Sean O'Brien
 
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
StreamNative
 
Kafka aws
Kafka awsKafka aws
Kafka aws
Ariel Moskovich
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
Rishabh Indoria
 
Streaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit LogStreaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit Log
Joe Stein
 
Distributed Tensorflow with Kubernetes - data2day - Jakob Karalus
Distributed Tensorflow with Kubernetes - data2day - Jakob KaralusDistributed Tensorflow with Kubernetes - data2day - Jakob Karalus
Distributed Tensorflow with Kubernetes - data2day - Jakob Karalus
Jakob Karalus
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
kloia
 

Similar to Rust kafka-5-2019-unskip (20)

14th Athens Big Data Meetup - Landoop Workshop - Apache Kafka Entering The St...
14th Athens Big Data Meetup - Landoop Workshop - Apache Kafka Entering The St...14th Athens Big Data Meetup - Landoop Workshop - Apache Kafka Entering The St...
14th Athens Big Data Meetup - Landoop Workshop - Apache Kafka Entering The St...
 
Netty training
Netty trainingNetty training
Netty training
 
Netty training
Netty trainingNetty training
Netty training
 
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
Como creamos QuestDB Cloud, un SaaS basado en Kubernetes alrededor de QuestDB...
 
Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
Creating Connector to Bridge the Worlds of Kafka and gRPC at Wework (Anoop Di...
 
Netflix Data Pipeline With Kafka
Netflix Data Pipeline With KafkaNetflix Data Pipeline With Kafka
Netflix Data Pipeline With Kafka
 
Netflix Data Pipeline With Kafka
Netflix Data Pipeline With KafkaNetflix Data Pipeline With Kafka
Netflix Data Pipeline With Kafka
 
It's Time To Stop Using Lambda Architecture
It's Time To Stop Using Lambda ArchitectureIt's Time To Stop Using Lambda Architecture
It's Time To Stop Using Lambda Architecture
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
 
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, Shopify
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, ShopifyIt's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, Shopify
It's Time To Stop Using Lambda Architecture | Yaroslav Tkachenko, Shopify
 
Nodejs
NodejsNodejs
Nodejs
 
Real time data pipline with kafka streams
Real time data pipline with kafka streamsReal time data pipline with kafka streams
Real time data pipline with kafka streams
 
Demo 0.9.4
Demo 0.9.4Demo 0.9.4
Demo 0.9.4
 
Kotlin REST & GraphQL API
Kotlin REST & GraphQL APIKotlin REST & GraphQL API
Kotlin REST & GraphQL API
 
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
Introducing Kafka-on-Pulsar: bring native Kafka protocol support to Apache Pu...
 
Kafka aws
Kafka awsKafka aws
Kafka aws
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Streaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit LogStreaming Processing with a Distributed Commit Log
Streaming Processing with a Distributed Commit Log
 
Distributed Tensorflow with Kubernetes - data2day - Jakob Karalus
Distributed Tensorflow with Kubernetes - data2day - Jakob KaralusDistributed Tensorflow with Kubernetes - data2day - Jakob Karalus
Distributed Tensorflow with Kubernetes - data2day - Jakob Karalus
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 

Recently uploaded

LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Crescat
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Undress Baby
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 

Recently uploaded (20)

LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
Neo4j - Product Vision and Knowledge Graphs - GraphSummit Paris
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfRevolutionizing Visual Effects Mastering AI Face Swaps.pdf
Revolutionizing Visual Effects Mastering AI Face Swaps.pdf
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 

Rust kafka-5-2019-unskip

  • 1. Adding some Rust to your Kafka
  • 2. About me Gerard Klijs ● @GKlijs ● https://github.com/gklijs ● Java developer with ● Used Kafka several times ● Author of schema_registry_converter ● Living in Papendrecht
  • 3. Contents ● Test setup ● 3 languages ● 4 Implementations ● Results of the tests ● Conclusion ● Questions
  • 4. Bank simulation with end-to-end performance test
  • 5.
  • 6. Overview of the whole system Every yellow component will be explained in details. We use the schema registry for schema management. All messages will have string as key and avro as value type. No d Meaning of the colors: ● Orange are the Confluent platform parts ● Yellow are the parts of open bank mark ● Green is an NginX instance ● Light blue are PostgreSQL databases
  • 7.
  • 8. Topology Common dependency of the other parts. Several functions: ● One way to set the logging for all components. ● All components have knowledge over the topics and data types without needing to connect. ● Will generate Avro object for (de)serialization. ● Functions wrapping the (Java) Kafka Consumer and Producer. ● Functions for dealing with IBAN and UUID.
  • 9.
  • 10. Synchronizer Makes sure both the correct topics and schema’s are set. Checks if it’s possible to set the replication factor to what’s in the config, takes the minimum of the available nodes and the config. Note that this has been used only on a clean Kafka cluster, and there is currently no check for topic properties being correct.
  • 11.
  • 12. Heartbeat Just a simple producer for easy debugging. Used a simple message with just a long value. Exposes and nrepl. A nrepl is a network repl, which can be used to execute code remotely and get the result back. This is a powerful concept, making it possible to apply fixes as the code runs, or interactively solve bugs. With the nrepl the pace of the send messages can be changed.
  • 13.
  • 14. Command generator Consumes the heartbeats and generates a command for each received heartbeat. This will be ConfirmAccountCreation first, as it runs there will be less of these. It rondomly ceates different kinds of ConfirmMoneyTransfer which might fail because it would cause the balance to become below the limit.
  • 15.
  • 16. Command handler Handles the different kinds of command. ● AccountCreationCommand: generates a new iban, if it not already exists creates a balance using the default values, if it does exists gives back an AccountCreationFailed. ● ConfirmMoneyTransfer: if the supplied token is correct, and there is enough money, makes the transfer. Updates both to and form if they are ‘open-bank’ ibans. And creates a BalanceChanged event for each changed balance.
  • 18. GraphQL-endpoint Exposes a GraphQL endpoint to make it easy to issue commands and get the results back in the frontend. All services have there own consumer, and share the producer and the database. ● Transaction service: makes it possible to query or subscribe to balance changed events. ● Account creation service: used to create an account. Will link the username used to log in with the uuid send for the account creation, in order to get the same iban back should the user log in at another time. ● Money transfer service: tries to transfer money, and provides feedback.
  • 19.
  • 20.
  • 21.
  • 23. Frontend The frontend is build on several parts that all end up in a NginX container to be served. ● The javascript part is build using clojurescript, an important part is the re- graph library. For clojurescript re-frame is often used, which uses react to update the dom depending on a global state. Clojurescript is using the Google Closure compiler to reduce the size of the resulting javascript. ● Bulma is used for the css with just the colors set differently and some additional animations. ● The output from the tests are added to NginX to make them easily accessible.
  • 24.
  • 25. Running a test When the test is run it will do several kind of transaction that either increase or lower the money on the balance in such a way as much goes in as goes out after 10 runs. It measures the time till the new balance comes in. During the test the load of the system is increased by using the nrepl of the heartbeat. Increasing the number of heartbeats which in turn will trigger additional commands to be processed. Also during the test using lispyclouds/clj-docker-client both the cpu and memory of parts of the system are measured. Al the data is written into a file so it can be analyzed later on.
  • 26.
  • 27. Output a test The generated files can be compared to other files to generate graphs. All the data is combined, and for each point with the same load some statistics are calculated. Most often the mean and the standard error. For different values graphs are generated in the public folder for the frontend so they can be easily viewed. They are available at the background tab at open-bank.
  • 29. Clojure and Kafka ● Rich Hickley is the creator and Benevolent Dictator for Life. ● Runs on the jvm, and has interop with Java. ● Cognitect is the company behind Clojure, it has several product around Clojure, like Datomic an elastic scaling transactional database. ● Multiple recent libraries, besides the consumer and the producer sometimes also supporting streams, the admin client and avro. ● At the time I started the project the latest Clojure was still java 6 compatible, and there was no recent Clojure Kafka client. ● Some fuss with Jackson in combination with other libraries, using explicit Jackson versions to make it work.
  • 31. Code example start consuming
  • 33. Kotlin with Spring and Kafka ● Kotin is closely tied to the IntelliJ IDEA. ● Can change java code to Kotlin automatically. ● Bit more functional then Java, and often immutable defaults. ● Spring makes it easy to set up and have something working fast. ● Getting Avro serializers to work was a puzzle, getting the right properties to use Avro serialisation. ● With Spring Cloud Streams is using Kafka Streams Api under the hood. ● Easiest it to start on Spring Initializr. ● Make sure to use the kotlin-maven-allopen and kotlin-maven-noarg plugin to compile.
  • 34.
  • 35. Code example money transfer
  • 36. Rust
  • 37. Rust and Kafka ● System programming language with focus on safety and speed. ● Mozilla was the first investor for Rust and continues to sponsor the work of the open source project. ● Used by dropbox in production. ● Two libraries, one that recently is getting more active, bumped to 1.0.0 of librdkafka, another one using pure rust, but has little activity and little features. ● No support for avro when I started. ● Created library to use the schema registry to transform bytes to Value and the other way around, and also to set a schema in the schema registry. ● Library is more low level than Java, things like logging have to be setup. Some examples are available making it easy.
  • 40. Code example money transfer
  • 41. Some results of the 10 runs on TravisCI (2 cpu) Language Clojure Kotlin Rust(rdkafka) Rust(kafka) Docker image size (MB) 152 206 102 8 Average start (ms) 2988 12878 2222 1929 Max load reached (msg/s) 310 330 260 220
  • 42. Some graphs, more available at https://open-bank.gklijs.tech/
  • 43. Latency ● Rust-kafka quickly rises because only sending one message at a time. ● Rust-rdkafka goes up eventually is stressing the Kafka broker more than the jvm languages. ● Both jvm languages are pretty close.
  • 44.
  • 45. Cpu load Kafka broker ● Rust-kafka is causing high cpu because every message is send seperately. ● Rust-rdkafka goes up eventually is stressing the Kafka broker more than the jvm languages, I don’t know why. ● Both jvm languages are pretty close.
  • 46.
  • 47. Cpu command handler ● Rust-kafka is the lowest, is pretty simple and bare docker image ● Rust-rdkafka only needs slightly more. ● Clojure is pretty close to rust, after jit has kicked in. ● Kotlin jit seems effective about the same but more overhead because of Spring.
  • 48.
  • 49. Conclusion, use Rust when: ● Startup time is important, but other options for the JVM with GraalVM like Quarkus or Micronaut. ● Memory footprint matters. ● A small Docker image is important. ● Memory safety is important. But: ● Be sure to test if in your case the broker can keep up. ● What the application needs to do can be done with Rust. ● Development may take a bit longer.
  • 50. Questions? Code available at open-bank-mark

Editor's Notes

  1. bla
  2. bla