Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Making asynchronous tasks in PHP
Olivier Dolbeau
April 07, 2014
Programming
6
3k
Making asynchronous tasks in PHP
Why & how making asynchronous tasks in PHP
SFLIve2014 - 04/07/2014 with Grégoire Pineau
Olivier Dolbeau
April 07, 2014
Tweet
Share
More Decks by Olivier Dolbeau
See All by Olivier Dolbeau
odolbeau
0
120
odolbeau
2
280
odolbeau
0
32
odolbeau
0
250
odolbeau
0
55
odolbeau
0
600
odolbeau
4
640
odolbeau
1
290
odolbeau
1
310
Other Decks in Programming
See All in Programming
mizdra
7
4.9k
attsumi
1
460
yshrsmz
1
460
akatsukinewgrad
0
220
azdaroth
0
170
azdaroth
0
140
line_developers_tw
0
540
koher
7
480
dictoss
0
170
ken3ypa
0
160
mu2in
0
150
akatsukinewgrad
0
220
Featured
See All Featured
scottboms
251
11k
jacobian
255
20k
sachag
267
17k
vanstee
116
4.8k
sachag
446
36k
danielanewman
200
20k
productmarketing
5
660
roundedbygravity
241
21k
philhawksworth
192
8.8k
smashingmag
283
47k
akmur
252
19k
ufuk
56
5.4k
Transcript
Making asynchronous tasks in PHP The easy way
Olivier Dolbeau Dev @odolbeau Who ? Grégoire Pineau Dev @lyrixx
Summary • Why? • How? • Problems? Solutions! • Tips
None
None
None
None
None
None
Your visitors don’t want to wait! (and if they have
to, they don’t want to know it) First reason to do asynchronous
Your web servers want to make their job! (they don’t
care about emails other boring tasks) Second reason to do asynchronous
None
Separating concerns Serveur web Consumer Consumer Consumer Consumer Consumer
None
How Rabbit work?
With more consumers
You can add simple routing logic
Or more complex logic
None
How your app talks to RabbitMQ?
With the PECL extension Thanks to Pieter de Zwart See:
pdezwart/php-amqp Use librabbitmq (alanxz/rabbitmq-c)
With videlalvaro/php-amqplib
None
</troll>
How to connect to RabbitMQ?
How to publish a message?
How to consume a message?
None
None
None
None
None
get > consume • consume is a blocking call •
you don’t want blocking calls in your application ! • Use “get” method with a poll-interval
None
None
None
None
None
None
None
None
None
None
Wait 30 seconds and retry!
Wait 3 minutes and retry!
Wait half an hour and retry!
None
None
None
None
None
None
<troll>
None
None
None
You can take a look at the code ! https://github.com/odolbeau/sflive2014-workers
Swarrot https://github.com/swarrot/swarrot
None