SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Downloaden Sie, um offline zu lesen
Architecting with Queues for
Scale and Separation
Sandy Smith
Northeast PHP 2015
Insert Text Here
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Setting Expectations
2
Architecting with Queues - Sandy Smith - Northeast PHP 2015
What this talk is NOT
•A queues HOWTO (though there is some)
•Benchmark bonanza
•An Azure talk (though there is some)
3
Architecting with Queues - Sandy Smith - Northeast PHP 2015
What this talk IS
•An architecture talk
•A challenge to think differently about your applications
•A story about rapidly developing an app
4
Architecting with Queues - Sandy Smith - Northeast PHP 2015
The Challenge
5
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Social Contest
•Show off Azure + PHP
•People submit tweets to enter contest
•Pull specified keywords from Twitter queue (prefiltered by
Node.js app)
•Human admins filter out inappropriate content
•Humans or computer pulls out winner from approved entries,
on timer or arbitrarily
•Display latest entries and latest winners to public
6
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Stretch goals
•Allow any size contest
•Assume global contest with distributed moderators
7
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Quick refresher
Performance vs. Scaling

Vertical vs. Horizontal Scaling
8
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Initial design
9
Architecting with Queues - Sandy Smith - Northeast PHP 2015
System-level view
10
Twitter
Firehose
Entries
node.js app
Contest App DB
Public
Admins
Architecting with Queues - Sandy Smith - Northeast PHP 2015
The real bottleneck
What’s the slowest and
most variable part of any
application?
11
Insert Text Here
Architecting with Queues - Sandy Smith - Northeast PHP 2015
The real bottleneck
12
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Traditional database design
•Group by kind
•Keep metadata with object or in metadata tables
•Objects (Document, Person, Account) are most important
•Reinforced by TableGateway, ActiveRecord patterns, and ORM
and framework module generator defaults
•Works for 80+% of cases
13
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Tradeoffs of traditional design
•Everything’s in one table, even when you routinely only need a
subset
•Typically one master writes, replicants read
•Design is focused around what something is, not its state or
other attribute
•Requires creative solutions for horizontal scaling
•Encourages (but does not require) centralizing logic for a given
type of data
14
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Worst of all…
•This design really didn’t show off all the stuff in Azure
15
(We had a week left)
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Redesign time
16
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Redesign goals
•Include as much Azure stuff as is reasonable
•Implement the stretch goals of scalability
17
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Queues to the rescue!
(Plus some other cool stuff)
18
Architecting with Queues - Sandy Smith - Northeast PHP 2015
New approach
•Keep long term but fast storage
•Central concern is not the Thing (Entry) but Status
– Unapproved

– Approved

– Denied

– Winner

•Separate updates to long term storage from status changes
•Minimal impact to working code
19
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Azure queuing options
Azure Queues (duh)
•Simple
•“Short”-lived (<7 days)
•Used within Azure
•Uses REST
•Can track message
processing
20
Azure Service Bus
•Enterprisey
•Long-lived
•In Azure or private cloud
•Can use AMQP, REST, or
API
•Can publish/subscribe
•Can batch requests
•Can guarantee FIFO
•etc.
See https://msdn.microsoft.com/en-us/library/azure/hh767287.aspx
Architecting with Queues - Sandy Smith - Northeast PHP 2015
More options
•Anything you can install on Linux or Windows (RabbitMQ,
ZeroMQ, Kafka, Kestrel, ActiveMQ, etc.)
•Any relational or NoSQL database
•Azure Tables - Simple REST NoSQL store with a twist
21
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Solutions
•Long term storage and display retrieval: Azure Table
•Since Node.js app already used it, use Service Bus to store
changes in status for consistency
•Have daemons pull incoming status changes out and write
them to the Table
22
Architecting with Queues - Sandy Smith - Northeast PHP 2015
New design
23
__construct(EntryAccessor $mapper)
Entry
EntryAccessor
__construct($proxy, $table)
EntryAccessorTable
EntryRepository
__construct($dbh)
EntryRepositoryTable
Entries
Incoming
Daemon
Denied
Winner
Approv-
ed
In-
coming
Approved
Daemon
Denied
Daemon
Winner
Daemon
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Azure Table basics
24
require_once 'vendorautoload.php';

use WindowsAzureCommonServicesBuilder;

use WindowsAzureCommonServiceException;

use WindowsAzureTableModelsEntity;

