symfony vs. message brokers

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

Upload: gaetano-giunta

Post on 09-Jan-2017

162 views

Category:

Internet


0 download

TRANSCRIPT

It’s all about eXperience

Gaetano Giunta

Symfony Live

Sept 2016

Symfony

vs.

Message Brokers

(tip: Symfony wins)

Message brokers in 1000 words

• RabbitMQ

• ActiveMQ

• Apollo

• Kafka

• Kestrel

• Amazon SQS

• ZeroMQ*

• And many more…

Can you name any broker?

• RabbitMQ

• ActiveMQ

• Apollo

• Kafka

• Kestrel

• Amazon SQS

• ZeroMQ*

• And many more…

Why should you use one? Which one?

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

A case study: generating M$Office docs

Reality bites

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

A case study: generating M$Office docs

…and the results are:

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

TextBook scenario for introducing queues

Web

server

Worker

?

Rabbit

MQ

Libre

Office

PHP

TextBook scenario for introducing queues

Web

server

Worker

?

Rabbit

MQ

Libre

Office

PHP

TextBook scenario for introducing queues

Web

server

PHP

!

Rabbit

MQ

Libre

Office

PHP

TextBook scenario for introducing queues

Web

server

PHP

!

Rabbit

MQ

Libre

Office

PHP

TextBook scenario for introducing queues

Web

server

Symfony

!!!

Rabbit

MQ

Libre

Office

PHP

TextBook scenario for introducing queues

Web

server

Symfony

!!!

Rabbit

MQ

Libre

Office

PHP

Is there a bundle for that ?

oldsound/rabbitmq-bundle

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?

A new hope

• kaliop/queueingbundle

• kaliop/queueingbundle-sqs

• kaliop/queueingbundle-stomp

Multiple protocol support

Multiple protocol support

Kaliop Queueing Bundles

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

ActiveMQ ApolloSQS RabbitMQ

Application

Easy to use

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

A design focusing on safety

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

I’llbe here all night

THANK YOU

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

• @gggeek

• www.kaliop.co.uk