throughput high concurrency & using mqtt and kafka

40
High Concurrency & Throughput Using MQTT and Kafka by Evan Purnama (Co-Founder, CTO Qiscus Pte Ltd)

Upload: others

Post on 14-Feb-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Throughput High Concurrency & Using MQTT and Kafka

High Concurrency & Throughput Using MQTT and Kafka

by Evan Purnama (Co-Founder, CTO Qiscus Pte Ltd)

Page 2: Throughput High Concurrency & Using MQTT and Kafka

Introduction

Page 3: Throughput High Concurrency & Using MQTT and Kafka

What is Qiscus?

We are a startup company that help other companies to enable conversations.

Page 4: Throughput High Concurrency & Using MQTT and Kafka

What is Qiscus?

Page 5: Throughput High Concurrency & Using MQTT and Kafka

What is Qiscus?

Page 6: Throughput High Concurrency & Using MQTT and Kafka

What is Qiscus?

Page 7: Throughput High Concurrency & Using MQTT and Kafka

Future of Technology

Page 8: Throughput High Concurrency & Using MQTT and Kafka

Future of Technology

Page 9: Throughput High Concurrency & Using MQTT and Kafka

Future of Technology

Page 10: Throughput High Concurrency & Using MQTT and Kafka

All Of Those Translate to ...

Page 11: Throughput High Concurrency & Using MQTT and Kafka

Huge Concurrent Connections

Page 12: Throughput High Concurrency & Using MQTT and Kafka

Huge Number of Messages Being

Processed

Page 13: Throughput High Concurrency & Using MQTT and Kafka
Page 14: Throughput High Concurrency & Using MQTT and Kafka

MQTT (Message Queuing Telemetry Transport)

- Created at 1999 by IBM.- Optimised for constrained environment.- Being used for communicate in rural/offshore area.

Page 15: Throughput High Concurrency & Using MQTT and Kafka

Pub Sub

Page 16: Throughput High Concurrency & Using MQTT and Kafka

MQTT

- Broker and Client (Publisher & Subscriber). - Highly Scalable Architecture- Broker become Single Point of Failure (SPoF).

- Both publishers and subscribers are very simple- Lightweight ( ~ few bytes overhead per message)- Very little resources on client side

- MQTT Broker is complex while the client is thin- Suitable for constrained environment

Page 17: Throughput High Concurrency & Using MQTT and Kafka

MQTT

- Reliable- QoS 0, 1, 2- Last Will & Testament Messages

- Secure- Username & Password- TLS

Page 18: Throughput High Concurrency & Using MQTT and Kafka

Components of MQTT

- Publisher and Subscriber- Topics- Message- QoS- Broker- etc.

Page 19: Throughput High Concurrency & Using MQTT and Kafka

Topics

- “Address” for client side to Publish or Subscribe.- Patterns :

- foo/abc/bar- foo/+/bar- foo/#

- Creating topic is cheap.- Use topic for specific event instead of general event.

Page 20: Throughput High Concurrency & Using MQTT and Kafka

Broker

- Open Source Based- Mosquitto- EMQ- Mosca- VerneMQ

- Managed Service MQTT Broker

Page 21: Throughput High Concurrency & Using MQTT and Kafka

Scaling Goal

Page 22: Throughput High Concurrency & Using MQTT and Kafka

Scaling Goals

- Connect as many connected users/devices as possible.- Handle as many throughput as possible

Page 23: Throughput High Concurrency & Using MQTT and Kafka

Scaling Goals

- Cloud based (AWS, GCP, etc)- Horizontal Scaling

- reduce cost- plan for future- less impact downtime

Page 24: Throughput High Concurrency & Using MQTT and Kafka

Concurrent Connections

Publisher Publisher Publisher Subscriber Subscriber Subscriber

Single MQTTBroker

Page 25: Throughput High Concurrency & Using MQTT and Kafka

Scaling Concurrent Connections

Publisher Publisher Publisher Subscriber Subscriber Subscriber

MQTTBroker 2

MQTTBroker 1

Page 26: Throughput High Concurrency & Using MQTT and Kafka

Scaling Concurrent Connections

Publisher Publisher Publisher Subscriber Subscriber Subscriber

MQTTBroker 2

MQTTBroker 1

Shared Memory Data

Page 27: Throughput High Concurrency & Using MQTT and Kafka

Scaling Concurrent Connections

Publisher Publisher Publisher Subscriber Subscriber Subscriber

MQTTBroker 2

MQTTBroker 1

Page 28: Throughput High Concurrency & Using MQTT and Kafka

Scaling Concurrent Connections

Page 29: Throughput High Concurrency & Using MQTT and Kafka

Load Balancing

- Which broker to connect to?- DNS Load Balancing.

Page 30: Throughput High Concurrency & Using MQTT and Kafka

High Concurrent Connections

Publisher Publisher Publisher Subscriber Subscriber Subscriber

MQTTBroker 2

MQTTBroker 1

DNS Load Balancer

Page 31: Throughput High Concurrency & Using MQTT and Kafka

Message Processing

Page 32: Throughput High Concurrency & Using MQTT and Kafka

Message Processing

Page 33: Throughput High Concurrency & Using MQTT and Kafka

Message Processing

Publisher

Publisher

Publisher

Publisher

Publisher

ClusterBroker MQTT

Subscriber

Subscriber

DB

Elastic Search

Push Notif, etc

Page 34: Throughput High Concurrency & Using MQTT and Kafka

Message Processing

- Sending to multiple destinations from the same instance that receiving very huge throughput is not a scalable approach.

- Adding more component means need to add to all of the subscribers.- What if one of the component suddenly become unavailable?

- Data lost?- Subscriber need to replay?

Page 35: Throughput High Concurrency & Using MQTT and Kafka

Kafka

- Unified, high-throughput, low-latency platform for handling real-time data feeds.

- Highly scalable stream, with throughput up to ~200k-300k for single node.

- Originally from LinkedIn, to solve Log Aggregation problems.- Zoo-Keeper- Publisher, Consumer, Topic, Partition concept.- Very scalable server-to-server messaging system.

Page 36: Throughput High Concurrency & Using MQTT and Kafka

Kafka

Page 37: Throughput High Concurrency & Using MQTT and Kafka

Scalable Message Processing

Publisher

Publisher

Publisher

Publisher

Publisher

ClusterBroker MQTT

DB

Elastic Search

Push Notif, etc

Subscriber

Subscriber

ClusterKafka

Page 38: Throughput High Concurrency & Using MQTT and Kafka

Notes :

- This strategy is only suitable for burst- need to make sure that the “consumer” able to catch-up to process

the input stream.- Kafka becoming Single Point of Failure (SPoF) on message processing,

be careful with this. Make sure to setup properly and make it High Availability (HA).

Page 39: Throughput High Concurrency & Using MQTT and Kafka

Thank You

Page 40: Throughput High Concurrency & Using MQTT and Kafka

References :

- https://blog.qiscus.com/handle-10-million-concurrent-user-connections-5-millions-messages-per-minute-throughput/

- https://www.youtube.com/watch?v=WFfciQ1U_lU

- https://www.csoonline.com/article/3346082/what-is-shadow-iot-how-to-mitigate-the-risk.html

- https://www.fastcompany.com/4011195/this-ibm-smart-bus-comes-with-a-watson-powered-assistant

- https://youngster.id/featured/vendor-telekomunikasi-berperan-penting-dalam-melindungi-smart-home/