SlideShare a Scribd company logo
1 of 30
Download to read offline
Queuing at the Checkout
Bulgaria Web Summit 2015
★Chief Technical Architect at Reward Gateway
★Interested in scalability and engineering
★“PHP addict!”
Who am I?
<html>	
  
	
  	
  <head>	
  
	
  	
  	
  	
  <title>Tutorial</title>	
  
	
  	
  </head>	
  
	
  	
  <body>	
  
	
  	
  	
  	
  <?php	
  echo	
  "<p>Hello	
  World</p>";	
  ?>	
  
	
  	
  </body>	
  
</html>	
  
“Do not wait; the time will never be
'just right.' Start where you stand,
and work with whatever tools you
may have at your command, and
better tools will be found as you go
along.”
American author, Napoleon Hill
(1883-1970)
A modern web application
Modern applications are complex
★Modern web
applications often do
not work in isolation.
★Gone are the days of a
single database
powering everything.
★Integrate with
Facebook, Stripe, etc.
Your application
Facebook
Stripe
Amazon S3Zendesk
Adding an API
★Let’s add a new SOAP
service to our
application.
<?xml	
  version="1.0"?>	
  
<soap:Envelope	
  
xmlns:soap="http://www.w3.org/2001/12/soap-­‐envelope"	
  
soap:encodingStyle="http://www.w3.org/2001/12/soap-­‐encoding">	
  
<soap:Body>	
  
	
  	
  <m:GetName	
  xmlns:m="http://www.example.com/name">	
  
	
  	
  	
  	
  <m:Item>John</m:Item>	
  
	
  	
  </m:GetPrice>	
  
</soap:Body>	
  
</soap:Envelope>	
  
Adding an API
★Let’s add a new SOAP
service to our
application.
★PHP makes this really
easy!<?php	
  
$client	
  =	
  new	
  SoapClient("http://www.example.com/some.wsdl");	
  
echo	
  "Hi	
  "	
  .	
  $client-­‐>name()	
  .	
  "n";	
  
Adding an API
★Let’s add a new SOAP
service to our
application.
★PHP makes this really
easy!
★We can be in
production in two
minutes.
$	
  php	
  client.php	
  
Hi	
  John	
  
$	
  php	
  client.php	
  
Hi	
  Dave	
  
$	
  php	
  client.php	
  
Hi	
  Colin	
  
Maintenance
Performance
Scaling
Poor response times lead to loss of revenue
★The slower your site,
the more likely people
are to give up (“exit”)
★Over 75% of people in
an Akami survey said
they would stop using
a site if it took longer
than 4 seconds.
★The more people who
give up, the less
money you’ll make.
ExitRate
0%
5%
10%
15%
20%
Load Time (secs)
0
.1
1
2
3
What can you do?
TL;DR
★Split your application into bits.
★Keep the predictable bit on the request path.
★Move the unpredictable bit somewhere else.
★Use a message queue to communicate between the two halves.
Message Queue Servers
★There are lots of message queue implementations:
★ RabbitMQ
★ Amazon SQS
★ OpenAMQ
★ ….
★Written in different languages with different tradeoffs.
★Almost all support a protocol called AMQP.
Message Queue Basics
★AMQP has three
concepts.
★Exchanges route
messages using rules
★Queues are where
messages wait for
processing
★Bindings define the
routing rules
Publisher
Publisher
Exchange
Exchange
Queue
Queue
Consumer
Consumer
Consumer
Exchange Rules
★The exchanges
understand three
types of rule:
★ Fanout
★ Direct
★ Topic
★You can create almost
any structure with this
set.
Publisher Exchange Queue Consumer
Consumer
Fanout
Queue
Publisher Exchange Queue Consumer
Direct
Exchange Rules Continued
★The exchanges
understand three
types of rule:
★ Fanout
★ Direct
★ Topic
★You can create almost
any structure with this
set.
Publisher Exchange
Queue Consumer
Consumer
Topic
Queue
lazy.#
*.orange.*
*.*.rabbit
Basic Publisher
<?php	
  
require_once	
  __DIR__	
  .	
  '/vendor/autoload.php';	
  
use	
  PhpAmqpLibConnectionAMQPConnection;	
  
