BACKGROUND JOB PROCESSING
CHUCK REEVES @MANCHUCK
DO'S AND DON'TS
BACKGROUND JOB PROCESSING DO'S AND DON'TS BACKGROUND JOB - - PowerPoint PPT Presentation
CHUCK REEVES @MANCHUCK BACKGROUND JOB PROCESSING DO'S AND DON'TS BACKGROUND JOB PROCESSING - DO'S AND DON'TS IMAGE PROCESSOR UPLOAD IMAGE PROCESS IMAGE ENTERS QUEUE ZendCon 2016 BACKGROUND JOB PROCESSING - DO'S AND DON'TS THE PROBLEM
BACKGROUND JOB PROCESSING
CHUCK REEVES @MANCHUCK
DO'S AND DON'TS
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
ZendCon 2016UPLOAD IMAGE IMAGE PROCESSOR ENTERS QUEUE PROCESS IMAGE
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
THE PROBLEM CHALLENGE
▸ Crawl Google Merchant Center ▸ Crawl Google Ad Words ▸ Crawl Google Analytics ▸ Match Data ▸ Analyze Data ▸ Make Decisions ▸ POST/PUT Google Ad Words ▸ Within 4 hours
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
ZendCon 2016TIME OF DAY CATALOGUE CRAWLER ENTERS QUEUE CRAWLS CATALOGUE BATCHES CATALOGUE BATCH PROCESSOR ENTERS QUEUE PROCESSES BATCH
TYPE A QUOTE HERE.
Johnny Appleseed
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
ZendCon 2016BACKGROUND JOB PROCESSING - DO'S AND DON'TS
REALTIME (ACCORDING TO POSIX)
Ability of a system to provide a service within a bounded response time
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
PROBLEMS CHALLENGES YOU WILL FACE
▸ Memory ▸ IO/Socket Blocks ▸ Network stack ▸ Timing of sequential jobs ▸ Queue
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
QUEUES
▸ Push/Pull (poll) ▸ Priority ▸ Time To Live ▸ Delay ▸ Tubes
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
TERMS
▸ Ready ▸ Reserved ▸ Delayed ▸ Buried ▸ Touch
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
JOB LIFE CYCLE
Time
RESERVED DELAY TTR
Posted Complete Start
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
JOB LIFE CYCLE GOTCHA
TTR
Time
DELAY RESERVED
Posted
TTR
Start
RESERVED
Re-Queued Start
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
ZendCon 2016CHECKPOINTS
PUSH OR PULL?
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
PUSH OR PULL?
▸ Hosted ▸ Queue Starts worker ▸ Scales with size of queue ▸ Limits number of workers ▸ Limited control over worker
environment
▸ Self-Hosted ▸ Process needed to check for new
queue
▸ Resources required for polling ▸ Additional delay ▸ Control of the Environment
PUSH PULL
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
BEANSTALKD - PULL
▸ In Memory ▸ Lightweight text protocol ▸ Useful reporting ▸ Cannot scale
PROS CONS
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
GEARMAN - PULL
▸ In Memory ▸ Distributed ▸ Workers can specify their capabilities ▸ Persistent with MySQL Plugin ▸ But Don't use it ▸ PHP Lib has Limited reporting ▸ Workers connecting to multiple job
servers can cause delays in jobs
▸ Job types can be confusing ▸ Simple Priorities
PROS CONS
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
RESQUE - PULL
▸ Redis ▸ Easy Protocol ▸ Management GUI ▸ Not really a Job Queue ▸ Limited reporting ▸ Roll your own if you know Redis
PROS CONS
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
RABBITMQ - PULL
▸ Easy Protocol ▸ Management GUI ▸ Persistent ▸ Not really a Job Queue ▸ Limited reporting ▸ Roll your own if you know Redis ▸ Memory error
PROS CONS
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
WHAT YOU SHOULD DO - POLLING QUEUES
JOB PROCESS JOB PROCESS JOB PROCESS JOB PROCESS JOB PROCESS MINION MINION MINION OVERLORD (POLLS)
SERVER
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
WHAT YOU SHOULD NOT DO - POLLING QUEUES
▸ Process every job with one process ▸ Have worker processes talk to the queue ▸ Use PCNTL (well...) ▸ PHP 7 Could be better ▸ But not on Windows
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
JOB
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
JOB
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
JOB AGGREGATE
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
JOB SERVICE
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
JOB HANDLER
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
JOB HANDLER
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
JOB HANDLER
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
AMAZON SQS/SNS/LAMBDA
▸ Scales Easily ▸ Easy Protocol (API) ▸ Management GUI ▸ Workers must be pre-defined ▸ Jobs can take between 10 seconds to 15 min to pop out ▸ Python, Java or NodeJS
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
GOOGLE TASK QUEUE
▸ Scales Easily ▸ Queues can be programmatically created or through API ▸ Supports push and pull queues ▸ Schedule Tasks ▸ On Demand TTR
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
FINIAL THOUGHTS
▸ Limit Connections to the Database ▸ Validate data going into a job ▸ Handel Errors ▸ Remove job on error ▸ Central Logging
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
BACKGROUND JOB PROCESSING - DO'S AND DON'TS
CHUCK REEVES @MANCHUCK