use WindowsAzureTableModelsEdmType;



// Create table REST proxy.

$tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString);



try {

// Create table.

$tableRestProxy->createTable("mytable");

} catch(ServiceException $e){

// Handle exception based on error codes and messages.

}



$entity = new Entity();

$entity->setPartitionKey("pk");

$entity->setRowKey("1");

$entity->addProperty("PropertyName", EdmType::STRING, "Sample");



try {

$tableRestProxy->insertEntity("mytable", $entity);

} catch(ServiceException $e){

// Handle exception based on error codes and messages.

}
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Create and send with Service Bus
25
use WindowsAzureServiceBusModelsQueueInfo;

use WindowsAzureCommonServiceException;

use WindowsAzureCommonServicesBuilder;



$serviceBusRestProxy = ServicesBuilder::getInstance()-
>createServiceBusService($connectionString);



try {

$queueInfo = new QueueInfo("myqueue");

$serviceBusRestProxy->createQueue($queueInfo);

} catch(ServiceException $e) {

// handle error

}



try {

// Create message.

$message = new BrokeredMessage();

$message->setBody("my message");



// Send message.

$serviceBusRestProxy->sendQueueMessage("myqueue", $message);

} catch(ServiceException $e) {

// handle error

}
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Receive with Service Bus
26
use WindowsAzureServiceBusModelsQueueInfo;

use WindowsAzureCommonServiceException;

use WindowsAzureCommonServicesBuilder;



$serviceBusRestProxy = ServicesBuilder::getInstance()-
>createServiceBusService($connectionString);



try {

// Set the receive mode to PeekLock (default is ReceiveAndDelete).

$options = new ReceiveMessageOptions();

$options->setPeekLock(true);



// Receive message.

$message = $serviceBusRestProxy->receiveQueueMessage("myqueue", $options);

echo "Body: ".$message->getBody()."<br />";

echo "MessageID: ".$message->getMessageId()."<br />";



// *** Process message here ***



// Delete message.

$serviceBusRestProxy->deleteMessage($message);

} catch(ServiceException $e){

// handle error

}
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Benefits
•Queues add safety: if processing fails, main store is unchanged
•App doesn’t wait for process-update-delete cycle
– Concerns more separated

– Scaling is simpler

•Can move queue processing to separate machines
•Trivial to move to different stores for each status
•Very performant with up-to-second data
27
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Challenges
•No full ACID
•Safety is largely in the application layer
•Potential for race conditions
– Humans suck
28
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Takeaways
•Look for more than just long processes
•Use queues to decouple functionality
•Look for status changes, e.g. workflow
•Is the type of data the most important aspect of your data?
– It usually is!

•Design for replacement of components
– Makes changes easier (not easy)
29
Architecting with Queues - Sandy Smith - Northeast PHP 2015
Links
•Azure: http://azure.microsoft.com/en-us/
•Social Contest:

https://github.com/MusketeersMe/SocialContest
•Me
– @SandyS1

– http://phparch.com/

•Feedback! https://joind.in/14720
•php[world] (Nov 16–20) world.phparch.com
•Slides will be at: slideshare.net/SandySmith
30

Weitere ähnliche Inhalte

Was ist angesagt?

Node.js and couchbase Full Stack JSON - Munich NoSQL
Node.js and couchbase   Full Stack JSON - Munich NoSQLNode.js and couchbase   Full Stack JSON - Munich NoSQL
Node.js and couchbase Full Stack JSON - Munich NoSQLPhilipp Fehre
 
OSCON2014: Understanding Hypervisor Selection in Apache CloudStack
OSCON2014: Understanding Hypervisor Selection in Apache CloudStackOSCON2014: Understanding Hypervisor Selection in Apache CloudStack
OSCON2014: Understanding Hypervisor Selection in Apache CloudStackTim Mackey
 
MySQL Monitoring with Zabbix
MySQL Monitoring with ZabbixMySQL Monitoring with Zabbix
MySQL Monitoring with ZabbixFromDual GmbH
 
Scaling wix to over 70 m users
Scaling wix to over 70 m usersScaling wix to over 70 m users
Scaling wix to over 70 m usersYoav Avrahami
 
CFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful CodeCFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful Codeindiver
 
Redis Labs and SQL Server
Redis Labs and SQL ServerRedis Labs and SQL Server
Redis Labs and SQL ServerLynn Langit
 
