Let's build event-driven application in 15 minu...

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Let's build event-driven application in 15 minutes - introduction to Watermill

Building event-driven applications should be as easy as building HTTP API - this was our goal when we were starting to work on Watermill.

During the talk, I would like to tell you the story of how we created one of the most popular libraries for building event-driven applications in Go. I will not end with the theory - I will do a quick live coding to show you how to use Watermill. The application will be independent of any Pub/Sub implementation and will be able to work with RabbitMQ, Kafka or even MySQL without many changes.

Robert Laszczak

April 26, 2020

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

43 slides
  1. roblaszczak About me • I’m Robert ;-) • Tech Lead

    @ • Blogging at https://threedots.tech/ • @roblaszczak at
  2. roblaszczak Building applications based on Kafka is not easy •

    Consumer groups • Partitioning • At-least-once delivery • Message Ack and Nack support • Not losing any message
  3. roblaszczak Unix philosophy (1978) • Write programs that do one

    thing and do it well. • Write programs to work together. • Write programs to handle text streams message, because that is a universal interface.
  4. roblaszczak type Publisher interface { Publish(topic string, messages ...*Message) error

    Close() error } type Subscriber interface { Subscribe(ctx context.Context, topic string) (<-chan *Message, error) Close() error }
  5. roblaszczak func TestPublishSubscribe(t *testing.T) { features := tests.Features{ ConsumerGroups: true,

    ExactlyOnceDelivery: false, GuaranteedOrder: false, Persistent: true, } tests.TestPubSub( t, features, createPubSub, createPubSubWithConsumerGrup, ) }
  6. roblaszczak var stressTestTestsCount = 10 func TestPubSubStressTest( t *testing.T, features

    Features, pubSubConstructor PubSubConstructor, consumerGroupPubSubConstructor ConsumerGroupPubSubConstructor, ) { for i := 0; i < stressTestTestsCount; i++ { t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { t.Parallel() TestPubSub(t, features, pubSubConstructor, consumerGroupConstructor) }) } }
  7. roblaszczak Pub/Sub Publish (messages / s)* Subscribe (messages / s)*

    Kafka 70,252 117,529 NATS 76,208 38,169 SQL (MySQL) 6,989 143 Google Cloud Pub/Sub 7,416 39,591 AMQP 2,408 10,608 *1 instance, 1 process, Docker Compose
  8. roblaszczak Pub/Sub Publish (messages / s) Subscribe (messages / s)

    Kafka 70,252 117,529 NATS 76,208 38,169 SQL (MySQL) 6,989 143 Google Cloud Pub/Sub 7,416 39,591 AMQP 2,408 10,608
  9. roblaszczak Pub/Sub Publish (messages / s) Subscribe (messages / s)

    Kafka 70,252 117,529 NATS 76,208 38,169 SQL (MySQL) 6,989 143 Google Cloud Pub/Sub 7,416 39,591 AMQP 2,408 10,608
  10. roblaszczak Pub/Sub Publish (messages / s) Subscribe (messages / s)

    Kafka 70,252 117,529 NATS 76,208 38,169 SQL (MySQL) 6,989 143 Google Cloud Pub/Sub 7,416 39,591 AMQP 2,408 10,608
  11. roblaszczak Not covered • It’s hard to show everything in

    13 minutes :) • Kafka and Google Cloud Pub/Sub internals • At-least-once delivery • CQRS component • Middlewares
  12. roblaszczak Small announcement: new articles on the blog • DDD,

    CQRS, Clean/Hexagonal Architecture/Event Storming • Focused on solving real issues instead of blindly applying patterns • Done by refactoring a real Go project!

More Decks by Robert Laszczak

Other Decks in Technology