Introducing Amazon SQS

A presentation at PHPSW Tips & Tricks, June 2016 in June 2016 in Bristol, UK by Lee Stone

Slide 1

Slide 1

Introducing Amazon SQS

Slide 2

Slide 2

Meet Lee @leesto • PHPSW Organiser • Web Team Lead for Gradwell • Theatre Tech • Theme Park Fan • Occasional Photographer

Slide 3

Slide 3

What is SQS – Amazon Web Services “Amazon SQS is a distributed queue system that enables web service applications to quickly and reliably queue messages that one component in the application generates to be consumed by another component. A queue is a temporary repository for messages that are awaiting processing.”

Slide 4

Slide 4

Why Queues? Ideal for tasks we don’t need to complete in real time Don’t keep the user waiting Help handle incoming data / content Help scale large tasks

Slide 5

Slide 5

Why SQS? Amazon runs the service for you High availability Free for the first 1,000,000 requests per month $0.50 per 1 million after AWS SDK

Slide 6

Slide 6

Queues Hold the messages to be processed Uniquely named per account Ability to build in a processing delay (up to 15 minutes) Can be created / configured through the UI or API

Slide 7

Slide 7

Messages Contains the actual job you want processed 1 blob - up to 256 KB Found it useful to have this as a JSON object Option for storing additional attributes

Slide 8

Slide 8

Create a Message Need to know the URL - separate call to get the URL from a name $this -> awsClient -> sendMessage ( array ( 


'QueueUrl' => 'http://sqs.us-east-1.amazonaws.com/123456789012/ myQueue' , 


'MessageBody' => 'Hello World' , 
 )) ;

Slide 9

Slide 9

Retrieve a Message Returns a Response model - check for Messages array Can implement long polling Queues define a ‘message visibility’ period $this -> awsClient -> receiveMessage ( array ( 


‘QueueUrl' => 'http://sqs.us-east-1.amazonaws.com/123456789012/ myQueue' , 
 )) ;

Slide 10

Slide 10

Gotchas First in, First out not guaranteed They guarantee ‘at least once’ delivery Retention Periods - default 4 days, max 14 days

Slide 11

Slide 11

Wait… There’s More Security Policies Message Attributes Dead Letter Queues Batch Processing

Slide 12

Slide 12

Thank You Questions?

Slide 13

Slide 13

joind.in/18340 @leesto lee@leestone.co.uk