Drupal High Availability High Performance 2012
Drupal High Availability High Performance 2012Drupal High Availability High Performance 2012
Drupal High Availability High Performance 2012Amazee Labs
 
Роман Новиков "Best Practices for MySQL Performance & Troubleshooting with th...
Роман Новиков "Best Practices for MySQL Performance & Troubleshooting with th...Роман Новиков "Best Practices for MySQL Performance & Troubleshooting with th...
Роман Новиков "Best Practices for MySQL Performance & Troubleshooting with th...Fwdays
 
Data stores: beyond relational databases
Data stores: beyond relational databasesData stores: beyond relational databases
Data stores: beyond relational databasesJavier García Magna
 
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance TuningWebinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance TuningSeveralnines
 
4th Lecture: JSP and such
4th Lecture:  JSP and such4th Lecture:  JSP and such
4th Lecture: JSP and suchManolis Vavalis
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelAlex Thissen
 
Nagios Conference 2014 - Luis Contreras - Monitoring SAP System with Nagios Core
Nagios Conference 2014 - Luis Contreras - Monitoring SAP System with Nagios CoreNagios Conference 2014 - Luis Contreras - Monitoring SAP System with Nagios Core
Nagios Conference 2014 - Luis Contreras - Monitoring SAP System with Nagios CoreNagios
 
Essential Camel Components
Essential Camel ComponentsEssential Camel Components
Essential Camel ComponentsChristian Posta
 
Planning a successful private cloud - CloudStack Collaboration Europe 2013
Planning a successful private cloud - CloudStack Collaboration Europe 2013Planning a successful private cloud - CloudStack Collaboration Europe 2013
Planning a successful private cloud - CloudStack Collaboration Europe 2013Tim Mackey
 
Building a Dev/Test Cloud with Apache CloudStack
Building a Dev/Test Cloud with Apache CloudStackBuilding a Dev/Test Cloud with Apache CloudStack
Building a Dev/Test Cloud with Apache CloudStackke4qqq
 
ASP.NET Scalability - VBUG London
ASP.NET Scalability - VBUG LondonASP.NET Scalability - VBUG London
ASP.NET Scalability - VBUG LondonPhil Pursglove
 
Lessons from the Trenches - Building Enterprise Applications with RavenDB
Lessons from the Trenches - Building Enterprise Applications with RavenDBLessons from the Trenches - Building Enterprise Applications with RavenDB
Lessons from the Trenches - Building Enterprise Applications with RavenDBOren Eini
 
Membase Intro from Membase Meetup San Francisco
Membase Intro from Membase Meetup San FranciscoMembase Intro from Membase Meetup San Francisco
Membase Intro from Membase Meetup San FranciscoMembase
 

Was ist angesagt? (20)

Serverless Go at BuzzBird
Serverless Go at BuzzBirdServerless Go at BuzzBird
Serverless Go at BuzzBird
 
Node.js and couchbase Full Stack JSON - Munich NoSQL
Node.js and couchbase   Full Stack JSON - Munich NoSQLNode.js and couchbase   Full Stack JSON - Munich NoSQL
Node.js and couchbase Full Stack JSON - Munich NoSQL
 
OSCON2014: Understanding Hypervisor Selection in Apache CloudStack
OSCON2014: Understanding Hypervisor Selection in Apache CloudStackOSCON2014: Understanding Hypervisor Selection in Apache CloudStack
OSCON2014: Understanding Hypervisor Selection in Apache CloudStack
 
MySQL Monitoring with Zabbix
MySQL Monitoring with ZabbixMySQL Monitoring with Zabbix
MySQL Monitoring with Zabbix
 
Scaling wix to over 70 m users
Scaling wix to over 70 m usersScaling wix to over 70 m users
Scaling wix to over 70 m users
 
CFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful CodeCFWheels - Pragmatic, Beautiful Code
CFWheels - Pragmatic, Beautiful Code
 
Redis Labs and SQL Server
Redis Labs and SQL ServerRedis Labs and SQL Server
Redis Labs and SQL Server
 
Drupal High Availability High Performance 2012
Drupal High Availability High Performance 2012Drupal High Availability High Performance 2012
Drupal High Availability High Performance 2012
 
Роман Новиков "Best Practices for MySQL Performance & Troubleshooting with th...
Роман Новиков "Best Practices for MySQL Performance & Troubleshooting with th...Роман Новиков "Best Practices for MySQL Performance & Troubleshooting with th...
Роман Новиков "Best Practices for MySQL Performance & Troubleshooting with th...
 
