Why & how making asynchronous tasks in PHP PHPTour Lyon 2014 - 24/06/2014
Making asynchronoustasks in PHP
View Slide
Olivier Dolbeau@odolbeauWeb ArchitectAbout me
RIDESHARINGCost ofmotoring100€25€25€25€25€@BlaBlaCar_FRALONE
A fast growing community
A European phenomenon
Your visitors don’t want to wait!and if they have to, theydon’t want to know it
For you :
Your web servers want to maketheir job!(they don’t care about emails other boring tasks)
Separating concernsServeurwebConsumerConsumerConsumerConsumerConsumer
Separating concerns
How Rabbit work?
With more consumers
You can add simple routing logic
Or more complex logic
How your app talks to RabbitMQ?
With the PECL extensionThanks to Pieter de ZwartSee: pdezwart/php-amqpUse librabbitmq (alanxz/rabbitmq-c)
How to connect to RabbitMQ?
How to publish a message?
How to consume a message?
It’s a trap !
get > consume● consume is a blocking call● you don’t want blocking calls in yourapplication !● Use “get” method with a poll-interval
Wait 30 secondsand retry!
Wait 3 minutesand retry!
Wait half an hourand retry!
Swarrot
Existing processors
Last tip !
Making asynchronous tasks is good(even in PHP)
@odolbeauhttps://joind.in/ 11237https://github.com/swarrot/swarrothttps://speakerdeck.com/odolbeau/asynchronous-tasks-in-php