SlideShare a Scribd company logo
It’s all about eXperience
Gaetano Giunta
PHP London
July 2015
Making Symfony
Services async with
RabbitMq
(and more Symfony)
PechaKucha style!
A case study: generating M$Office docs
2
The needs
• 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
• Has anyone tried generating OOXML by hand?
A case study: generating M$Office docs
3
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
4
…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
server
PHP
Libre
Office
Waiting processes
TextBook scenario for introducing queues
5
Web
server
Worker
?
Rabbit
MQ
Libre
Office
PHP
TextBook scenario for introducing queues
6
Web
server
Worker
?
Rabbit
MQ
Libre
Office
PHP
TextBook scenario for introducing queues
7
Web
server
PHP
!
Rabbit
MQ
Libre
Office
PHP
TextBook scenario for introducing queues
8
Web
server
PHP
!
Rabbit
MQ
Libre
Office
PHP
TextBook scenario for introducing queues
9
Web
server
Symfony
!!!
Rabbit
MQ
Libre
Office
PHP
TextBook scenario for introducing queues
10
Web
server
Symfony
!!!
Rabbit
MQ
Libre
Office
PHP
The rationale
11
• Same library handling both sides of the connection
• Easier to troubleshoot
• Sf Console component is lovely
• Everything developed in a single repository
• No need to learn new languages
• Everything which I can rewrite in PHP, I eventually will*
* = 3rd whimsical law of Gaetano
The details
12
• Json used as payload encoding
• The worker has been made thread-safe
• Again, thanks to Symfony: the « Process » Component
• It spins up a new php process each time it receives a command
• The new process executes the command
• Bonus: a ‘watchdog’ to restart workers via crontab if they die
Symfony
listener
Symfony
listener
Symfony
listener
Symfony
worker
Libre
Office
Libre
Office
W
The evolution
13
• What is exactly a « queued command » ?
• For starters, each existing Symfony console command!
• Why not every existing Symfony Service?
• Allows to run existing services asynchronously
• As long as their arguments are serializable to json
• Not a project-specific tool any more
• Could be turned into a Bundle
• …
• Profit!
The problems
14
• Assumes good security on the network
• Low throughput
• Spinning up a new php worker process takes time
• Could we use php-fpm to communicate to workers
instead?
• Am I reinventing the wheel?
• Others?
• Suggestions are welcome
I’ll be here all night
15
THANK YOU
https://github.com/kaliop-uk/kueueingbundle
• @gggeek
• www.kaliop.co.uk

More Related Content

PPTX
Rabbits, indians and... Symfony meets queueing brokers
PPTX
Designing a Docker Stack for Symfony apps: lessons learned
KEY
Zero mq logs
PDF
Distributing OSGi
PDF
How to Make Your Code OSGi Friendly Without Depending on OSGi - Neil Bartlett
PDF
Enterprise messaging
PDF
Lock-free algorithms for Kotlin Coroutines
KEY
Messaging, interoperability and log aggregation - a new framework
Rabbits, indians and... Symfony meets queueing brokers
Designing a Docker Stack for Symfony apps: lessons learned
Zero mq logs
Distributing OSGi
How to Make Your Code OSGi Friendly Without Depending on OSGi - Neil Bartlett
Enterprise messaging
Lock-free algorithms for Kotlin Coroutines
Messaging, interoperability and log aggregation - a new framework

What's hot (20)

PPTX
Auto-Generating Language-Specific Wrappers for Rust Libraries
PPTX
EhTrace -- RoP Hooks
PPTX
Keeping MongoDB Data Safe
PPTX
What's the "right" PHP Framework?
PPTX
Repeating History...On Purpose...with Elixir
PDF
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
PDF
Modularity problems
PDF
Multi-platform Enterprise Messaging with RabbitMQ
PDF
RabbitMQ fairly-indepth
PDF
Perl-Critic
PPTX
How to Keep Your Data Safe in MongoDB
KEY
Rails development environment talk
PDF
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
PPT
TypeScript for Alfresco and CMIS - Alfresco DevCon 2012 San Jose
PPTX
Proxying DBI with DBD::Gofer and App::Staticperl
PDF
RabbitMQ with python and ruby RuPy 2009
PDF
PDF
IPv4aaS tutorial and hands-on
PDF
Stackato v6
PPTX
T4T Training day - NodeJS
Auto-Generating Language-Specific Wrappers for Rust Libraries
EhTrace -- RoP Hooks
Keeping MongoDB Data Safe
What's the "right" PHP Framework?
Repeating History...On Purpose...with Elixir
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Modularity problems
Multi-platform Enterprise Messaging with RabbitMQ
RabbitMQ fairly-indepth
Perl-Critic
How to Keep Your Data Safe in MongoDB
Rails development environment talk
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
TypeScript for Alfresco and CMIS - Alfresco DevCon 2012 San Jose
Proxying DBI with DBD::Gofer and App::Staticperl
RabbitMQ with python and ruby RuPy 2009
IPv4aaS tutorial and hands-on
Stackato v6
T4T Training day - NodeJS
Ad

