SlideShare a Scribd company logo
1 of 56
Download to read offline
Software
Architecture
using ØMQ

by
Pieter Hintjens
Strange Loop 2012
Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
A complex
story is best
told as a
series of
vacuous 1-
liners



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
90% of
software is
trash.

90% of the
rest will be
trash RSN


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
We basically
don't know
how to
make code
that can
survive ten,
let alone 50
years

Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
The most
difficult
challenge
in our
profession
is simple
accuracy


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Future code
has to talk
to code, has
to be chatty,
sociable,
well-
connected


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
When we
can move
faster,
where we
go is more
critical than
ever.


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Writing
distributed
code is like
a live jam
session.

It's all about
other people

Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
How we
connect to
each other
matters
more than
who we are



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
The physics
of software
is the
physics of
people




Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Ideas are
cheap.

Execution is
the hard
part



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Making
perfect
software is
easy, once
you learn
the trick
(which is
kinda hard)

Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Simplicity
always
beats
functionality




Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Problems
are not all
equal, and
most are
illusions




Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
When you
know the
real problem
you have
done half
the work



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Do nothing
that is not a
minimal,
plausible
answer to a
well-defined
problem


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Every
commit
should be
shippable




Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Design by
removing
problems,
not adding
features




Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Five Steps
to Satori:
Learn,
Draw,
Divide,
Conquer,
Repeat


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
1.
Learn the
language
before you
write a
poem



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
2.
If it looks
pretty, it's
more likely
to work




Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
3.
A good
contract is
worth a
thousands
assumptions



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
4.
When you
take small
steps, it
hurts less
when you
fall


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
5.
Solve one
problem,
and repeat
until you run
out of time
or money


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Distributed
software
lives or dies
by its
protocols




Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Protocols
are contracts
that describe
the rights
and
obligations
of each party


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
An unprotocol
takes minutes
to explain,
hours to
design, days to
write, weeks to
prove, months
to mature, and
years to
replace
Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Use human                         nom-protocol =
                                     open-peering
language                            *use-peering
in your                           open-peering =
unprotocols.                         C:OHAI
                                   ( S:OHAI-OK / S:WTF )

                                  use-peering =
ORLY?                                C:ICANHAZ
YARLY!                             / S:CHEEZBURGER
                                   / C:HUGZ S:HUGZ-OK
                                   / S:HUGZ C:HUGZ-OK


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Use GPLv3
for your
open specs.

Remixability
is freedom



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
If you're
willing to
give up
flexibility for
speed you
deserve
neither
flexibility nor
speed
Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Use cheap
text for the
low-volume
chatty
control
commands



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Use nasty
hand-coded
binary for
the high-
volume data




Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
ØMQ
framing
makes a
lousy codec
but a great
separator



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
A hand-
crafted
codec can
always beat
a generic
serializer



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
A code-
generated
codec can
always beat
a hand-
crafted one



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
iMatix GSL:
technology
so dangerous
we had to
lock it up for
years



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
File transfer
is the
zombie
problem of
distributed
applications



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Router
sockets are
the beating
heart of
every real
ØMQ
protocol
engine

Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
The world
needs a
chunked,
flow-controlled,
restartable,
cancellable,
async,
multicast
file transfer
ØMQ protocol

Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
No matter                         C:   fetch
how hard                          S:   chunk 1
you push, a                       S:   chunk 2
file will not                     S:   chunk 3
just go down
a socket



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
That                              C:   fetch chunk 1
annoying                          S:   send chunk 1
pause after                       C:   fetch chunk 2
                                  S:   send chunk 2
you finish
                                  C:   fetch chunk 3
your beer,                        S:   send chunk 3
before you                        C:   fetch chunk 4
catch the
waiter's eye

Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
You can,                          C:   fetch chunk 1
and I've                          C:   fetch chunk 2
tested this,                      C:   fetch chunk 3
                                  S:   send chunk 1
order a new
                                  C:   fetch chunk 4
beer before                       S:   send chunk 2
your old one                      S:   send chunk 3
is empty


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Request-                          C:   subscribe
reply is just                     C:   send credit
a vulgar                          S:   send chunk
                                  S:   send chunk
subclass of
                                  C:   send credit
publish-                          S:   send chunk
subscribe



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
On a router
socket, you
should
never hit the
high-water
mark



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Heartbeats
are our
protocol's
way of
asking if we
still care



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Protocol                          command_t
stack                              *request =
=                                 command_decode
                                   (socket)
message
codec                             execute_engine
+                                  (command)
protocol
engine

Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
State
machines
are a perfect
domain
language for
protocol
engines


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
State
machines
can be cudly
and gentle,
when you
get to know
them


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
You don't
want to bet
against a
compiler




Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
If you're not
thinking of
security,
security is
probably
thinking of
you


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
For
connected
bidirectional
protocols
over ØMQ
use SASL



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
For loosely
connected
and one-way
protocols
over ØMQ,
use AES and
such


Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
secure-nom = open-peering
SASL over                                     *use-peering

ØMQ is                            open-peering =
                                      C:OHAI