use	
  PhpAmqpLibMessageAMQPMessage;	
  
$connection	
  =	
  new	
  AMQPConnection('localhost',	
  5672,	
  'guest',	
  ‘guest');	
  
$channel	
  =	
  $connection-­‐>channel();	
  
$channel-­‐>queue_declare('hello',	
  false,	
  false,	
  false,	
  false);	
  
$msg	
  =	
  new	
  AMQPMessage('Hello	
  World!');	
  
$channel-­‐>basic_publish($msg,	
  '',	
  'hello');	
  
echo	
  "	
  [x]	
  Sent	
  'Hello	
  World!’n”;	
  
$channel-­‐>close();	
  
$connection-­‐>close();	
  
Basic Consumer
#!/usr/bin/env	
  python	
  
import	
  pika	
  
connection	
  =	
  pika.BlockingConnection(pika.ConnectionParameters(	
  
	
  	
  	
  	
  	
  	
  	
  	
  host='localhost'))	
  
channel	
  =	
  connection.channel()	
  
channel.queue_declare(queue='hello')	
  
print	
  '	
  [*]	
  Waiting	
  for	
  messages.	
  To	
  exit	
  press	
  CTRL+C'	
  
def	
  callback(ch,	
  method,	
  properties,	
  body):	
  
	
  	
  	
  	
  print	
  "	
  [x]	
  Received	
  %r"	
  %	
  (body,)	
  
channel.basic_consume(callback,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  queue='hello',	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  no_ack=True)	
  
channel.start_consuming()
Still need to handle problems…
★You still have to
monitor your queues.
★Easy to see when
things go wrong.
★More advanced
features let you cope
with this better (e.g.
timeouts on delivery)
QueueSize(messages)
0
250
500
750
1,000
Requests (/secs)
0
10
0
20
0
30
0
Still need to handle crashes…
★What happens when the message queue server crashes?
★ You also still need to worry about your data.
★By default, nothing is saved by RabbitMQ (i.e you lose everything.)
★Pay attention to durability settings when configuring the queues.
Some helpful tools
“Bad API”
★http://badapi.trip.tv
★Allows you to send a request and get a known response back.
★Lets you specify how long to delay the response
★Lets you specify a HTTP error code
★Good for simulating a poorly performing API
“RabbitMQ Simulator”
★http://tryrabbitmq.com
★Single page simulator for RabbitMQ
★Interactive user interface
★Lets you try out all the concepts in this talk and get comfortable with exchanges,
bindings etc.
Conclusion
★Keep your application predictable - move the unpredictable bit out.
★Your integration tests should consider API failures and performance problems.
★Command-Query Response Separation can really help in this area (another talk!)
★We’re hiring! http://rg.co/careers
Questions

More Related Content

What's hot

Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Abu Ashraf Masnun
 
The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)danwrong
 
Distributed Applications with Perl & Gearman
Distributed Applications with Perl & GearmanDistributed Applications with Perl & Gearman
Distributed Applications with Perl & GearmanIssac Goldstand
 
Khanh-Nguyen - Gearman - distributed process solution
Khanh-Nguyen - Gearman - distributed process solutionKhanh-Nguyen - Gearman - distributed process solution
Khanh-Nguyen - Gearman - distributed process solutionJavaScript Meetup HCMC
 
Abusing the Cloud for Fun and Profit
Abusing the Cloud for Fun and ProfitAbusing the Cloud for Fun and Profit
Abusing the Cloud for Fun and ProfitAlan Pinstein
 
The Mysteries Of JavaScript-Fu (@media Europe Edition)
The Mysteries Of JavaScript-Fu (@media Europe Edition)The Mysteries Of JavaScript-Fu (@media Europe Edition)
The Mysteries Of JavaScript-Fu (@media Europe Edition)danwrong
 
Being a pimp without silverlight
Being a pimp without silverlightBeing a pimp without silverlight
Being a pimp without silverlightMaarten Balliauw
 
Deploying Rails on EC2 using Rubber (Slides Only)
Deploying Rails on EC2 using Rubber (Slides Only)Deploying Rails on EC2 using Rubber (Slides Only)
Deploying Rails on EC2 using Rubber (Slides Only)wr0ngway
 
Gearman: A Job Server made for Scale
Gearman: A Job Server made for ScaleGearman: A Job Server made for Scale
Gearman: A Job Server made for ScaleMike Willbanks
 
[Back2 basic] from c10k problem to concurrency concept
[Back2 basic] from c10k problem to concurrency concept[Back2 basic] from c10k problem to concurrency concept
[Back2 basic] from c10k problem to concurrency conceptTrịnh Thế Thành
 
Cloud-Native DevOps Engineering
Cloud-Native DevOps EngineeringCloud-Native DevOps Engineering
Cloud-Native DevOps EngineeringDiego Pacheco
 
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsGearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsDinh Pham
 
Ops, DevOps, NoOps and AWS Lambda
Ops, DevOps, NoOps and AWS LambdaOps, DevOps, NoOps and AWS Lambda
Ops, DevOps, NoOps and AWS LambdaMatthew Boeckman
 
Spreadshirt Techcamp 2018 - Hold until Told
Spreadshirt Techcamp 2018 - Hold until ToldSpreadshirt Techcamp 2018 - Hold until Told
Spreadshirt Techcamp 2018 - Hold until ToldMartin Breest
 
The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)danwrong
 