Similar to Making Symfony Services async with RabbitMq (and more Symfony) (20)

PDF
Symfony vs. Message Brokers
PPTX
Developing highly scalable applications with Symfony and RabbitMQ
PPTX
Message Queues & Offline Processing with PHP
PDF
When symfony met promises
KEY
Symfony2 - A Short Introduction
PDF
Symfony 2.0 on PHP 5.3
PDF
Faster PHP apps using Queues and Workers
PPTX
Ran Mizrahi - Symfony2 meets Drupal8
ODP
The promise of asynchronous PHP
PDF
Working with Asynchronous Events
PPTX
Freelance web development
PDF
Scaling Symfony2 apps with RabbitMQ - Symfony UK Meetup
PPT
Gearman and asynchronous processing in PHP applications
PPT
Gearman and asynchronous processing in PHP applications
PDF
Meet a parallel, asynchronous PHP world
KEY
Cooking a rabbit pie
PDF
Gearman - Northeast PHP 2012
PDF
Gearman: A Job Server made for Scale
PDF
No Hugging, No Learning
PPTX
Slides from LAX & DEN usergroup meetings
Symfony vs. Message Brokers
Developing highly scalable applications with Symfony and RabbitMQ
Message Queues & Offline Processing with PHP
When symfony met promises
Symfony2 - A Short Introduction
Symfony 2.0 on PHP 5.3
Faster PHP apps using Queues and Workers
Ran Mizrahi - Symfony2 meets Drupal8
The promise of asynchronous PHP
Working with Asynchronous Events
Freelance web development
Scaling Symfony2 apps with RabbitMQ - Symfony UK Meetup
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applications
Meet a parallel, asynchronous PHP world
Cooking a rabbit pie
Gearman - Northeast PHP 2012
Gearman: A Job Server made for Scale
No Hugging, No Learning
Slides from LAX & DEN usergroup meetings
Ad

More from Gaetano Giunta (13)

PDF
php day 2008 - Introduzione agli ez components
PDF
phpday 2006 - SEA case study
PDF
phpday 2006 - WS in PHP
PDF
Powerful Automation Made Simple
PPTX
Managing changes to eZPublish Database
PDF
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
PPTX
Symfony2 for legacy app rejuvenation: the eZ Publish case study
PDF
EzPerformancelogger & Graphite
PDF
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
PDF
eZPublish meets Simfony2 - phpDay2013
PDF
Ez performance measurement
ODP
Ez Content Staging for the rest of us
ODP
An eZ Publish Craftsman's toolchest
php day 2008 - Introduzione agli ez components
phpday 2006 - SEA case study
phpday 2006 - WS in PHP
Powerful Automation Made Simple
Managing changes to eZPublish Database
eZ Publish 5: from zero to automated deployment (and no regressions!) in one ...
Symfony2 for legacy app rejuvenation: the eZ Publish case study
EzPerformancelogger & Graphite
Symfony HTTP Kernel for refactoring legacy apps: the eZ Publish case study - ...
eZPublish meets Simfony2 - phpDay2013
Ez performance measurement
Ez Content Staging for the rest of us
An eZ Publish Craftsman's toolchest

Recently uploaded (20)

