a tale of queues — from activemq over hazelcast to disque - philipp krenn

62
A tale of queues from ActiveMQ over Hazelcast to Disque Philipp Krenn @xeraa

Upload: distributed-matters

Post on 23-Jan-2018

1.413 views

Category:

Data & Analytics


1 download

TRANSCRIPT

Page 1: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

A tale of queuesfrom ActiveMQ over Hazelcast to Disque

Philipp Krenn��� ���@xeraa

Page 2: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Vienna

Page 3: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Vienna

Page 4: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Vienna

Page 5: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

ViennaDBPapers We Love Vienna

Page 6: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Electronic Data Interchange EDI

Page 7: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn
Page 8: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

AutomotiveRetail

Page 9: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Transmission & message flowAS2, X.400, OFTP2, FTP, SMTP, IMAP,

web services,...

Document formatEDIFACT, X12, ODETTE, VDA,...

Page 10: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn
Page 11: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn
Page 12: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Architecture +--------+ | | +----+ | +--------+ | | | | | | | | | | +--------+ v + | | | | | | +------------> Processing +-|-|----+ | | + | | | | | +-|------+ | | | | <--------------+ +--------+ Connectors

Page 13: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn
Page 14: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Flow Camel component / protocol implementation + ^ | | | | v + Camel routing + ^ | | | | v + Queue + ^ | | | | v + Processing

Page 15: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

QueuesDecoupling producer and consumer

Page 16: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Networked message queues like ActiveMQ, RabbitMQ, ZeroMQ, and a host of other Java inspired software

tumors are crutches of systems design.— Ted Dziuba, http://widgetsandshit.com/teddziuba/2011/02/the-case-

against-queues.html

Page 17: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

"The Blocking Consumer"

Page 18: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

"Collecting Data for Offline Processing"

Page 19: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

"Everybody Loves System Complexity"

Page 20: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

There are only two hard problems in distributed systems:

2. Exactly-once delivery1. Guaranteed order of messages

2. Exactly-once delivery— Mathias Verraes, https://twitter.com/mathiasverraes/status/

632260618599403520

Page 21: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

OrderIt works like it would on a single

machinehttp://book.mixu.net/distsys/time.html

Page 22: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Exactly once

Page 23: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Removal / ACKBefore processing: at-most-onceA!er processing: at-least-once

Page 24: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

At-most-onceRequires strict consistency with

communication overheadReplicated messages and liveness

Network split — majority

Page 25: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

At-least-onceEasier to distribute

Idempotent consumptionTimeout tuning

Page 26: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

http://antirez.com/news/78antirez 430 days ago

Page 27: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

CheatingOrder

Page 28: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Cheating1. Receive

2a. Persist in RDS (MySQL)2b. Camel routing + queue

3. Acknowledge

Page 29: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

GoalsReliabilityLiveness

At-most-once

Page 30: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

MachinesWaitRetry

Page 31: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Amazon Simple Queue Service (SQS)

Fast, reliable, scalable, and fully managed

Page 32: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn
Page 33: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

But...At-least-once

64KB (now 256KB) payload

Page 34: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn
Page 35: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Master SlaveShared file system

JDBCReplicated LevelDB

+ ZooKeeper

Page 36: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

<bean id="mysql-ds" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="com.mysql.jdbc.Driver"/> <property name="jdbcUrl" value="jdbc:mysql://{{rds_hostname}}: 3306/{{rds.activemq.database}}?relaxAutoCommit=true"/> <property name="user" value="{{rds.activemq.user}}"/> <property name="password" value="{{rds.activemq.pass}}"/> <property name="acquireRetryAttempts" value="100"/> <property name="testConnectionOnCheckout" value="true"/> <property name="testConnectionOnCheckin" value="false"/> <property name="idleConnectionTestPeriod" value="3600"/> <property name="maxStatements" value="0"/> <property name="minPoolSize" value="2"/> <property name="maxPoolSize" value="20"/> <property name="maxIdleTimeExcessConnections" value="600"/> <property name="numHelperThreads" value="6"/> <property name="acquireRetryDelay" value="5000"/> <property name="maxConnectionAge" value="10800"/> <property name="preferredTestQuery" value="SELECT 1;"/></bean>

Page 37: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn
Page 38: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

RDS down !

Page 39: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn
Page 40: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn
Page 41: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

In-memory data gridSet, list, map, queue, topic, lock,

atomic long,...Query, aggregate, MapReduce

Hibernate 2nd level cache, session replication

Page 42: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Eierlegende Wollmilchsau

Page 43: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

"egg-laying wool-milk-sow"

Page 44: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

GreatDoes everything for Java apps

Multi-master HAFast

Page 45: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Bad feelingVery few queue users

Bugs with IP / DNS changesPainful upgrades

Page 46: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Currently our action is to create bug for these scenarios and try to

ensure exactly-once.— Enes Akar, https://groups.google.com/forum/#!msg/hazelcast/

u_KLHVnvT_U/Qx5Km8COk_oJ

Page 47: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

KafkaReal-time focusAt-least-once

https://cwiki.apache.org/confluence/display/KAFKA/Idempotent+Producer

Page 48: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

KestrelDead !

Page 49: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

RabbitMQToo much middleware

Page 50: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

In the event of network failure (or a node crashing), messages

can be duplicated, and consumers must be prepared to handle them.

— https://www.rabbitmq.com/reliability.html

Page 51: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn
Page 52: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

[...] no one try to use N Redis independent nodes and the

offered primitives as a building block for a distributed system [...]

— Salvatore Sanfilippo, http://antirez.com/news/78

Page 53: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Disque, an in-memory, distributed job queue

— https://github.com/antirez/disque

Page 54: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

GreatDocumentationDoes one thing

Multi-master HAConfigurable ACKSimilar to Redis

Page 55: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Driver: Spinach"A scalable Java Disque client" based

on lettuce, "A scalable Java Redis client"

Page 56: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

! !Some teething problems

Page 57: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Current configurationPer message

Replication factor: 1Retry time: 0

No persistence

Page 58: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Current useBilling since 07/2015

Full ActiveMQ replacement soon?

Page 59: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

WARNING: This is alpha code NOT suitable for production.

— https://github.com/antirez/disque

Page 60: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Nobody likes queues

Page 61: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Thank you!Questions?!

@xeraa

Page 62: A tale of queues — from ActiveMQ over Hazelcast to Disque - Philipp Krenn

Image Credit· Schnitzel https://flic.kr/p/9m27wm

· Architecture https://flic.kr/p/6dwCAe· Conchita https://flic.kr/p/nBqSHT

· Paper https://flic.kr/p/83thLf· Airli! https://commons.wikimedia.org/wiki/File:C-54landingattemplehof.jpg

· Beer https://flic.kr/p/aBSmtY· Gum https://flic.kr/p/ALQ3b

· Eierlegende Wollmilchsau https://flic.kr/p/GzQTT· British https://flic.kr/p/hzxLvw