What's hot (20)

Queue your work
Queue your workQueue your work
Queue your work
 
Build App with Nodejs - YWC Workshop
Build App with Nodejs - YWC WorkshopBuild App with Nodejs - YWC Workshop
Build App with Nodejs - YWC Workshop
 
Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!Gearman, Supervisor and PHP - Job Management with Sanity!
Gearman, Supervisor and PHP - Job Management with Sanity!
 
The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)The Mysteries Of JavaScript-Fu (@media SF Edition)
The Mysteries Of JavaScript-Fu (@media SF Edition)
 
Web Assembly (W3C TPAC presentation)
Web Assembly (W3C TPAC presentation)Web Assembly (W3C TPAC presentation)
Web Assembly (W3C TPAC presentation)
 
Distributed Applications with Perl & Gearman
Distributed Applications with Perl & GearmanDistributed Applications with Perl & Gearman
Distributed Applications with Perl & Gearman
 
Khanh-Nguyen - Gearman - distributed process solution
Khanh-Nguyen - Gearman - distributed process solutionKhanh-Nguyen - Gearman - distributed process solution
Khanh-Nguyen - Gearman - distributed process solution
 
Abusing the Cloud for Fun and Profit
Abusing the Cloud for Fun and ProfitAbusing the Cloud for Fun and Profit
Abusing the Cloud for Fun and Profit
 
The Mysteries Of JavaScript-Fu (@media Europe Edition)
The Mysteries Of JavaScript-Fu (@media Europe Edition)The Mysteries Of JavaScript-Fu (@media Europe Edition)
The Mysteries Of JavaScript-Fu (@media Europe Edition)
 
Being a pimp without silverlight
Being a pimp without silverlightBeing a pimp without silverlight
Being a pimp without silverlight
 
Deploying Rails on EC2 using Rubber (Slides Only)
Deploying Rails on EC2 using Rubber (Slides Only)Deploying Rails on EC2 using Rubber (Slides Only)
Deploying Rails on EC2 using Rubber (Slides Only)
 
Gearman: A Job Server made for Scale
Gearman: A Job Server made for ScaleGearman: A Job Server made for Scale
Gearman: A Job Server made for Scale
 
[Back2 basic] from c10k problem to concurrency concept
[Back2 basic] from c10k problem to concurrency concept[Back2 basic] from c10k problem to concurrency concept
[Back2 basic] from c10k problem to concurrency concept
 
Observables - the why, what & how
Observables - the why, what & howObservables - the why, what & how
Observables - the why, what & how
 
Gearman and Perl
Gearman and PerlGearman and Perl
Gearman and Perl
 
Cloud-Native DevOps Engineering
Cloud-Native DevOps EngineeringCloud-Native DevOps Engineering
Cloud-Native DevOps Engineering
 
Gearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applicationsGearman and asynchronous processing in PHP applications
Gearman and asynchronous processing in PHP applications
 
Ops, DevOps, NoOps and AWS Lambda
Ops, DevOps, NoOps and AWS LambdaOps, DevOps, NoOps and AWS Lambda
Ops, DevOps, NoOps and AWS Lambda
 