PPTX
Digital Literacy And Online Safety on internet
PPT
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
PPTX
E -tech empowerment technologies PowerPoint
PDF
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
PDF
Sims 4 Historia para lo sims 4 para jugar
DOC
Rose毕业证学历认证,利物浦约翰摩尔斯大学毕业证国外本科毕业证
PDF
Introduction to the IoT system, how the IoT system works
PDF
Unit-1 introduction to cyber security discuss about how to secure a system
PDF
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
PPTX
Power Point - Lesson 3_2.pptx grad school presentation
PPTX
Internet___Basics___Styled_ presentation
PPTX
presentation_pfe-universite-molay-seltan.pptx
PDF
Exploring VPS Hosting Trends for SMBs in 2025
PPTX
t_and_OpenAI_Combined_two_pressentations
PDF
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
PDF
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
PPT
415456121-Jiwratrwecdtwfdsfwgdwedvwe dbwsdjsadca-EVN.ppt
PPTX
Funds Management Learning Material for Beg
PDF
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
PPTX
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION
Digital Literacy And Online Safety on internet
FIRE PREVENTION AND CONTROL PLAN- LUS.FM.MQ.OM.UTM.PLN.00014.ppt
E -tech empowerment technologies PowerPoint
mera desh ae watn.(a source of motivation and patriotism to the youth of the ...
Sims 4 Historia para lo sims 4 para jugar
Rose毕业证学历认证,利物浦约翰摩尔斯大学毕业证国外本科毕业证
Introduction to the IoT system, how the IoT system works
Unit-1 introduction to cyber security discuss about how to secure a system
Best Practices for Testing and Debugging Shopify Third-Party API Integrations...
Power Point - Lesson 3_2.pptx grad school presentation
Internet___Basics___Styled_ presentation
presentation_pfe-universite-molay-seltan.pptx
Exploring VPS Hosting Trends for SMBs in 2025
t_and_OpenAI_Combined_two_pressentations
Vigrab.top – Online Tool for Downloading and Converting Social Media Videos a...
💰 𝐔𝐊𝐓𝐈 𝐊𝐄𝐌𝐄𝐍𝐀𝐍𝐆𝐀𝐍 𝐊𝐈𝐏𝐄𝐑𝟒𝐃 𝐇𝐀𝐑𝐈 𝐈𝐍𝐈 𝟐𝟎𝟐𝟓 💰
415456121-Jiwratrwecdtwfdsfwgdwedvwe dbwsdjsadca-EVN.ppt
Funds Management Learning Material for Beg
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
June-4-Sermon-Powerpoint.pptx USE THIS FOR YOUR MOTIVATION

Making Symfony Services async with RabbitMq (and more Symfony)

  • 1. It’s all about eXperience Gaetano Giunta PHP London July 2015 Making Symfony Services async with RabbitMq (and more Symfony) PechaKucha style!
  • 2. A case study: generating M$Office docs 2 The needs • 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 • Has anyone tried generating OOXML by hand?
  • 3. A case study: generating M$Office docs 3 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
  • 4. A case study: generating M$Office docs 4 …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 server PHP Libre Office Waiting processes
  • 5. TextBook scenario for introducing queues 5 Web server Worker ? Rabbit MQ Libre Office PHP
  • 6. TextBook scenario for introducing queues 6 Web server Worker ? Rabbit MQ Libre Office PHP
  • 7. TextBook scenario for introducing queues 7 Web server PHP ! Rabbit MQ Libre Office PHP
  • 8. TextBook scenario for introducing queues 8 Web server PHP ! Rabbit MQ Libre Office PHP
  • 9. TextBook scenario for introducing queues 9 Web server Symfony !!! Rabbit MQ Libre Office PHP
  • 10. TextBook scenario for introducing queues 10 Web server Symfony !!! Rabbit MQ Libre Office PHP
  • 11. The rationale 11 • Same library handling both sides of the connection • Easier to troubleshoot • Sf Console component is lovely • Everything developed in a single repository • No need to learn new languages • Everything which I can rewrite in PHP, I eventually will* * = 3rd whimsical law of Gaetano
  • 12. The details 12 • Json used as payload encoding • The worker has been made thread-safe • Again, thanks to Symfony: the « Process » Component • It spins up a new php process each time it receives a command • The new process executes the command • Bonus: a ‘watchdog’ to restart workers via crontab if they die Symfony listener Symfony listener Symfony listener Symfony worker Libre Office Libre Office W
  • 13. The evolution 13 • What is exactly a « queued command » ? • For starters, each existing Symfony console command! • Why not every existing Symfony Service? • Allows to run existing services asynchronously • As long as their arguments are serializable to json • Not a project-specific tool any more • Could be turned into a Bundle • … • Profit!
  • 14. The problems 14 • Assumes good security on the network • Low throughput • Spinning up a new php worker process takes time • Could we use php-fpm to communicate to workers instead? • Am I reinventing the wheel? • Others? • Suggestions are welcome
  • 15. I’ll be here all night 15 THANK YOU https://github.com/kaliop-uk/kueueingbundle • @gggeek • www.kaliop.co.uk