SlideShare a Scribd company logo
Building a Distributed
Data Ingestion System
with RabbitMQ
Alvaro Videla - RabbitMQ
Alvaro Videla
• Developer Advocate at Pivotal / RabbitMQ!
• Co-Author of RabbitMQ in Action!
• Creator of the RabbitMQ Simulator!
• Blogs about RabbitMQ Internals: http://videlalvaro.github.io/internals.html!
• @old_sound — alvaro@rabbitmq.com — github.com/videlalvaro

About Me
Co-authored!
!
RabbitMQ in Action!
http://bit.ly/rabbitmq
About this Talk
• Exploratory Talk
• A ‘what could be done’ talk instead of ‘this is how you do it’
Agenda
• Intro to RabbitMQ
• The Problem
• Solution Proposal
• Improvements
Intermission
Intermission
History Lessons
The Hungarian Connection
The Hungarian Connection
• I’m from Uruguay
The Hungarian Connection
• I’m from Uruguay	

• I live in Switzerland
The Hungarian Connection
• I’m from Uruguay	

• I live in Switzerland	

• I’m in Hungary right now
WHAT?
The Hungarian Connection
The Hungarian Connection
Switzerland World Cup - 1954
The Hungarian Connection
Switzerland World Cup - 1954
The Hungarian Connection
Switzerland World Cup - 1954
Hungary 4 - Uruguay 2
The Hungarian Connection II
Tivadar Puskás
Telephone Switch Inventor
The Hungarian Connection III
Old Hungarian Alphabet
The Hungarian Connection III
Erlang
The Hungarian Connection III
As Neumann János Lajos said
The Hungarian Connection III
As Neumann János Lajos said
Use Erlang
What is RabbitMQ
RabbitMQ
RabbitMQ
RabbitMQ
• Multi Protocol Messaging Server
• Multi Protocol Messaging Server!
• Open Source (MPL)
RabbitMQ
• Multi Protocol Messaging Server!
• Open Source (MPL)!
• Polyglot
RabbitMQ
• Multi Protocol Messaging Server!
• Open Source (MPL)!
• Polyglot!
• Written in Erlang/OTP
RabbitMQ
Multi Protocol
http://bit.ly/rmq-protocols
http://www.rabbitmq.com/community-plugins.html
Community Plugins
Polyglot
Polyglot
Polyglot
• Java
Polyglot
• Java!
• node.js
Polyglot
• Java!
• node.js!
• Erlang
Polyglot
• Java!
• node.js!
• Erlang!
• PHP
Polyglot
• Java!
• node.js!
• Erlang!
• PHP!
• Ruby
Polyglot
• Java!
• node.js!
• Erlang!
• PHP!
• Ruby!
• .Net
Polyglot
• Java!
• node.js!
• Erlang!
• PHP!
• Ruby!
• .Net!
• Haskell
Polyglot
Even COBOL!!!11
Some users of RabbitMQ
• Instagram
Some users of RabbitMQ
• Instagram!
• Indeed.com
Some users of RabbitMQ
• Instagram!
• Indeed.com!
• Telefonica
Some users of RabbitMQ
• Instagram!
• Indeed.com!
• Telefonica!
• Mercado Libre
Some users of RabbitMQ
• Instagram!
• Indeed.com!
• Telefonica!
• Mercado Libre!
• NHS
Some users of RabbitMQ
• Instagram!
• Indeed.com!
• Telefonica!
• Mercado Libre!
• NHS!
• Mozilla
Some users of RabbitMQ
The NewYork Times on RabbitMQ
This architecture - Fabrik - has dozens of RabbitMQ instances
spread across 6 AWS zones in Oregon and Dublin.
Upon launch today, the system autoscaled to ~500,000 users.
Connection times remained flat at ~200ms.
http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2014-January/032943.html
http://www.rabbitmq.com/download.html
Unix - Mac - Windows
Messaging with RabbitMQ
A demo with the RabbitMQ Simulator
https://github.com/RabbitMQSimulator/RabbitMQSimulator
http://tryrabbitmq.com
RabbitMQ Simulator
The Problem
Distributed Application
App
App
App
App
Distributed Application
App
App
App
App
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
!
Connection connection = factory.newConnection();
!
Channel channel = connection.createChannel();
Data Producer
Obtain a Channel
channel.exchangeDeclare(EXCHANGE_NAME, "direct", true);
Data Producer
Declare an Exchange
String message = "Hello Federation!";
channel.basicPublish(EXCHANGE_NAME, "", null,
message.getBytes());
Data Producer
Publish a message
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
!
Connection connection = factory.newConnection();
!
Channel channel = connection.createChannel();
Data Consumer
Obtain a Channel
channel.queueDeclare(QUEUE_NAME, true, false, false,
null);
channel.exchangeDeclare(EXCHANGE_NAME, "direct", true);
channel.queueBind(QUEUE_NAME, EXCHANGE_NAME, "");
Data Consumer
Declare Queue and bind it
QueueingConsumer consumer = new
QueueingConsumer(channel);
channel.basicConsume(QUEUE_NAME, false, consumer);
Data Consumer
Start a consumer
while (true) {
QueueingConsumer.Delivery delivery =
consumer.nextDelivery();
String message = new String(delivery.getBody());
System.out.println("Received '" + message + "'");
!
channel.basicAck(
delivery.getEnvelope().
getDeliveryTag(), false);
}
Data Consumer
Process messages
Ad-hoc solution
A process that replicates data
to the remote server
Possible issues
• Remote server is offline
• Prevent unbounded local buffers
• Prevent message loss
• Prevent unnecessary message replication
• No need for those messages on remote server
• Messages that became stale
Can we do better?
RabbitMQ Federation
RabbitMQ Federation
• Supports replication across different administrative domains
• Supports mix of Erlang and RabbitMQ versions
• Supports Network Partitions
• Specificity - not everything has to be federated
RabbitMQ Federation
RabbitMQ Federation
RabbitMQ Federation
RabbitMQ Federation
• It’s a RabbitMQ Plugin
RabbitMQ Federation
• It’s a RabbitMQ Plugin
• Internally uses Queues and Exchanges Decorators
RabbitMQ Federation
• It’s a RabbitMQ Plugin
• Internally uses Queues and Exchanges Decorators
• Managed using Parameters and Policies
Enabling the Plugin
rabbitmq-plugins enable rabbitmq_federation
Enabling the Plugin
rabbitmq-plugins enable rabbitmq_federation
rabbitmq-plugins enable rabbitmq_federation_management
Federating an Exchange
rabbitmqctl set_parameter federation-upstream my-upstream 
‘{“uri":"amqp://server-name","expires":3600000}'
Federating an Exchange
rabbitmqctl set_parameter federation-upstream my-upstream 
‘{“uri":"amqp://server-name","expires":3600000}'
!
rabbitmqctl set_policy --apply-to exchanges federate-me "^amq." 
'{"federation-upstream-set":"all"}'
Federating an Exchange
Configuring Federation
Config Options
rabbitmqctl set_parameter federation-upstream 
name ‘json-object’
Config Options
rabbitmqctl set_parameter federation-upstream 
name ‘json-object’
!
json-object: {
‘uri’: ‘amqp://server-name/’,
‘prefetch-count’: 1000,
‘reconnect-delay’: 1,
‘ack-mode’: on-confirm
}
http://www.rabbitmq.com/federation-reference.html
Prevent unbound buffers
expires: N // ms.
message-ttl: N // ms.
Prevent message forwarding
max-hops: N
Speed vs No Message Loss
ack-mode: on-confirm
ack-mode: on-publish
ack-mode: no-ack
AMQP URI:
amqp://user:pass@host:10000/vhost
http://www.rabbitmq.com/uri-spec.html
Config can be applied via
• CLI using rabbitmqctl
• HTTP API
• RabbitMQ Management Interface
RabbitMQ Federation
Scaling the Setup
The Problem
The Problem
• Queues contents live in the node where the Queue was declared
The Problem
• Queues contents live in the node where the Queue was declared
• A cluster can access the queue from every connected node
The Problem
• Queues contents live in the node where the Queue was declared
• A cluster can access the queue from every connected node
• Queues are an Erlang process (tied to one core)
The Problem
• Queues contents live in the node where the Queue was declared
• A cluster can access the queue from every connected node
• Queues are an Erlang process (tied to one core)
• Adding more nodes doesn’t really help
Enter Sharded Queues
Enter Sharded Queues
Pieces of the Puzzle
• modulo hash exchange (consistent hash works as well)
• good ol’ queues
Sharded Queues
Sharded Queues
Sharded Queues
Sharded Queues
Sharded Queues
• Declare Queues with name: nodename.queuename.index
Sharded Queues
• Declare Queues with name: nodename.queuename.index
• Bind the queues to a consistent hash exchange
Sharded Queues
• Declare Queues with name: nodename.queuename.index
• Bind the queues to a partitioner exchange
• Transparent to the consumer (virtual queue name)
We need more scale!
Federated Queues
Federated Queues
• Load-balance messages across federated queues
• Only moves messages when needed
Federating a Queue
rabbitmqctl set_parameter federation-upstream my-upstream 
‘{“uri":"amqp://server-name","expires":3600000}'
Federating a Queue
rabbitmqctl set_parameter federation-upstream my-upstream 
‘{“uri":"amqp://server-name","expires":3600000}'
!
rabbitmqctl set_policy --apply-to queues federate-me "^images." 
'{"federation-upstream-set":"all"}'
With RabbitMQ we can
With RabbitMQ we can
• Ingest data using various protocols: AMQP, MQTT and STOMP
With RabbitMQ we can
• Ingest data using various protocols: AMQP, MQTT and STOMP
• Distribute that data globally using Federation
With RabbitMQ we can
• Ingest data using various protocols: AMQP, MQTT and STOMP
• Distribute that data globally using Federation
• Scale up using Sharding
With RabbitMQ we can
• Ingest data using various protocols: AMQP, MQTT and STOMP
• Distribute that data globally using Federation
• Scale up using Sharding
• Load balance consumers with Federated Queues
Credits
world map: wikipedia.org
federation diagrams: rabbitmq.com
Questions?
Thanks
AlvaroVidela - @old_sound

More Related Content

PDF
Improvements in RabbitMQ
PDF
RabbitMQ Data Ingestion
PDF
Dissecting the rabbit: RabbitMQ Internal Architecture
PDF
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
PPTX
RabbitMQ Model and Some Example Applications
PPTX
Scaling application with RabbitMQ
PDF
PDF
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
Improvements in RabbitMQ
RabbitMQ Data Ingestion
Dissecting the rabbit: RabbitMQ Internal Architecture
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
RabbitMQ Model and Some Example Applications
Scaling application with RabbitMQ
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ

What's hot (20)

PDF
Scaling applications with RabbitMQ at SunshinePHP
PDF
RabbitMQ Operations
PDF
Troubleshooting RabbitMQ and services that use it
PPTX
Spring RabbitMQ
PDF
RabbitMQ with python and ruby RuPy 2009
PPTX
High powered messaging with RabbitMQ
PDF
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
PDF
RabbitMQ fairly-indepth
PDF
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
PDF
Integrating PostgreSql with RabbitMQ
PDF
Developing Java based microservices ready for the world of containers
PPTX
No Docker? No Problem: Automating installation and config with Ansible
PDF
Lessons from managing a Pulsar cluster (Nutanix)
PDF
Red Hat Nordics 2020 - Apache Camel 3 the next generation of enterprise integ...
PDF
Developing Java based microservices ready for the world of containers
PPTX
Server Side Swift
PPTX
Introducing Exactly Once Semantics To Apache Kafka
PDF
Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes
PPTX
ITB2015 - Go Commando with CommandBox CLI
PDF
Kafka Summit NYC 2017 - Running Hundreds of Kafka Clusters with 5 People
Scaling applications with RabbitMQ at SunshinePHP
RabbitMQ Operations
Troubleshooting RabbitMQ and services that use it
Spring RabbitMQ
RabbitMQ with python and ruby RuPy 2009
High powered messaging with RabbitMQ
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
RabbitMQ fairly-indepth
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Integrating PostgreSql with RabbitMQ
Developing Java based microservices ready for the world of containers
No Docker? No Problem: Automating installation and config with Ansible
Lessons from managing a Pulsar cluster (Nutanix)
Red Hat Nordics 2020 - Apache Camel 3 the next generation of enterprise integ...
Developing Java based microservices ready for the world of containers
Server Side Swift
Introducing Exactly Once Semantics To Apache Kafka
Riga Dev Day 2016 - Microservices with Apache Camel & fabric8 on Kubernetes
ITB2015 - Go Commando with CommandBox CLI
Kafka Summit NYC 2017 - Running Hundreds of Kafka Clusters with 5 People
Ad

Viewers also liked (18)

PPT
Web sphere mq Online Training at bigclasses
PPTX
Java Messaging with AMQP and RabbitMQ
KEY
Taste Rabbitmq
PDF
新浪微博开放平台Redis实战
PPTX
高性能No sql数据库redis
PDF
redis 适用场景与实现
PPTX
Redis介绍
PDF
Introduction to RabbitMQ | Meetup at Pivotal Labs
PDF
RabbitMQ Messaging
PDF
Integrating RabbitMQ with PHP
PDF
深入了解Redis
PPTX
Gobblin: Unifying Data Ingestion for Hadoop
PDF
Streaming Big Data & Analytics For Scale
DOCX
Ibm web sphere application server interview questions
PDF
Redis for the Everyday Developer
PPTX
Data Ingestion, Extraction & Parsing on Hadoop
PDF
Introduction to AMQP Messaging with RabbitMQ
KEY
Redis in Practice
Web sphere mq Online Training at bigclasses
Java Messaging with AMQP and RabbitMQ
Taste Rabbitmq
新浪微博开放平台Redis实战
高性能No sql数据库redis
redis 适用场景与实现
Redis介绍
Introduction to RabbitMQ | Meetup at Pivotal Labs
RabbitMQ Messaging
Integrating RabbitMQ with PHP
深入了解Redis
Gobblin: Unifying Data Ingestion for Hadoop
Streaming Big Data & Analytics For Scale
Ibm web sphere application server interview questions
Redis for the Everyday Developer
Data Ingestion, Extraction & Parsing on Hadoop
Introduction to AMQP Messaging with RabbitMQ
Redis in Practice
Ad

Similar to RabbitMQ Data Ingestion at Craft Conf (20)

PDF
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
PPTX
Picking a message queue
KEY
London devops logging
KEY
Message:Passing - lpw 2012
PDF
NullMQ @ PDX
PDF
Follow the White Rabbit - Message Queues with PHP
PDF
Apache Kafka® at Dropbox
PPTX
Meetup on Apache Zookeeper
PPTX
Release the Monkeys ! Testing in the Wild at Netflix
KEY
Puppet101
PDF
The Future of Messaging: RabbitMQ and AMQP
PPTX
RabbitMQ and EasyNetQ
KEY
Real time system_performance_mon
PDF
Directions for CloudStack Networking
KEY
A web app in pure Clojure
KEY
Messaging, interoperability and log aggregation - a new framework
PDF
Alvaro Videla, Pivotal, Inc.
PDF
The Future of SDN in CloudStack by Chiradeep Vittal
PPT
Cdn cs6740
PDF
Vert.x
Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Vid...
Picking a message queue
London devops logging
Message:Passing - lpw 2012
NullMQ @ PDX
Follow the White Rabbit - Message Queues with PHP
Apache Kafka® at Dropbox
Meetup on Apache Zookeeper
Release the Monkeys ! Testing in the Wild at Netflix
Puppet101
The Future of Messaging: RabbitMQ and AMQP
RabbitMQ and EasyNetQ
Real time system_performance_mon
Directions for CloudStack Networking
A web app in pure Clojure
Messaging, interoperability and log aggregation - a new framework
Alvaro Videla, Pivotal, Inc.
The Future of SDN in CloudStack by Chiradeep Vittal
Cdn cs6740
Vert.x

More from Alvaro Videla (19)

PDF
Data Migration at Scale with RabbitMQ and Spring Integration
PDF
Unit Test + Functional Programming = Love
PDF
Writing testable code
PDF
RabbitMQ Hands On
PDF
Rabbitmq Boot System
PDF
Cloud Foundry Bootcamp
PDF
Cloud Messaging With Cloud Foundry
PDF
Taming the rabbit
PDF
PDF
Código Fácil De Testear
PDF
Desacoplando aplicaciones
PDF
Messaging patterns
PDF
Theres a rabbit on my symfony
PDF
Scaling Web Apps With RabbitMQ - Erlang Factory Lite
PDF
Integrating php withrabbitmq_zendcon
PDF
Scaling webappswithrabbitmq
PDF
Integrating Erlang with PHP
PDF
Interoperability With RabbitMq
PDF
Debugging and Profiling Symfony Apps
Data Migration at Scale with RabbitMQ and Spring Integration
Unit Test + Functional Programming = Love
Writing testable code
RabbitMQ Hands On
Rabbitmq Boot System
Cloud Foundry Bootcamp
Cloud Messaging With Cloud Foundry
Taming the rabbit
Código Fácil De Testear
Desacoplando aplicaciones
Messaging patterns
Theres a rabbit on my symfony
Scaling Web Apps With RabbitMQ - Erlang Factory Lite
Integrating php withrabbitmq_zendcon
Scaling webappswithrabbitmq
Integrating Erlang with PHP
Interoperability With RabbitMq
Debugging and Profiling Symfony Apps

Recently uploaded (20)

PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
KodekX | Application Modernization Development
PDF
Approach and Philosophy of On baking technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Big Data Technologies - Introduction.pptx
PDF
Modernizing your data center with Dell and AMD
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Cloud computing and distributed systems.
Mobile App Security Testing_ A Comprehensive Guide.pdf
The AUB Centre for AI in Media Proposal.docx
KodekX | Application Modernization Development
Approach and Philosophy of On baking technology
Building Integrated photovoltaic BIPV_UPV.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
Big Data Technologies - Introduction.pptx
Modernizing your data center with Dell and AMD
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
“AI and Expert System Decision Support & Business Intelligence Systems”
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
NewMind AI Weekly Chronicles - August'25 Week I
Cloud computing and distributed systems.

RabbitMQ Data Ingestion at Craft Conf