SlideShare a Scribd company logo
Building a 
Distributed 
Data Ingestion 
System 
with RabbitMQ 
Alvaro Videla - RabbitMQ
Alvaro Videla 
• Works at RabbitMQ 
• Co-Author of RabbitMQ in Action 
• Creator of the RabbitMQ Simulator 
• Blogs about RabbitMQ Internals: h!p://videlalvaro.github.io/ 
internals.html 
• @old_sound — alvaro@rabbitmq.com — github.com/videlalvaro
About Me 
Co-authored 
RabbitMQ in Action 
h!p://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
h!ps://twi!er.com/spacemanaki/status/514590885523505153
What is RabbitMQ
Multi Protocol 
http://bit.ly/rmq-protocols
Community Plugins 
http://www.rabbitmq.com/community-plugins.html
Polyglot
Polyglot 
• PHP
Polyglot 
• PHP 
• node.js
Polyglot 
• PHP 
• node.js 
• Erlang
Polyglot 
• PHP 
• node.js 
• Erlang 
• Java
Polyglot 
• PHP 
• node.js 
• Erlang 
• Java 
• Ruby
Polyglot 
• PHP 
• node.js 
• Erlang 
• Java 
• Ruby 
• .Net
Polyglot 
• PHP 
• node.js 
• Erlang 
• Java 
• Ruby 
• .Net 
• Haskell
Polyglot 
Even COBOL!!!11
Some users of RabbitMQ
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 
• Mozilla
The New York 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. 
h!p://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2014-January/032943.html
h!p://www.rabbitmq.com/download.html 
Unix - Mac - Windows
Messaging with RabbitMQ 
h!ps://github.com/RabbitMQSimulator/ 
RabbitMQSimulator
h!p://tryrabbitmq.com
RabbitMQ Simulator
The Problem
Distributed Application 
App 
App 
App 
App
{ok, Connection} = 
Data Producer 
Obtain a Channel 
amqp_connection:start(#amqp_params_network{host = "localhost"}), 
{ok, Channel} = amqp_connection:open_channel(Connection),
Data Producer 
Declare an Exchange 
amqp_channel:call(Channel, #’exchange.declare'{exchange = <<"events">>, 
type = <<"direct">>}),
Data Producer 
amqp_channel:cast(Channel, 
Publish a message 
#'basic.publish'{ 
exchange = <<"events">>}, 
#amqp_msg{props = #'P_basic'{delivery_mode = 2}, 
payload = <<“Hello Federation">>}),
Data Consumer 
Obtain a Channel 
{ok, Connection} = 
amqp_connection:start(#amqp_params_network{host = "localhost"}), 
{ok, Channel} = amqp_connection:open_channel(Connection),
Data Consumer 
Declare Queue and bind it 
amqp_channel:call(Channel, #'exchange.declare'{exchange = <<"events">>, 
type = <<"direct">>}), 
#'queue.declare_ok'{queue = Queue} = 
amqp_channel:call(Channel, #'queue.declare'{exclusive = true}), 
amqp_channel:call(Channel, #'queue.bind'{exchange = <<"events">>, 
queue = Queue}),
Data Consumer 
amqp_channel:subscribe(Channel, #'basic.consume'{queue = Queue, 
no_ack = true}, self()), 
receive 
#'basic.consume_ok'{} -> ok 
end, 
loop(Channel). 
Start a consumer
loop(Channel) -> 
receive 
Data Consumer 
{#'basic.deliver'{}, #amqp_msg{payload = Body}} -> 
io:format(" [x] ~p~n", [Body]), 
loop(Channel) 
end. 
Process messages
Distributed Application 
App 
App 
App 
App
Ad-hoc solution
A process that replicates data 
to the remote server
Possible issues
Possible issues 
• Remote server is offline
Possible issues 
• Remote server is offline 
• Prevent unbounded local buffers
Possible issues 
• Remote server is offline 
• Prevent unbounded local buffers 
• Prevent message loss
Possible issues 
• Remote server is offline 
• Prevent unbounded local buffers 
• Prevent message loss 
• Prevent unnecessary message replication
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
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 be!er?
RabbitMQ Federation
RabbitMQ Federation
RabbitMQ Federation 
• Supports replication across different administrative domains
RabbitMQ Federation 
• Supports replication across different administrative domains 
• Supports mix of Erlang and RabbitMQ versions
RabbitMQ Federation 
• Supports replication across different administrative domains 
• Supports mix of Erlang and RabbitMQ versions 
• Supports Network Partitions
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
Some Queueing Theory 
http://www.rabbitmq.com/blog/2012/05/11/some-queuing-theory-throughput-latency-and-bandwidth/
RabbitMQ BasicQos Simulator
Prevent Unbound Buffers 
λ = mean arrival time 
μ = mean service rate 
if λ > μ what happens? 
https://www.rabbitmq.com/blog/2014/01/23/preventing-unbounded-buffers-with-rabbitmq/
Prevent Unbound Buffers 
λ = mean arrival time 
μ = mean service rate 
if λ > μ what happens? 
Queue length goes to infinity over time. 
https://www.rabbitmq.com/blog/2014/01/23/preventing-unbounded-buffers-with-rabbitmq/
Recommended Reading 
Performance Modeling and 
Design of Computer Systems: 
Queueing Theory in Action
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
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 partitioner 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
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! 
Alvaro Videla - @old_sound

More Related Content

PDF
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
PDF
Troubleshooting RabbitMQ and services that use it
PDF
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
PPTX
RabbitMQ Model and Some Example Applications
PDF
RabbitMQ Data Ingestion
PDF
Dissecting the rabbit: RabbitMQ Internal Architecture
PDF
RabbitMQ Operations
PDF
Improvements in RabbitMQ
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Troubleshooting RabbitMQ and services that use it
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
RabbitMQ Model and Some Example Applications
RabbitMQ Data Ingestion
Dissecting the rabbit: RabbitMQ Internal Architecture
RabbitMQ Operations
Improvements in RabbitMQ

What's hot (19)

PDF
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
PPTX
Scaling application with RabbitMQ
PDF
PDF
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
PDF
Concurrency in Python
PDF
실시간 서비스 플랫폼 개발 사례
PDF
События, шины и интеграция данных в непростом мире микросервисов / Валентин Г...
KEY
Streams are Awesome - (Node.js) TimesOpen Sep 2012
PPTX
Terraform Immutablish Infrastructure with Consul-Template
PDF
Ruby 2.4 Internals
PDF
DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술
PDF
The SaltStack Pub Crawl - Fosscomm 2016
PDF
Deployment de Rails
PDF
Fisl - Deployment
PDF
Advanced technic for OS upgrading in 3 minutes
PDF
CRUFT! - Peter Kriens, President, aQute
PDF
OpenNebula and SaltStack - OpenNebulaConf 2013
PDF
Apache Camel in the belly of the Docker whale
ODP
Developing high-performance network servers in Lisp
Alvaro Videla, Building a Distributed Data Ingestion System with RabbitMQ
Scaling application with RabbitMQ
Practical Message Queuing Using RabbitMQ (PHPem, 3rd July 2014)
Concurrency in Python
실시간 서비스 플랫폼 개발 사례
События, шины и интеграция данных в непростом мире микросервисов / Валентин Г...
Streams are Awesome - (Node.js) TimesOpen Sep 2012
Terraform Immutablish Infrastructure with Consul-Template
Ruby 2.4 Internals
DEVIEW - 오픈소스를 활용한 분산아키텍처 구현기술
The SaltStack Pub Crawl - Fosscomm 2016
Deployment de Rails
Fisl - Deployment
Advanced technic for OS upgrading in 3 minutes
CRUFT! - Peter Kriens, President, aQute
OpenNebula and SaltStack - OpenNebulaConf 2013
Apache Camel in the belly of the Docker whale
Developing high-performance network servers in Lisp
Ad

Viewers also liked (10)

PDF
Alvaro Videla, Pivotal, Inc.
PDF
Рецепты RabbitMQ
PPTX
ByndyuSoft 1 год глазами программиста
ODP
Сравнение AMQP и ZeroMQ
PDF
Компания мечты своими руками, Уфа,
PDF
Карьера в IT, 27-02-2013
PPTX
Инструменты высоконагруженных проектов - кэширование и очереди, Вячеслав Моск...
PDF
Zabbix
PDF
Zabbix Performance Tuning
PDF
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
Alvaro Videla, Pivotal, Inc.
Рецепты RabbitMQ
ByndyuSoft 1 год глазами программиста
Сравнение AMQP и ZeroMQ
Компания мечты своими руками, Уфа,
Карьера в IT, 27-02-2013
Инструменты высоконагруженных проектов - кэширование и очереди, Вячеслав Моск...
Zabbix
Zabbix Performance Tuning
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
Ad

Similar to Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Videla (Pivotal Inc.) (20)

PDF
RabbitMQ Data Ingestion at Craft Conf
PDF
Follow the White Rabbit - Message Queues with PHP
PDF
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
PDF
The Future of Messaging: RabbitMQ and AMQP
PDF
Scaling applications with RabbitMQ at SunshinePHP
PDF
Messaging with RabbitMQ and AMQP
PDF
Messaging with amqp and rabbitmq
PDF
Multi-language/multi-OS communication using RabbitMQ
PDF
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de Bruin
PPTX
Picking a message queue
PPTX
The RabbitMQ Message Broker
PDF
Building scalable flexible messaging systems using qpid
PPTX
Docker Swarm secrets for creating great FIWARE platforms
PPT
Cdn cs6740
PDF
Vert.x – The problem of real-time data binding
PDF
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
PPTX
When it Absolutely, Positively, Has to be There: Reliability Guarantees in Ka...
PDF
Common issues with Apache Kafka® Producer
PPTX
Planning to Fail #phpne13
PDF
RabbitMQ with python and ruby RuPy 2009
RabbitMQ Data Ingestion at Craft Conf
Follow the White Rabbit - Message Queues with PHP
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
The Future of Messaging: RabbitMQ and AMQP
Scaling applications with RabbitMQ at SunshinePHP
Messaging with RabbitMQ and AMQP
Messaging with amqp and rabbitmq
Multi-language/multi-OS communication using RabbitMQ
ITB2019 Multi-language / multi-OS communication using RabbitMQ - Wil de Bruin
Picking a message queue
The RabbitMQ Message Broker
Building scalable flexible messaging systems using qpid
Docker Swarm secrets for creating great FIWARE platforms
Cdn cs6740
Vert.x – The problem of real-time data binding
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
When it Absolutely, Positively, Has to be There: Reliability Guarantees in Ka...
Common issues with Apache Kafka® Producer
Planning to Fail #phpne13
RabbitMQ with python and ruby RuPy 2009

More from Ontico (20)

PDF
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
PDF
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
PPTX
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
PDF
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
PDF
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
PDF
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
PDF
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
PDF
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
PPTX
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
PPTX
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
PDF
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
PPTX
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
PPTX
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
PDF
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
PPT
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
PPTX
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
PPTX
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
PPTX
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
PPTX
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
PDF
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...
One-cloud — система управления дата-центром в Одноклассниках / Олег Анастасье...
Масштабируя DNS / Артем Гавриченков (Qrator Labs)
Создание BigData-платформы для ФГУП Почта России / Андрей Бащенко (Luxoft)
Готовим тестовое окружение, или сколько тестовых инстансов вам нужно / Алекса...
Новые технологии репликации данных в PostgreSQL / Александр Алексеев (Postgre...
PostgreSQL Configuration for Humans / Alvaro Hernandez (OnGres)
Inexpensive Datamasking for MySQL with ProxySQL — Data Anonymization for Deve...
Опыт разработки модуля межсетевого экранирования для MySQL / Олег Брославский...
ProxySQL Use Case Scenarios / Alkin Tezuysal (Percona)
MySQL Replication — Advanced Features / Петр Зайцев (Percona)
Внутренний open-source. Как разрабатывать мобильное приложение большим количе...
Подробно о том, как Causal Consistency реализовано в MongoDB / Михаил Тюленев...
Балансировка на скорости проводов. Без ASIC, без ограничений. Решения NFWare ...
Перехват трафика — мифы и реальность / Евгений Усков (Qrator Labs)
И тогда наверняка вдруг запляшут облака! / Алексей Сушков (ПЕТЕР-СЕРВИС)
Как мы заставили Druid работать в Одноклассниках / Юрий Невиницин (OK.RU)
Разгоняем ASP.NET Core / Илья Вербицкий (WebStoating s.r.o.)
100500 способов кэширования в Oracle Database или как достичь максимальной ск...
Apache Ignite Persistence: зачем Persistence для In-Memory, и как он работает...
Механизмы мониторинга баз данных: взгляд изнутри / Дмитрий Еманов (Firebird P...

Recently uploaded (20)

PDF
Sims 4 Historia para lo sims 4 para jugar
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PPTX
Internet___Basics___Styled_ presentation
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PDF
An introduction to the IFRS (ISSB) Stndards.pdf
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PPTX
Module 1 - Cyber Law and Ethics 101.pptx
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
PPTX
SAP Ariba Sourcing PPT for learning material
PPT
Design_with_Watersergyerge45hrbgre4top (1).ppt
PPTX
artificial intelligence overview of it and more
PPTX
Job_Card_System_Styled_lorem_ipsum_.pptx
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PDF
Testing WebRTC applications at scale.pdf
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PDF
Paper PDF World Game (s) Great Redesign.pdf
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PPTX
introduction about ICD -10 & ICD-11 ppt.pptx
PPTX
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
Sims 4 Historia para lo sims 4 para jugar
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
Internet___Basics___Styled_ presentation
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
An introduction to the IFRS (ISSB) Stndards.pdf
522797556-Unit-2-Temperature-measurement-1-1.pptx
Module 1 - Cyber Law and Ethics 101.pptx
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
SAP Ariba Sourcing PPT for learning material
Design_with_Watersergyerge45hrbgre4top (1).ppt
artificial intelligence overview of it and more
Job_Card_System_Styled_lorem_ipsum_.pptx
Unit-1 introduction to cyber security discuss about how to secure a system
Testing WebRTC applications at scale.pdf
PptxGenJS_Demo_Chart_20250317130215833.pptx
Paper PDF World Game (s) Great Redesign.pdf
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
introduction about ICD -10 & ICD-11 ppt.pptx
Introduction about ICD -10 and ICD11 on 5.8.25.pptx
Slides PDF The World Game (s) Eco Economic Epochs.pdf

Построение распределенной системы сбора данных с помощью RabbitMQ, Alvaro Videla (Pivotal Inc.)