Top Banner
JOB QUEUE web is more than request and response Abhinav Lal
19

Job Queue - web is more than request and response

May 17, 2015

Download

Technology

Abhinav Lal

Job queue presentation for PHP meetup bangalore on 24th April 2010
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Job Queue - web is more than request and response

JOB QUEUEweb is more than request and responseAbhinav Lal

Page 2: Job Queue - web is more than request and response

WHO AM I

CTO at Naabo TurboDoc.in Cooking PHP for 4 years

Page 3: Job Queue - web is more than request and response

Job Queue

In computer science, message queues and mailboxes are software-

engineering components used for interprocess communication, or for inter-thread communication within

the same process.http://en.wikipedia.org/wiki/Message_queue

Any long running work which does not require user feedback should be done in background.

Page 4: Job Queue - web is more than request and response

Order processing without job queue

Page 5: Job Queue - web is more than request and response

Order processing with job queue

Page 6: Job Queue - web is more than request and response

Jobs to run in background

• Sending email

• Fetching RSS feed periodically

• Interacting with other application API

• Complex report generation

• Log analysis

• cleaning file system

o periodically or after certain action.

Page 7: Job Queue - web is more than request and response

But I can use cron for that

Asynchronous

Low latency

Reliable

Scalable

Page 8: Job Queue - web is more than request and response

Options out there

Page 9: Job Queue - web is more than request and response

Options out there

Page 10: Job Queue - web is more than request and response

Gearman = Manager

Developed by Danga (People behind memcache) Open source C daemon Native PHP extension Persistence – drizzle, postgres, memcache, sqllite Distributed No single point of failure

Page 11: Job Queue - web is more than request and response

Beanstalkd

Open source C daemon Fast Persistence – bin log file Distributed PHP library – pheanstalk, beanstalk Simple protocol

Page 12: Job Queue - web is more than request and response

Simple setup

Client script

JobServe

r

Worker script

Page 13: Job Queue - web is more than request and response

Beanstalkd

Page 14: Job Queue - web is more than request and response

Beanstalkd client

Page 15: Job Queue - web is more than request and response

Beanstalkd Worker

Page 16: Job Queue - web is more than request and response

Beanstalkd Goodness

Named Tubes – max 200 bytes Priority Delayed job Bury Kick

Page 17: Job Queue - web is more than request and response

Advantages

Speed up work Parallel and asynchronous work Scales easily Call functionality in other programming language Does not block your apache process.

Page 18: Job Queue - web is more than request and response

Running worker script

Use supervisord Gearman Manager Gear up Check for memory leaks in worker scripts Restart your worker scripts after certain number of

runs.

Page 19: Job Queue - web is more than request and response

QuestionsAbhinav LalBlog: abhinavlal.wordpress.comTwitter: @abhinavlalSlideshare: slideshare.net/abhinavlal