Data stores: beyond relational databases
Data stores: beyond relational databasesData stores: beyond relational databases
Data stores: beyond relational databases
 
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance TuningWebinar slides: Our Guide to MySQL & MariaDB Performance Tuning
Webinar slides: Our Guide to MySQL & MariaDB Performance Tuning
 
4th Lecture: JSP and such
4th Lecture:  JSP and such4th Lecture:  JSP and such
4th Lecture: JSP and such
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
 
Nagios Conference 2014 - Luis Contreras - Monitoring SAP System with Nagios Core
Nagios Conference 2014 - Luis Contreras - Monitoring SAP System with Nagios CoreNagios Conference 2014 - Luis Contreras - Monitoring SAP System with Nagios Core
Nagios Conference 2014 - Luis Contreras - Monitoring SAP System with Nagios Core
 
Essential Camel Components
Essential Camel ComponentsEssential Camel Components
Essential Camel Components
 
Planning a successful private cloud - CloudStack Collaboration Europe 2013
Planning a successful private cloud - CloudStack Collaboration Europe 2013Planning a successful private cloud - CloudStack Collaboration Europe 2013
Planning a successful private cloud - CloudStack Collaboration Europe 2013
 
Building a Dev/Test Cloud with Apache CloudStack
Building a Dev/Test Cloud with Apache CloudStackBuilding a Dev/Test Cloud with Apache CloudStack
Building a Dev/Test Cloud with Apache CloudStack
 
ASP.NET Scalability - VBUG London
ASP.NET Scalability - VBUG LondonASP.NET Scalability - VBUG London
ASP.NET Scalability - VBUG London
 
Lessons from the Trenches - Building Enterprise Applications with RavenDB
Lessons from the Trenches - Building Enterprise Applications with RavenDBLessons from the Trenches - Building Enterprise Applications with RavenDB
Lessons from the Trenches - Building Enterprise Applications with RavenDB
 
Membase Intro from Membase Meetup San Francisco
Membase Intro from Membase Meetup San FranciscoMembase Intro from Membase Meetup San Francisco
Membase Intro from Membase Meetup San Francisco
 

Andere mochten auch

Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Sandy Smith
 
Out of the silos and into the farm (NEPHP 2014)
Out of the silos and into the farm (NEPHP 2014)Out of the silos and into the farm (NEPHP 2014)
Out of the silos and into the farm (NEPHP 2014)Marli Mesibov
 
Unit Testing Done Right
Unit Testing Done RightUnit Testing Done Right
Unit Testing Done RightBrian Fenton
 
Iterators, ArrayAccess & Countable (Oh My!) - Madison PHP 2014
Iterators, ArrayAccess & Countable (Oh My!) - Madison PHP 2014Iterators, ArrayAccess & Countable (Oh My!) - Madison PHP 2014
Iterators, ArrayAccess & Countable (Oh My!) - Madison PHP 2014Sandy Smith
 
Multibyte string handling in PHP
Multibyte string handling in PHPMultibyte string handling in PHP
Multibyte string handling in PHPDaniel_Rhodes
 
Unicode Regular Expressions
Unicode Regular ExpressionsUnicode Regular Expressions
Unicode Regular ExpressionsNova Patch
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsdavidfstr
 
Don't Fear the Regex LSP15
Don't Fear the Regex LSP15Don't Fear the Regex LSP15
Don't Fear the Regex LSP15Sandy Smith
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsNicole Ryan
 
Don't Fear the Regex - CapitalCamp/GovDays 2014
Don't Fear the Regex - CapitalCamp/GovDays 2014Don't Fear the Regex - CapitalCamp/GovDays 2014
Don't Fear the Regex - CapitalCamp/GovDays 2014Sandy Smith
 
Lessons from a Dying CMS
Lessons from a Dying CMSLessons from a Dying CMS
Lessons from a Dying CMSSandy Smith
 
GAIQ - Regular expressions-google-analytics
GAIQ - Regular expressions-google-analyticsGAIQ - Regular expressions-google-analytics
GAIQ - Regular expressions-google-analyticsAnkita Kishore
 
Hyperlocalisation or "localising everything"
Hyperlocalisation or "localising everything"Hyperlocalisation or "localising everything"
Hyperlocalisation or "localising everything"Daniel_Rhodes
 
