Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

//setup things

while($run){

//do some things

sleep(1);

}

//shutdown things

Publish

Database

Seed

Queue

Worker

Web App

Check If Ready

Queue Up Work

Delay Job

Publish File

Select Stale URLs

Add as Jobs

Wait A While

Page URL

Keywords

Links

Last Update

Multiple Workers

Reasonable Timeout

Queue

Fetch User Data

Generate Content

Send Email

Create New User

Add ID as Job

For Two Channels

Multiple Channels

Worker(n)

Transcode

Queue

Fetch Page

Extract Keywords

Extract Links

Upsert Data

Check If Done

Convert File

Queue Thumbnail

Queue Keyword

Twitter Streaming API

Publish

Transcode

Thumbnail

Keyword

(lets see some real code)

Thumbnail

Keyword

Check if Done

Extract Frames

Queue Publish

Check if Done

Extract Keywords

Queue Publish

PHP Daemons

and

Long Running

Control

gearman

beanstalkd

rabbitmq

SQS/SNS

Processes

Respond to

signals.

blocking

reservations

streaming

In case you only recognize people by their profile pics.

Process a post,

send an email,

Tim Lytle - @tjlytle

parse a log.

pcntl_signal()

declare()

pcntl_signal_dispatch()

Building stuff PhoneBurner

Retired Contract Developer

Daemons

Why? Time.

(and if it's needed)

3

Processing files. Reports. Migrations. Batch inserts.

Stop

2

How?

Restart.

(or Debian)

upstart

systemd

supervisord

fork

Things that take time.

responsibly.

Things that happen over time.

start on runlevel [2345]

respawn

respawn limit 5 60

setuid vagrant

chdir /vagrant/cli

exec php twitter.php

Don't exit.

1

Queue processing. Real-time data. Workers.

Or that

must be

successful.

And things

like them.

Queues

Alternatives

webhooks • platforms

Abstract

Perhaps better

the setup.

than queues.

Just your

bootstrap.

CRON might

work.

Okay for

a while.

Probably

shouldn't stop.

Use next() instead

of a foreach loop.

Runs as

a daemon.

For Example:

Like a queue

without jobs.

You could buy

this book.

Web

Crawler

Daemon should

restart.

You probably

shouldn't

do this.

Wait for the

next job.

Process

Email

Use at least

one of these.

Track what

was done.

Easy on

Ubuntu.

Stop

eventually.

Long running

process is done.

Retry until

it's done.

Learn more about creating dynamic, engaging presentations with Prezi