Top Banner
Gaetano Giunta Symfony Live Sept 2016 Symfony vs. Message Brokers (tip: Symfony wins)
25

Symfony vs. Message Brokers

Jan 09, 2017

Download

Internet

Gaetano Giunta
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Symfony  vs.  Message Brokers

It’s all about eXperience

Gaetano Giunta

Symfony Live

Sept 2016

Symfony

vs.

Message Brokers

(tip: Symfony wins)

Page 2: Symfony  vs.  Message Brokers

Message brokers in 1000 words

Page 3: Symfony  vs.  Message Brokers

• RabbitMQ

• ActiveMQ

• Apollo

• Kafka

• Kestrel

• Amazon SQS

• ZeroMQ*

• And many more…

Can you name any broker?

Page 4: Symfony  vs.  Message Brokers

• RabbitMQ

• ActiveMQ

• Apollo

• Kafka

• Kestrel

• Amazon SQS

• ZeroMQ*

• And many more…

Why should you use one? Which one?

Page 5: Symfony  vs.  Message Brokers

A case study: generating M$Office docs

• Produce content in Microsoft Office formats

• Many formats for each document

• Both Word and Excel docs

• XML content generated by CMS

• LibreOffice used to generate MS Office and PDF

versions

Page 6: Symfony  vs.  Message Brokers

A case study: generating M$Office docs

Reality bites

Page 7: Symfony  vs.  Message Brokers

A case study: generating M$Office docs

Reality bites

• Slooow

• Rest assured that some of the docs will be pretty big

• Unreliable

• Depending on version, LO crashes from a-bit to almost-

always

• Race-prone

• Two conversion jobs in parallel might step on each other

Page 8: Symfony  vs.  Message Brokers

A case study: generating M$Office docs

…and the results are:

Page 9: Symfony  vs.  Message Brokers

A case study: generating M$Office docs

…and the results are:

• Ugly code: lots of polling, copying of files around,

manual locking

• Does not scale at all: only one conversion process

active at any given time

Web

serverPHP

Libre

Office

Waiting processes

Page 10: Symfony  vs.  Message Brokers

TextBook scenario for introducing queues

Web

server

Worker

?

Rabbit

MQ

Libre

Office

PHP

Page 11: Symfony  vs.  Message Brokers

TextBook scenario for introducing queues

Web

server

Worker

?

Rabbit

MQ

Libre

Office

PHP

Page 12: Symfony  vs.  Message Brokers

TextBook scenario for introducing queues

Web

server

PHP

!

Rabbit

MQ

Libre

Office

PHP

Page 13: Symfony  vs.  Message Brokers

TextBook scenario for introducing queues

Web

server

PHP

!

Rabbit

MQ

Libre

Office

PHP

Page 14: Symfony  vs.  Message Brokers

TextBook scenario for introducing queues

Web

server

Symfony

!!!

Rabbit

MQ

Libre

Office

PHP

Page 15: Symfony  vs.  Message Brokers

TextBook scenario for introducing queues

Web

server

Symfony

!!!

Rabbit

MQ

Libre

Office

PHP

Page 16: Symfony  vs.  Message Brokers

Is there a bundle for that ?

oldsound/rabbitmq-bundle

Page 17: Symfony  vs.  Message Brokers

Is there a bundle for that ?

oldsound/rabbitmq-bundle

• Specific to RabbitMQ

• Consumers are long-lived php processes

• fatal errors

• mem leaks

• DB connections time out

• on your code or in a dependency?

Page 18: Symfony  vs.  Message Brokers

A new hope

• kaliop/queueingbundle

• kaliop/queueingbundle-sqs

• kaliop/queueingbundle-stomp

Page 19: Symfony  vs.  Message Brokers

Multiple protocol support

Page 20: Symfony  vs.  Message Brokers

Multiple protocol support

Kaliop Queueing Bundles

fusesource/stomp-phpaws/aws-sdk-php oldsound/rabbitmq

ActiveMQ ApolloSQS RabbitMQ

Application

Page 21: Symfony  vs.  Message Brokers

Easy to use

Page 22: Symfony  vs.  Message Brokers

Easy to use

• Message encoding taken care of

• Has events your code can listen to

Message

received

Do stuff

Consump

tion

failed

Message

consumed

Exception

Page 23: Symfony  vs.  Message Brokers

A design focusing on safety

Page 24: Symfony  vs.  Message Brokers

A design focusing on safety

• The default consumer has been split in 2

• The listener is long lived

• The worker process is a Symfony console command

• It handles a single message then exits

Symfony

listenerSymfony

worker

Libre

OfficeQueue

Page 25: Symfony  vs.  Message Brokers

I’llbe here all night

THANK YOU

https://github.com/kaliop-uk/kueueingbundle

• @gggeek

• www.kaliop.co.uk