SlideShare a Scribd company logo
1 of 96
Download to read offline
Faster Apps That Won't
Get Crushed With
Queues And Pub/Sub
Mechanisms
INTO THE BOX 2023
BRIAN KLAAS
Workflows
Workflows
Workflows
Click Button
Validate
Request
Check
Inventory
Process
Payment
Find Closest
Warehouse
Create Pick
Ticket
Calculate
Ship Date
Send
Confirmation
Email
Success
View
Workflows
Click Button
Success
View
Nothing’s faster
than work you don’t have to wait for.
Workflows
Scale and speed
are every developer’s problem.
Workflows
Faster Apps That Won't
Get Crushed With
Queues And Pub/Sub
Mechanisms
INTO THE BOX 2023
BRIAN KLAAS
Request/Response
Request/Response
We’ve got to wait around for some ill-
defined future point.
Request/Response
runAsync( ) in CFML 2018+
Request/Response
runAsync(validateRequest)
.then(checkInventory)
.then(processPayment)
.then(findClosestWarehouse)
.then(createPickTicket)
.then(calculateShipDate);
.then(sendEmailConfirmation);
Request/Response
var clientView = runAsync(validateRequest)
.then(processPayment)
.then(sendEmailConfirmation);
var warehouseProcess = runAsync(findClosestWarehouse)
.then(checkInventory)
.then(createPickTicket)
.then(calculateShipDate);
.then(sendShipmentDateEmail);
Request/Response
ColdBox asyncManager & Futures
async().newFuture( () => orderService.getOrder() )
.then( (order) => enrichOrder( order ) )
.then( (order) => performPayment( order ) )
.then( (order) => sendConfirmation( order ) );
Request/Response
Error handling
Retries
Throttling
New business requirements
Request/Response
Linear, linked flow encourages
brittle architectures
Request/Response
Linear, linked flow blocks
your ability to scale
Request/Response
How can we do better?
Request/Response
Event-driven
Something happens.
Code responds.
Event-driven
Database triggers
Event-driven
SQL
ColdBox Interceptors
Event-driven
Event–driven = automatic plumbing
Event-driven
Event-driven = easy fan-out
Event-driven
How do you know it’s done?
Event-driven
?
Orchestration tools
Event-driven
Orchestration = additional complexity
Event-driven
!
Something simpler?
Event-driven
Pub/Sub +
Queues
SNS = Simple Notification Service
Pub/Sub + Queues
SNS = Pub/Sub
Pub/Sub + Queues
SNS = One Publisher,
Many Subscribers
Pub/Sub + Queues
SNS Subscribers:
https endpoints (including CFML)
Email
Phone number (SMS)
SQS queue
Lambda
Kinesis Firehose
Pinpoint
Pub/Sub + Queues
SNS subscribers can:
Filter on specific criteria
Retry on delivery to https endpoints
Specify DLQ on completely failed delivery
Pub/Sub + Queues
var messageBody = { "createdOn": now()),
"userID": arguments.userID,
"event": arguments.thisEvent,
};
var messageBodyAsJSON = serializeJSON(messageBody);
var publishRequest = CreateObject('java',
‘com.amazonaws.services.sns.model.PublishRequest’)
.withTopicARN(variables.snsARN)
.withMessage(messageBodyAsJSON);
variables.snsService.publish(publishRequest);
Pub/Sub + Queues
github.com/brianklaas/awsplaybox
Add AWS Java SDK .jar to:
Adobe ColdFusion: cfusion/lib
Lucee: WEB-INF/lucee/lib/
ColdBox: lib/
Pub/Sub + Queues
SNS is about speed
Pub/Sub + Queues
SNS = Fan-out
Pub/Sub + Queues
SQS = Simple Queue Service
Pub/Sub + Queues
SQS = Stack of messages
Pub/Sub + Queues
SQS = One publisher,
one worker
Pub/Sub + Queues
Pub/Sub + Queues
CFML
(ack)
Pub/Sub + Queues
CFML
CFML
CFML
SQS queues can:
Perform content-based deduplication
Retry messages on failed processing
Specify DLQ on completely failed processing
Pub/Sub + Queues
SQS != ordered processing
Pub/Sub + Queues
SQS != only-once delivery
Pub/Sub + Queues
SQS reqiures idempotency
Pub/Sub + Queues
FIFO queues for order
Pub/Sub + Queues
Pub/Sub + Queues
github.com/brianklaas/awsplaybox
var messageBody = { "createdOn": now()),
"userID": arguments.userID,
"event": arguments.thisEvent,
};
var messageBodyAsJSON = serializeJSON(messageBody);
var sendMessageRequest =
createObject("java","com.amazonaws.services.sqs.model.SendMessageRequest")
.withQueueUrl(variables.sqsQueueURL)
.withMessageBody(messageBody);
variables.sqsService.sendMessage(sendMessageRequest);
var receiveMessageRequest =
CreateObject(‘java’,'com.amazonaws.services.sqs.model.
ReceiveMessageRequest').init()
.withQueueURL(variables.queueURL).withMaxNumberOfMessages(1);
var messagesArray =
variables.sqsService.receiveMessage(receiveMessageRequest).getMessages();
if (arrayLen(messagesArray)) {
var messageToProcess = messagesArray[1];
var receiptHandle = messageToProcess.getReceiptHandle();
var messageBody = deserializeJSON(messageToProcess.getBody());
// do work with the message
var deleteMessageResult =
variables.sqsService.deleteMessage(variables.queueURL,receiptHandle);
}
Pub/Sub + Queues
vs
Message Size Limit:
SNS = 256 KiB
SQS = 256 KiB
vs
Message Persistence:
SNS = No
SQS = Yes
vs
Message Ordering:
SNS = Yes
SQS = Yes, when using FIFO queues
vs
Message Filtering:
SNS = Yes
SQS = Yes
vs
Common Pattern: SNS in front of SQS
vs
Use cases:
SNS = Fan-out to multiple recipients
SQS = Queuing up work by processors
vs
SNS + SQS allow you to scale and
parallelize work safely and durably.
vs
Real-World Example 1
Example
Example
Example
Example
Example
Example
Example
Example
( numRequests * avg execution time )
seconds for scheduled task
var remainingTime = 55000;
do {
var messageProcessStartTime = getTickCount();
// get SQS message, generate and send email, delete message
var messageProcessEndTime = getTickCount();
remainingTime -= (messageProcessEndTime - messageProcessStartTime);
} while (remainingTime gt 0);
Example
Example
Processing–intensive tasks
Throttle processing of a batch of items
Real-World Example 2
Example
Example
Example
Example
Example
Example
Example
Example
Kinesis Data Firehose:
Can ingest up to 500,000 records/second
Stores records for up to 7 days
Manages writing to the destination
Can be queried in real-time with Kinesis Data Analytics
Example
Example
Example
Amazon Athena:
Query files in S3 with SQL
Store in JSON, CSV, or Parquet formats
Ad-hoc or repeated queries
Pay based on amount of data scanned
Example
Example
Example
Example
Example
Example
So how much does this cost?
Example
40 million requests = $30/month
Example
Example
Safe experimentation!
Example
Go Do!
Brian Klaas
@brian_klaas
Blog: brianklaas.net
github.com/brianklaas/awsplaybox
THANK YOU
Thanks to our sponsors

More Related Content

Similar to ITB_2023_Faster_Apps_That_Wont_Get_Crushed_Brian_Klaas.pdf

Being a pimp without silverlight
Being a pimp without silverlightBeing a pimp without silverlight
Being a pimp without silverlight
Maarten Balliauw
 
Being a pimp without silverlight - ASP.NET MVC 2 and jQuery
Being a pimp without silverlight - ASP.NET MVC 2 and jQueryBeing a pimp without silverlight - ASP.NET MVC 2 and jQuery
Being a pimp without silverlight - ASP.NET MVC 2 and jQuery
Kris van der Mast
 
Being a pimp without silverlight
Being a pimp without silverlightBeing a pimp without silverlight
Being a pimp without silverlight
Kris van der Mast
 

Similar to ITB_2023_Faster_Apps_That_Wont_Get_Crushed_Brian_Klaas.pdf (20)

[1C1]Service Workers
[1C1]Service Workers[1C1]Service Workers
[1C1]Service Workers
 
Serverless Apps with AWS Step Functions
Serverless Apps with AWS Step FunctionsServerless Apps with AWS Step Functions
Serverless Apps with AWS Step Functions
 
Azure Durable Functions (2018-06-13)
Azure Durable Functions (2018-06-13)Azure Durable Functions (2018-06-13)
Azure Durable Functions (2018-06-13)
 
"Load Testing Distributed Systems with NBomber 4.0", Anton Moldovan
"Load Testing Distributed Systems with NBomber 4.0",  Anton Moldovan"Load Testing Distributed Systems with NBomber 4.0",  Anton Moldovan
"Load Testing Distributed Systems with NBomber 4.0", Anton Moldovan
 
Webauthn Tutorial
Webauthn TutorialWebauthn Tutorial
Webauthn Tutorial
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
SMC304 Serverless Orchestration with AWS Step Functions
SMC304 Serverless Orchestration with AWS Step FunctionsSMC304 Serverless Orchestration with AWS Step Functions
SMC304 Serverless Orchestration with AWS Step Functions
 
Being a pimp without silverlight
Being a pimp without silverlightBeing a pimp without silverlight
Being a pimp without silverlight
 
Being a pimp without silverlight - ASP.NET MVC 2 and jQuery
Being a pimp without silverlight - ASP.NET MVC 2 and jQueryBeing a pimp without silverlight - ASP.NET MVC 2 and jQuery
Being a pimp without silverlight - ASP.NET MVC 2 and jQuery
 
Being a pimp without silverlight
Being a pimp without silverlightBeing a pimp without silverlight
Being a pimp without silverlight
 
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
 
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
Callbacks, Promises, and Coroutines (oh my!): Asynchronous Programming Patter...
 
Azure SQL Database - Connectivity Best Practices
Azure SQL Database - Connectivity Best PracticesAzure SQL Database - Connectivity Best Practices
Azure SQL Database - Connectivity Best Practices
 
4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...
4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...
4Developers 2018: Real-time capabilities in ASP.NET Core web applications (To...
 
Final microsoft cloud summit - windows azure building block services
Final   microsoft cloud summit - windows azure building block servicesFinal   microsoft cloud summit - windows azure building block services
Final microsoft cloud summit - windows azure building block services
 
Server Side Events
Server Side EventsServer Side Events
Server Side Events
 
ReactJS
ReactJSReactJS
ReactJS
 
Building Event Driven Services with Kafka Streams
Building Event Driven Services with Kafka StreamsBuilding Event Driven Services with Kafka Streams
Building Event Driven Services with Kafka Streams
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance test
 

More from Ortus Solutions, Corp

More from Ortus Solutions, Corp (20)

ITB2024 - Keynote Day 1 - Ortus Solutions.pdf
ITB2024 - Keynote Day 1 - Ortus Solutions.pdfITB2024 - Keynote Day 1 - Ortus Solutions.pdf
ITB2024 - Keynote Day 1 - Ortus Solutions.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Ortus Government.pdf
Ortus Government.pdfOrtus Government.pdf
Ortus Government.pdf
 
Luis Majano The Battlefield ORM
Luis Majano The Battlefield ORMLuis Majano The Battlefield ORM
Luis Majano The Battlefield ORM
 
Brad Wood - CommandBox CLI
Brad Wood - CommandBox CLI Brad Wood - CommandBox CLI
Brad Wood - CommandBox CLI
 
Secure your Secrets and Settings in ColdFusion
Secure your Secrets and Settings in ColdFusionSecure your Secrets and Settings in ColdFusion
Secure your Secrets and Settings in ColdFusion
 
Daniel Garcia ContentBox: CFSummit 2023
Daniel Garcia ContentBox: CFSummit 2023Daniel Garcia ContentBox: CFSummit 2023
Daniel Garcia ContentBox: CFSummit 2023
 
ITB_2023_Human-Friendly_Scheduled_Tasks_Giancarlo_Gomez.pdf
ITB_2023_Human-Friendly_Scheduled_Tasks_Giancarlo_Gomez.pdfITB_2023_Human-Friendly_Scheduled_Tasks_Giancarlo_Gomez.pdf
ITB_2023_Human-Friendly_Scheduled_Tasks_Giancarlo_Gomez.pdf
 
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdfITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
ITB_2023_CommandBox_Multi-Server_-_Brad_Wood.pdf
 
ITB_2023_The_Many_Layers_of_OAuth_Keith_Casey_.pdf
ITB_2023_The_Many_Layers_of_OAuth_Keith_Casey_.pdfITB_2023_The_Many_Layers_of_OAuth_Keith_Casey_.pdf
ITB_2023_The_Many_Layers_of_OAuth_Keith_Casey_.pdf
 
ITB_2023_Relationships_are_Hard_Data_modeling_with_NoSQL_Curt_Gratz.pdf
ITB_2023_Relationships_are_Hard_Data_modeling_with_NoSQL_Curt_Gratz.pdfITB_2023_Relationships_are_Hard_Data_modeling_with_NoSQL_Curt_Gratz.pdf
ITB_2023_Relationships_are_Hard_Data_modeling_with_NoSQL_Curt_Gratz.pdf
 
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdf
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdfITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdf
ITB_2023_Extend_your_contentbox_apps_with_custom_modules_Javier_Quintero.pdf
 
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdfITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
ITB_2023_25_Most_Dangerous_Software_Weaknesses_Pete_Freitag.pdf
 
ITB_2023_CBWire_v3_Grant_Copley.pdf
ITB_2023_CBWire_v3_Grant_Copley.pdfITB_2023_CBWire_v3_Grant_Copley.pdf
ITB_2023_CBWire_v3_Grant_Copley.pdf
 
ITB_2023_Practical_AI_with_OpenAI_-_Grant_Copley_.pdf
ITB_2023_Practical_AI_with_OpenAI_-_Grant_Copley_.pdfITB_2023_Practical_AI_with_OpenAI_-_Grant_Copley_.pdf
ITB_2023_Practical_AI_with_OpenAI_-_Grant_Copley_.pdf
 
ITB_2023_When_Your_Applications_Work_As_a_Team_Nathaniel_Francis.pdf
ITB_2023_When_Your_Applications_Work_As_a_Team_Nathaniel_Francis.pdfITB_2023_When_Your_Applications_Work_As_a_Team_Nathaniel_Francis.pdf
ITB_2023_When_Your_Applications_Work_As_a_Team_Nathaniel_Francis.pdf
 
ITB_2023_Chatgpt_Box_Scott_Steinbeck.pdf
ITB_2023_Chatgpt_Box_Scott_Steinbeck.pdfITB_2023_Chatgpt_Box_Scott_Steinbeck.pdf
ITB_2023_Chatgpt_Box_Scott_Steinbeck.pdf
 
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdfITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
ITB_2023_CommandBox_Task_Runners_Brad_Wood.pdf
 
ITB_2023_Create_as_many_web_sites_or_web_apps_as_you_want_George_Murphy.pdf
ITB_2023_Create_as_many_web_sites_or_web_apps_as_you_want_George_Murphy.pdfITB_2023_Create_as_many_web_sites_or_web_apps_as_you_want_George_Murphy.pdf
ITB_2023_Create_as_many_web_sites_or_web_apps_as_you_want_George_Murphy.pdf
 
ITB2023 Developing for Performance - Denard Springle.pdf
ITB2023 Developing for Performance - Denard Springle.pdfITB2023 Developing for Performance - Denard Springle.pdf
ITB2023 Developing for Performance - Denard Springle.pdf
 

Recently uploaded

JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
Max Lee
 

Recently uploaded (20)

JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand
 
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
 
What need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java DevelopersWhat need to be mastered as AI-Powered Java Developers
What need to be mastered as AI-Powered Java Developers
 
Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024Food Delivery Business App Development Guide 2024
Food Delivery Business App Development Guide 2024
 
Malaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptxMalaysia E-Invoice digital signature docpptx
Malaysia E-Invoice digital signature docpptx
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdfStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi.pdf
 
OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024OpenChain @ LF Japan Executive Briefing - May 2024
OpenChain @ LF Japan Executive Briefing - May 2024
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product UpdatesGraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
GraphSummit Stockholm - Neo4j - Knowledge Graphs and Product Updates
 
The Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion ProductionThe Impact of PLM Software on Fashion Production
The Impact of PLM Software on Fashion Production
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea Goulet
 
Microsoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdfMicrosoft365_Dev_Security_2024_05_16.pdf
Microsoft365_Dev_Security_2024_05_16.pdf
 
Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024
Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024
Odoo vs Shopify: Why Odoo is Best for Ecommerce Website Builder in 2024
 
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
 
The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)The mythical technical debt. (Brooke, please, forgive me)
The mythical technical debt. (Brooke, please, forgive me)
 
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
Entropy, Software Quality, and Innovation (presented at Princeton Plasma Phys...
 
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
Tree in the Forest - Managing Details in BDD Scenarios (live2test 2024)
 
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdfImplementing KPIs and Right Metrics for Agile Delivery Teams.pdf
Implementing KPIs and Right Metrics for Agile Delivery Teams.pdf
 
architecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdfarchitecting-ai-in-the-enterprise-apis-and-applications.pdf
architecting-ai-in-the-enterprise-apis-and-applications.pdf
 

ITB_2023_Faster_Apps_That_Wont_Get_Crushed_Brian_Klaas.pdf