Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Queues And The Giant beanstalkd

Queues And The Giant beanstalkd

In the modern world of scaling web applications, queues have become a go-to for increasing performance by parallelizing and backgrounding heavy duty tasks. Learn practical usages of queues through beanstalkd.

Given at Feb 2013 DallasPHP meeting and ConFoo 2013

Daniel Cousineau

February 13, 2013
Tweet

More Decks by Daniel Cousineau

Other Decks in Programming

Transcript

  1. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com Asynchronous

    Computation Multi-threading Multi-Process Memory Thread Thread Thread process process process memory Memory Memory
  2. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com Race

    Condition A B Fetch Z Work Z 5 5 Work Fetch Z 5
  3. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com Race

    Condition A B Fetch Z Work Z 5 10 Work 10 Work Fetch Z 5 5
  4. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com Race

    Condition A B Fetch Z Fetch Z Work Z 5 5 Work 10 Work 15 15 5 10
  5. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com Locking

    A B Fetch Z Fetch Z Work Z 5 Work 15 15 15 B 5 A wait wait
  6. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com Locking

    A B Fetch Z Fetch Z Work Z 5 Work 15 15 Work 25 25 15 B 5 A wait wait
  7. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com DEAD

    LOCKS A B Fetch Z Z 5 5 Fetch Y A Y 10 b 10 Fetch Y Fetch Z
  8. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com DEAD

    LOCKS A B Fetch Z Z 5 5 Fetch Y A Y 10 b 10 Fetch Y Fetch Z wait wait wait wait wait wait wait wait wait
  9. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com job

    1 job 2 job 3 worker 1 worker 2 reserve job 1
  10. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com job

    1 job 2 job 3 worker 1 worker 2 reserve job 1 job 2
  11. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com job

    2 job 3 worker 1 worker 2 Completed Reserve job 3 job 2
  12. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com do

    work update database or save file[s] or new job all data necessary to complete job
  13. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com resize

    image make thumbs Original Location thumbnail[s] image file new Name[s]
  14. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com post

    tweet api response twitter id access tokens tweet text metadata
  15. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com A:

    10 B: 20 B: 25 worker 1 worker 2 reserve a: 10 A: ? B: ?
  16. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com A:

    10 B: 20 B: 25 worker 1 worker 2 reserve a: 10 B: 20 A: ? B: ?
  17. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com B:

    20 B: 25 worker 1 worker 2 Completed Reserve B: 25 B: 20 A: 10 B: ?
  18. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com A:

    10 B: 20 B: 25 worker 1 worker 2 reserve a: 10 A: ? B: ?
  19. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com A:

    10 B: 20 B: 25 worker 1 worker 2 reserve a: 10 B: 20 A: ? B: ?
  20. Daniel Cousineau // follow me : @dcousineau or http://dcousineau.com worker

    1 worker 2 B: 25 B: 20 A: 10 B: ? A: 10 B: 20 B: 25 STUCK!
  21. Q& A Put your questions Daniel Cousineau // follow me

    : @dcousineau or http://dcousineau.com
  22. THANKS. FOR YOUR ATTENTION Daniel Cousineau // follow me :

    @dcousineau or http://dcousineau.com http://joind.in/7873