Architecting with Queues for Scale, Speed, and Separation (DCPHP 3/11/15)
Architecting with Queues for Scale, Speed, and Separation (DCPHP 3/11/15)Architecting with Queues for Scale, Speed, and Separation (DCPHP 3/11/15)
Architecting with Queues for Scale, Speed, and Separation (DCPHP 3/11/15)Sandy Smith
 
Regular expressions
Regular expressionsRegular expressions
Regular expressionsJames Gray
 
TDA Center Depok update 2014 (Concept)
TDA Center Depok update 2014 (Concept)TDA Center Depok update 2014 (Concept)
TDA Center Depok update 2014 (Concept)Herri Setiawan
 
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?daoswald
 

Andere mochten auch (20)

Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015Don't Fear the Regex - Northeast PHP 2015
Don't Fear the Regex - Northeast PHP 2015
 
Out of the silos and into the farm (NEPHP 2014)
Out of the silos and into the farm (NEPHP 2014)Out of the silos and into the farm (NEPHP 2014)
Out of the silos and into the farm (NEPHP 2014)
 
Unit Testing Done Right
Unit Testing Done RightUnit Testing Done Right
Unit Testing Done Right
 
Iterators, ArrayAccess & Countable (Oh My!) - Madison PHP 2014
Iterators, ArrayAccess & Countable (Oh My!) - Madison PHP 2014Iterators, ArrayAccess & Countable (Oh My!) - Madison PHP 2014
Iterators, ArrayAccess & Countable (Oh My!) - Madison PHP 2014
 
Multibyte string handling in PHP
Multibyte string handling in PHPMultibyte string handling in PHP
Multibyte string handling in PHP
 
Unicode Regular Expressions
Unicode Regular ExpressionsUnicode Regular Expressions
Unicode Regular Expressions
 
Grokking regex
Grokking regexGrokking regex
Grokking regex
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Don't Fear the Regex LSP15
Don't Fear the Regex LSP15Don't Fear the Regex LSP15
Don't Fear the Regex LSP15
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Don't Fear the Regex - CapitalCamp/GovDays 2014
Don't Fear the Regex - CapitalCamp/GovDays 2014Don't Fear the Regex - CapitalCamp/GovDays 2014
Don't Fear the Regex - CapitalCamp/GovDays 2014
 
Lessons from a Dying CMS
Lessons from a Dying CMSLessons from a Dying CMS
Lessons from a Dying CMS
 
GAIQ - Regular expressions-google-analytics
GAIQ - Regular expressions-google-analyticsGAIQ - Regular expressions-google-analytics
GAIQ - Regular expressions-google-analytics
 
Intoduction to php strings
Intoduction to php  stringsIntoduction to php  strings
Intoduction to php strings
 
Hyperlocalisation or "localising everything"
Hyperlocalisation or "localising everything"Hyperlocalisation or "localising everything"
Hyperlocalisation or "localising everything"
 
Architecting with Queues for Scale, Speed, and Separation (DCPHP 3/11/15)
Architecting with Queues for Scale, Speed, and Separation (DCPHP 3/11/15)Architecting with Queues for Scale, Speed, and Separation (DCPHP 3/11/15)
Architecting with Queues for Scale, Speed, and Separation (DCPHP 3/11/15)
 
Dom
DomDom
Dom
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
TDA Center Depok update 2014 (Concept)
TDA Center Depok update 2014 (Concept)TDA Center Depok update 2014 (Concept)
TDA Center Depok update 2014 (Concept)
 
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
 

Ähnlich wie Architecting with Queues - Northeast PHP 2015

WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf
 
OpenIDM - Flexible Provisioning Platform - April 28 Webinar
OpenIDM - Flexible Provisioning Platform - April 28 WebinarOpenIDM - Flexible Provisioning Platform - April 28 Webinar
OpenIDM - Flexible Provisioning Platform - April 28 WebinarForgeRock
 
Challenges of Implementing an Advanced SQL Engine on Hadoop
Challenges of Implementing an Advanced SQL Engine on HadoopChallenges of Implementing an Advanced SQL Engine on Hadoop
Challenges of Implementing an Advanced SQL Engine on HadoopDataWorks Summit
 
Dsdt meetup 2017 11-21
Dsdt meetup 2017 11-21Dsdt meetup 2017 11-21
Dsdt meetup 2017 11-21JDA Labs MTL
 