darned                             *( S:ORLY C:YARLY )
simple                              ( S:OHAI-OK / S:WTF )

                                  ORLY = 1*mechanism
                                         challenge
                                  mechanism = string
                                  challenge = *OCTET

                                  YARLY = mechanism
                                          response
                                  response = *OCTET

Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
Theory is
fine in
theory, but
in practice,
practice is
better



Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
FileMQ is a
file sharing
protocol and
stack over
ØMQ.

Reusable
until 2062

Photos by Pieter Hintjens
cc-by-sa © 2012 Pieter Hintjens
1. Aim for 50 years
To sum it up:                     2. It's all about people
                                  3. Minimal plausible solutions
zero.mq/ch6                       4. To real immediate problems
                                  5. Document the contracts
                                  6. Cheap and Nasty codecs
The Weird                         7. Code generation rocks
Fish Book,                        8. Router sockets rock
coming soon                       9. CBFC > HWM
from O'Reilly                     10. Learn state machines
                                  11. Learn about SASL

Photos by Pieter Hintjens
                                  12. Worked example: FileMQ
cc-by-sa © 2012 Pieter Hintjens

More Related Content

Viewers also liked

Git Without Branches - Simple, Smooth, Scalable
Git Without Branches - Simple, Smooth, ScalableGit Without Branches - Simple, Smooth, Scalable
Git Without Branches - Simple, Smooth, Scalable
pieterh
 

Viewers also liked (20)

Introduction to ZeroMQ - eSpace TechTalk
Introduction to ZeroMQ - eSpace TechTalkIntroduction to ZeroMQ - eSpace TechTalk
Introduction to ZeroMQ - eSpace TechTalk
 
Zeromq anatomy & jeromq
Zeromq anatomy & jeromqZeromq anatomy & jeromq
Zeromq anatomy & jeromq
 
Software Architecture using ZeroMQ - techmesh 2012
Software Architecture using ZeroMQ - techmesh 2012Software Architecture using ZeroMQ - techmesh 2012
Software Architecture using ZeroMQ - techmesh 2012
 
Git Without Branches - Simple, Smooth, Scalable
Git Without Branches - Simple, Smooth, ScalableGit Without Branches - Simple, Smooth, Scalable
Git Without Branches - Simple, Smooth, Scalable
 
Revolutionary Open Source
Revolutionary Open SourceRevolutionary Open Source
Revolutionary Open Source
 
Practical Message Queueing using RabbitMQ (Nomad PHP EU Dec 2014)
Practical Message Queueing using RabbitMQ (Nomad PHP EU Dec 2014)Practical Message Queueing using RabbitMQ (Nomad PHP EU Dec 2014)
Practical Message Queueing using RabbitMQ (Nomad PHP EU Dec 2014)
 
Social architecture-101
Social architecture-101Social architecture-101
Social architecture-101
 
Fosdem 2009
Fosdem 2009Fosdem 2009
Fosdem 2009
 
Introducing Practical RabbitMQ (php[tek] 2016 - Tutorial)
Introducing Practical RabbitMQ (php[tek] 2016 - Tutorial)Introducing Practical RabbitMQ (php[tek] 2016 - Tutorial)
Introducing Practical RabbitMQ (php[tek] 2016 - Tutorial)
 
CurveZMQ, ZMTP and other Dubious Characters
CurveZMQ, ZMTP and other Dubious CharactersCurveZMQ, ZMTP and other Dubious Characters
CurveZMQ, ZMTP and other Dubious Characters
 
Introduction to Heroku Postgres
Introduction to Heroku PostgresIntroduction to Heroku Postgres
Introduction to Heroku Postgres
 
Scala and ZeroMQ: Events beyond the JVM
Scala and ZeroMQ: Events beyond the JVMScala and ZeroMQ: Events beyond the JVM
Scala and ZeroMQ: Events beyond the JVM
 
Roman Kuznietsov: Zeromq: sockets on steroids.Zero mq
Roman Kuznietsov: Zeromq: sockets on steroids.Zero mqRoman Kuznietsov: Zeromq: sockets on steroids.Zero mq
Roman Kuznietsov: Zeromq: sockets on steroids.Zero mq
 
ZeroMQ
ZeroMQZeroMQ
ZeroMQ
 
zeromq
zeromqzeromq
zeromq
 
ZeroMQ e Redis: soluzioni open source per l'integrazione di componenti
ZeroMQ e Redis: soluzioni open source per l'integrazione di componentiZeroMQ e Redis: soluzioni open source per l'integrazione di componenti
ZeroMQ e Redis: soluzioni open source per l'integrazione di componenti
 
RabbitMq
RabbitMqRabbitMq
RabbitMq
 
RestMS Introduction
RestMS IntroductionRestMS Introduction
RestMS Introduction
 
Introduction to ZeroMQ
Introduction to ZeroMQIntroduction to ZeroMQ
Introduction to ZeroMQ
 
Zmq in context of openstack
Zmq in context of openstackZmq in context of openstack
Zmq in context of openstack
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Software Architecture over ZeroMQ