Spreadshirt Techcamp 2018 - Hold until Told
Spreadshirt Techcamp 2018 - Hold until ToldSpreadshirt Techcamp 2018 - Hold until Told
Spreadshirt Techcamp 2018 - Hold until Told
 
The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)The Mysteries Of JavaScript-Fu (RailsConf Ediition)
The Mysteries Of JavaScript-Fu (RailsConf Ediition)
 

Viewers also liked

Information security diligence issue 4.5
Information security diligence issue 4.5 Information security diligence issue 4.5
Information security diligence issue 4.5 Reward Gateway
 
Information for new clients.
Information for new clients.Information for new clients.
Information for new clients.Reward Gateway
 
CEO Glenn Elliott's User Manual : A solution for poor employee trust?
CEO Glenn Elliott's User Manual : A solution for poor employee trust?CEO Glenn Elliott's User Manual : A solution for poor employee trust?
CEO Glenn Elliott's User Manual : A solution for poor employee trust?Reward Gateway
 
Review: Wellness technology in the workplace
Review: Wellness technology in the workplace Review: Wellness technology in the workplace
Review: Wellness technology in the workplace Reward Gateway
 
Total Rewards Strategy- Debra Corey
Total Rewards Strategy- Debra CoreyTotal Rewards Strategy- Debra Corey
Total Rewards Strategy- Debra CoreyExpedite HR
 
Bridging the employee engagement gap
Bridging the employee engagement gapBridging the employee engagement gap
Bridging the employee engagement gapReward Gateway
 

Viewers also liked (6)

Information security diligence issue 4.5
Information security diligence issue 4.5 Information security diligence issue 4.5
Information security diligence issue 4.5
 
Information for new clients.
Information for new clients.Information for new clients.
Information for new clients.
 
CEO Glenn Elliott's User Manual : A solution for poor employee trust?
CEO Glenn Elliott's User Manual : A solution for poor employee trust?CEO Glenn Elliott's User Manual : A solution for poor employee trust?
CEO Glenn Elliott's User Manual : A solution for poor employee trust?
 
Review: Wellness technology in the workplace
Review: Wellness technology in the workplace Review: Wellness technology in the workplace
Review: Wellness technology in the workplace
 
Total Rewards Strategy- Debra Corey
Total Rewards Strategy- Debra CoreyTotal Rewards Strategy- Debra Corey
Total Rewards Strategy- Debra Corey
 
Bridging the employee engagement gap
Bridging the employee engagement gapBridging the employee engagement gap
Bridging the employee engagement gap
 

Similar to Queueing at the Checkout

Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...
Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...
Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...nine
 
Planning to Fail #phpne13
Planning to Fail #phpne13Planning to Fail #phpne13
Planning to Fail #phpne13Dave Gardner
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous ApplicationsJohan Edstrom
 
Mazda siv - web services
Mazda   siv - web servicesMazda   siv - web services
Mazda siv - web servicesOlivier Lépine
 
Planning to Fail #phpuk13
Planning to Fail #phpuk13Planning to Fail #phpuk13
Planning to Fail #phpuk13Dave Gardner
 
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNAFirst Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNATomas Cervenka
 
Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...Peter Gfader
 
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...Amazon Web Services
 
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over WebsocketIntroduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocketsametmax
 
AWS re:Invent 2016 Fast Forward
AWS re:Invent 2016 Fast ForwardAWS re:Invent 2016 Fast Forward
AWS re:Invent 2016 Fast ForwardShuen-Huei Guan
 
Ajax Performance
Ajax PerformanceAjax Performance
Ajax Performancekaven yan
 
AWS Serverless patterns & best-practices in AWS
AWS Serverless  patterns & best-practices in AWSAWS Serverless  patterns & best-practices in AWS
AWS Serverless patterns & best-practices in AWSDima Pasko
 
Do You Need a Service Mesh? @ London Devops, January 2019
Do You Need a Service Mesh? @ London Devops, January 2019Do You Need a Service Mesh? @ London Devops, January 2019
Do You Need a Service Mesh? @ London Devops, January 2019Matt Turner
 