DSDT Meetup Nov 2017
DSDT Meetup Nov 2017DSDT Meetup Nov 2017
DSDT Meetup Nov 2017DSDT_MTL
 
Data(?)Ops with CircleCI
Data(?)Ops with CircleCIData(?)Ops with CircleCI
Data(?)Ops with CircleCIJinwoong Kim
 
Deep Dive - Usage of on premises data gateway for hybrid integration scenarios
Deep Dive - Usage of on premises data gateway for hybrid integration scenariosDeep Dive - Usage of on premises data gateway for hybrid integration scenarios
Deep Dive - Usage of on premises data gateway for hybrid integration scenariosSajith C P Nair
 
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpChalermpon Areepong
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...Amazon Web Services
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Emerson Eduardo Rodrigues Von Staffen
 
Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Jan Helke
 
PPWT2019 - EmPower your BI architecture
PPWT2019 - EmPower your BI architecturePPWT2019 - EmPower your BI architecture
PPWT2019 - EmPower your BI architectureRiccardo Perico
 
Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...
Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...
Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...DataKitchen
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Drupalcon Paris
 
Azure + DataStax Enterprise Powers Office 365 Per User Store
Azure + DataStax Enterprise Powers Office 365 Per User StoreAzure + DataStax Enterprise Powers Office 365 Per User Store
Azure + DataStax Enterprise Powers Office 365 Per User StoreDataStax Academy
 
Using Databases and Containers From Development to Deployment
Using Databases and Containers  From Development to DeploymentUsing Databases and Containers  From Development to Deployment
Using Databases and Containers From Development to DeploymentAerospike, Inc.
 
SQL Engines for Hadoop - The case for Impala
SQL Engines for Hadoop - The case for ImpalaSQL Engines for Hadoop - The case for Impala
SQL Engines for Hadoop - The case for Impalamarkgrover
 

Ähnlich wie Architecting with Queues - Northeast PHP 2015 (20)

WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release Pipelines
 
OpenIDM - Flexible Provisioning Platform - April 28 Webinar
OpenIDM - Flexible Provisioning Platform - April 28 WebinarOpenIDM - Flexible Provisioning Platform - April 28 Webinar
OpenIDM - Flexible Provisioning Platform - April 28 Webinar
 
Challenges of Implementing an Advanced SQL Engine on Hadoop
Challenges of Implementing an Advanced SQL Engine on HadoopChallenges of Implementing an Advanced SQL Engine on Hadoop
Challenges of Implementing an Advanced SQL Engine on Hadoop
 
Dsdt meetup 2017 11-21
Dsdt meetup 2017 11-21Dsdt meetup 2017 11-21
Dsdt meetup 2017 11-21
 
DSDT Meetup Nov 2017
DSDT Meetup Nov 2017DSDT Meetup Nov 2017
DSDT Meetup Nov 2017
 
Data(?)Ops with CircleCI
Data(?)Ops with CircleCIData(?)Ops with CircleCI
Data(?)Ops with CircleCI
 
Deep Dive - Usage of on premises data gateway for hybrid integration scenarios
Deep Dive - Usage of on premises data gateway for hybrid integration scenariosDeep Dive - Usage of on premises data gateway for hybrid integration scenarios
Deep Dive - Usage of on premises data gateway for hybrid integration scenarios
 
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvpZZ BC#7 asp.net mvc practice and guideline by NineMvp
ZZ BC#7 asp.net mvc practice and guideline by NineMvp
 
Windows Azure Essentials V3
Windows Azure Essentials V3Windows Azure Essentials V3
Windows Azure Essentials V3
 
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
DevOps, Continuous Integration and Deployment on AWS: Putting Money Back into...
 
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
Devops continuousintegration and deployment onaws puttingmoneybackintoyourmis...
 
Ipc mysql php
Ipc mysql php Ipc mysql php
Ipc mysql php
 
Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']Bye bye $GLOBALS['TYPO3_DB']
Bye bye $GLOBALS['TYPO3_DB']
 
PPWT2019 - EmPower your BI architecture
PPWT2019 - EmPower your BI architecturePPWT2019 - EmPower your BI architecture
PPWT2019 - EmPower your BI architecture
 
Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...
Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...
Open Data Science Conference Big Data Infrastructure – Introduction to Hadoop...
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3
 
SD Times - Docker v2
SD Times - Docker v2SD Times - Docker v2
SD Times - Docker v2
 