AWS Observability Made Simple
AWS Observability Made SimpleAWS Observability Made Simple
AWS Observability Made SimpleLuciano Mammino
 
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Startupfest
 

Similar to Queueing at the Checkout (20)

Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...
Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...
Challenges behind the scenes of the large Swiss e-Commerce shop apfelkiste.ch...
 
Planning to Fail #phpne13
Planning to Fail #phpne13Planning to Fail #phpne13
Planning to Fail #phpne13
 
Ajax and PHP
Ajax and PHPAjax and PHP
Ajax and PHP
 
Otimizando servidores web
Otimizando servidores webOtimizando servidores web
Otimizando servidores web
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous Applications
 
Mazda siv - web services
Mazda   siv - web servicesMazda   siv - web services
Mazda siv - web services
 
Planning to Fail #phpuk13
Planning to Fail #phpuk13Planning to Fail #phpuk13
Planning to Fail #phpuk13
 
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNAFirst Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
First Hive Meetup London 2012-07-10 - Tomas Cervenka - VisualDNA
 
Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...Silverlight vs HTML5 - Lessons learned from the real world...
Silverlight vs HTML5 - Lessons learned from the real world...
 
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...
AWS re:Invent 2016: Save up to 90% and Run Production Workloads on Spot - Fea...
 
Real time web
Real time webReal time web
Real time web
 
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over WebsocketIntroduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
Introduction to WAMP, a protocol enabling PUB/SUB and RPC over Websocket
 
Scaling symfony apps
Scaling symfony appsScaling symfony apps
Scaling symfony apps
 
AWS re:Invent 2016 Fast Forward
AWS re:Invent 2016 Fast ForwardAWS re:Invent 2016 Fast Forward
AWS re:Invent 2016 Fast Forward
 
Ajax Performance
Ajax PerformanceAjax Performance
Ajax Performance
 
AWS Serverless patterns & best-practices in AWS
AWS Serverless  patterns & best-practices in AWSAWS Serverless  patterns & best-practices in AWS
AWS Serverless patterns & best-practices in AWS
 
Do You Need a Service Mesh? @ London Devops, January 2019
Do You Need a Service Mesh? @ London Devops, January 2019Do You Need a Service Mesh? @ London Devops, January 2019
Do You Need a Service Mesh? @ London Devops, January 2019
 
Beginners Node.js
Beginners Node.jsBeginners Node.js
Beginners Node.js
 
AWS Observability Made Simple
AWS Observability Made SimpleAWS Observability Made Simple
AWS Observability Made Simple
 
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
 

Recently uploaded

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 

Recently uploaded (20)

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 