Azure + DataStax Enterprise Powers Office 365 Per User Store
Azure + DataStax Enterprise Powers Office 365 Per User StoreAzure + DataStax Enterprise Powers Office 365 Per User Store
Azure + DataStax Enterprise Powers Office 365 Per User Store
 
Using Databases and Containers From Development to Deployment
Using Databases and Containers  From Development to DeploymentUsing Databases and Containers  From Development to Deployment
Using Databases and Containers From Development to Deployment
 
SQL Engines for Hadoop - The case for Impala
SQL Engines for Hadoop - The case for ImpalaSQL Engines for Hadoop - The case for Impala
SQL Engines for Hadoop - The case for Impala
 

Kürzlich hochgeladen

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 

Kürzlich hochgeladen (20)

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 

Architecting with Queues - Northeast PHP 2015

  • 1. Architecting with Queues for Scale and Separation Sandy Smith Northeast PHP 2015
  • 2. Insert Text Here Architecting with Queues - Sandy Smith - Northeast PHP 2015 Setting Expectations 2
  • 3. Architecting with Queues - Sandy Smith - Northeast PHP 2015 What this talk is NOT •A queues HOWTO (though there is some) •Benchmark bonanza •An Azure talk (though there is some) 3
  • 4. Architecting with Queues - Sandy Smith - Northeast PHP 2015 What this talk IS •An architecture talk •A challenge to think differently about your applications •A story about rapidly developing an app 4
  • 5. Architecting with Queues - Sandy Smith - Northeast PHP 2015 The Challenge 5
  • 6. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Social Contest •Show off Azure + PHP •People submit tweets to enter contest •Pull specified keywords from Twitter queue (prefiltered by Node.js app) •Human admins filter out inappropriate content •Humans or computer pulls out winner from approved entries, on timer or arbitrarily •Display latest entries and latest winners to public 6
  • 7. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Stretch goals •Allow any size contest •Assume global contest with distributed moderators 7
  • 8. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Quick refresher Performance vs. Scaling Vertical vs. Horizontal Scaling 8
  • 9. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Initial design 9
  • 10. Architecting with Queues - Sandy Smith - Northeast PHP 2015 System-level view 10 Twitter Firehose Entries node.js app Contest App DB Public Admins
  • 11. Architecting with Queues - Sandy Smith - Northeast PHP 2015 The real bottleneck What’s the slowest and most variable part of any application? 11
  • 12. Insert Text Here Architecting with Queues - Sandy Smith - Northeast PHP 2015 The real bottleneck 12
  • 13. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Traditional database design •Group by kind •Keep metadata with object or in metadata tables •Objects (Document, Person, Account) are most important •Reinforced by TableGateway, ActiveRecord patterns, and ORM and framework module generator defaults •Works for 80+% of cases 13
  • 14. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Tradeoffs of traditional design •Everything’s in one table, even when you routinely only need a subset •Typically one master writes, replicants read •Design is focused around what something is, not its state or other attribute •Requires creative solutions for horizontal scaling •Encourages (but does not require) centralizing logic for a given type of data 14
  • 15. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Worst of all… •This design really didn’t show off all the stuff in Azure 15
  • 16. (We had a week left) Architecting with Queues - Sandy Smith - Northeast PHP 2015 Redesign time 16
  • 17. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Redesign goals •Include as much Azure stuff as is reasonable •Implement the stretch goals of scalability 17
  • 18. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Queues to the rescue! (Plus some other cool stuff) 18
  • 19. Architecting with Queues - Sandy Smith - Northeast PHP 2015 New approach •Keep long term but fast storage •Central concern is not the Thing (Entry) but Status – Unapproved – Approved – Denied – Winner •Separate updates to long term storage from status changes •Minimal impact to working code 19
  • 20. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Azure queuing options Azure Queues (duh) •Simple •“Short”-lived (<7 days) •Used within Azure •Uses REST •Can track message processing 20 Azure Service Bus •Enterprisey •Long-lived •In Azure or private cloud •Can use AMQP, REST, or API •Can publish/subscribe •Can batch requests •Can guarantee FIFO •etc. See https://msdn.microsoft.com/en-us/library/azure/hh767287.aspx
  • 21. Architecting with Queues - Sandy Smith - Northeast PHP 2015 More options •Anything you can install on Linux or Windows (RabbitMQ, ZeroMQ, Kafka, Kestrel, ActiveMQ, etc.) •Any relational or NoSQL database •Azure Tables - Simple REST NoSQL store with a twist 21
  • 22. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Solutions •Long term storage and display retrieval: Azure Table •Since Node.js app already used it, use Service Bus to store changes in status for consistency •Have daemons pull incoming status changes out and write them to the Table 22
  • 23. Architecting with Queues - Sandy Smith - Northeast PHP 2015 New design 23 __construct(EntryAccessor $mapper) Entry EntryAccessor __construct($proxy, $table) EntryAccessorTable EntryRepository __construct($dbh) EntryRepositoryTable Entries Incoming Daemon Denied Winner Approv- ed In- coming Approved Daemon Denied Daemon Winner Daemon
  • 24. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Azure Table basics 24 require_once 'vendorautoload.php';
 use WindowsAzureCommonServicesBuilder;
 use WindowsAzureCommonServiceException;
 use WindowsAzureTableModelsEntity;
 use WindowsAzureTableModelsEdmType;
 
 // Create table REST proxy.
 $tableRestProxy = ServicesBuilder::getInstance()->createTableService($connectionString);
 
 try {
 // Create table.
 $tableRestProxy->createTable("mytable");
 } catch(ServiceException $e){
 // Handle exception based on error codes and messages.
 }
 
 $entity = new Entity();
 $entity->setPartitionKey("pk");
 $entity->setRowKey("1");
 $entity->addProperty("PropertyName", EdmType::STRING, "Sample");
 
 try {
 $tableRestProxy->insertEntity("mytable", $entity);
 } catch(ServiceException $e){
 // Handle exception based on error codes and messages.
 }
  • 25. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Create and send with Service Bus 25 use WindowsAzureServiceBusModelsQueueInfo;
 use WindowsAzureCommonServiceException;
 use WindowsAzureCommonServicesBuilder;
 
 $serviceBusRestProxy = ServicesBuilder::getInstance()- >createServiceBusService($connectionString);
 
 try {
 $queueInfo = new QueueInfo("myqueue");
 $serviceBusRestProxy->createQueue($queueInfo);
 } catch(ServiceException $e) {
 // handle error
 }
 
 try {
 // Create message.
 $message = new BrokeredMessage();
 $message->setBody("my message");
 
 // Send message.
 $serviceBusRestProxy->sendQueueMessage("myqueue", $message);
 } catch(ServiceException $e) {
 // handle error
 }
  • 26. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Receive with Service Bus 26 use WindowsAzureServiceBusModelsQueueInfo;
 use WindowsAzureCommonServiceException;
 use WindowsAzureCommonServicesBuilder;
 
 $serviceBusRestProxy = ServicesBuilder::getInstance()- >createServiceBusService($connectionString);
 
 try {
 // Set the receive mode to PeekLock (default is ReceiveAndDelete).
 $options = new ReceiveMessageOptions();
 $options->setPeekLock(true);
 
 // Receive message.
 $message = $serviceBusRestProxy->receiveQueueMessage("myqueue", $options);
 echo "Body: ".$message->getBody()."<br />";
 echo "MessageID: ".$message->getMessageId()."<br />";
 
 // *** Process message here ***
 
 // Delete message.
 $serviceBusRestProxy->deleteMessage($message);
 } catch(ServiceException $e){
 // handle error
 }
  • 27. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Benefits •Queues add safety: if processing fails, main store is unchanged •App doesn’t wait for process-update-delete cycle – Concerns more separated – Scaling is simpler •Can move queue processing to separate machines •Trivial to move to different stores for each status •Very performant with up-to-second data 27
  • 28. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Challenges •No full ACID •Safety is largely in the application layer •Potential for race conditions – Humans suck 28
  • 29. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Takeaways •Look for more than just long processes •Use queues to decouple functionality •Look for status changes, e.g. workflow •Is the type of data the most important aspect of your data? – It usually is! •Design for replacement of components – Makes changes easier (not easy) 29
  • 30. Architecting with Queues - Sandy Smith - Northeast PHP 2015 Links •Azure: http://azure.microsoft.com/en-us/ •Social Contest:
 https://github.com/MusketeersMe/SocialContest •Me – @SandyS1 – http://phparch.com/ •Feedback! https://joind.in/14720 •php[world] (Nov 16–20) world.phparch.com •Slides will be at: slideshare.net/SandySmith 30