Queueing at the Checkout

  • 1. Queuing at the Checkout Bulgaria Web Summit 2015
  • 2. ★Chief Technical Architect at Reward Gateway ★Interested in scalability and engineering ★“PHP addict!” Who am I?
  • 3.
  • 4. <html>      <head>          <title>Tutorial</title>      </head>      <body>          <?php  echo  "<p>Hello  World</p>";  ?>      </body>   </html>  
  • 5. “Do not wait; the time will never be 'just right.' Start where you stand, and work with whatever tools you may have at your command, and better tools will be found as you go along.” American author, Napoleon Hill (1883-1970)
  • 6. A modern web application
  • 7. Modern applications are complex ★Modern web applications often do not work in isolation. ★Gone are the days of a single database powering everything. ★Integrate with Facebook, Stripe, etc. Your application Facebook Stripe Amazon S3Zendesk
  • 8. Adding an API ★Let’s add a new SOAP service to our application. <?xml  version="1.0"?>   <soap:Envelope   xmlns:soap="http://www.w3.org/2001/12/soap-­‐envelope"   soap:encodingStyle="http://www.w3.org/2001/12/soap-­‐encoding">   <soap:Body>      <m:GetName  xmlns:m="http://www.example.com/name">          <m:Item>John</m:Item>      </m:GetPrice>   </soap:Body>   </soap:Envelope>  
  • 9. Adding an API ★Let’s add a new SOAP service to our application. ★PHP makes this really easy!<?php   $client  =  new  SoapClient("http://www.example.com/some.wsdl");   echo  "Hi  "  .  $client-­‐>name()  .  "n";  
  • 10. Adding an API ★Let’s add a new SOAP service to our application. ★PHP makes this really easy! ★We can be in production in two minutes. $  php  client.php   Hi  John   $  php  client.php   Hi  Dave   $  php  client.php   Hi  Colin  
  • 11.
  • 15. Poor response times lead to loss of revenue ★The slower your site, the more likely people are to give up (“exit”) ★Over 75% of people in an Akami survey said they would stop using a site if it took longer than 4 seconds. ★The more people who give up, the less money you’ll make. ExitRate 0% 5% 10% 15% 20% Load Time (secs) 0 .1 1 2 3
  • 17. TL;DR ★Split your application into bits. ★Keep the predictable bit on the request path. ★Move the unpredictable bit somewhere else. ★Use a message queue to communicate between the two halves.
  • 18. Message Queue Servers ★There are lots of message queue implementations: ★ RabbitMQ ★ Amazon SQS ★ OpenAMQ ★ …. ★Written in different languages with different tradeoffs. ★Almost all support a protocol called AMQP.
  • 19. Message Queue Basics ★AMQP has three concepts. ★Exchanges route messages using rules ★Queues are where messages wait for processing ★Bindings define the routing rules Publisher Publisher Exchange Exchange Queue Queue Consumer Consumer Consumer
  • 20. Exchange Rules ★The exchanges understand three types of rule: ★ Fanout ★ Direct ★ Topic ★You can create almost any structure with this set. Publisher Exchange Queue Consumer Consumer Fanout Queue Publisher Exchange Queue Consumer Direct
  • 21. Exchange Rules Continued ★The exchanges understand three types of rule: ★ Fanout ★ Direct ★ Topic ★You can create almost any structure with this set. Publisher Exchange Queue Consumer Consumer Topic Queue lazy.# *.orange.* *.*.rabbit
  • 22. Basic Publisher <?php   require_once  __DIR__  .  '/vendor/autoload.php';   use  PhpAmqpLibConnectionAMQPConnection;   use  PhpAmqpLibMessageAMQPMessage;   $connection  =  new  AMQPConnection('localhost',  5672,  'guest',  ‘guest');   $channel  =  $connection-­‐>channel();   $channel-­‐>queue_declare('hello',  false,  false,  false,  false);   $msg  =  new  AMQPMessage('Hello  World!');   $channel-­‐>basic_publish($msg,  '',  'hello');   echo  "  [x]  Sent  'Hello  World!’n”;   $channel-­‐>close();   $connection-­‐>close();  
  • 23. Basic Consumer #!/usr/bin/env  python   import  pika   connection  =  pika.BlockingConnection(pika.ConnectionParameters(                  host='localhost'))   channel  =  connection.channel()   channel.queue_declare(queue='hello')   print  '  [*]  Waiting  for  messages.  To  exit  press  CTRL+C'   def  callback(ch,  method,  properties,  body):          print  "  [x]  Received  %r"  %  (body,)   channel.basic_consume(callback,                                              queue='hello',                                              no_ack=True)   channel.start_consuming()
  • 24. Still need to handle problems… ★You still have to monitor your queues. ★Easy to see when things go wrong. ★More advanced features let you cope with this better (e.g. timeouts on delivery) QueueSize(messages) 0 250 500 750 1,000 Requests (/secs) 0 10 0 20 0 30 0
  • 25. Still need to handle crashes… ★What happens when the message queue server crashes? ★ You also still need to worry about your data. ★By default, nothing is saved by RabbitMQ (i.e you lose everything.) ★Pay attention to durability settings when configuring the queues.
  • 27. “Bad API” ★http://badapi.trip.tv ★Allows you to send a request and get a known response back. ★Lets you specify how long to delay the response ★Lets you specify a HTTP error code ★Good for simulating a poorly performing API
  • 28. “RabbitMQ Simulator” ★http://tryrabbitmq.com ★Single page simulator for RabbitMQ ★Interactive user interface ★Lets you try out all the concepts in this talk and get comfortable with exchanges, bindings etc.
  • 29. Conclusion ★Keep your application predictable - move the unpredictable bit out. ★Your integration tests should consider API failures and performance problems. ★Command-Query Response Separation can really help in this area (another talk!) ★We’re hiring! http://rg.co/careers