SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Procrastination
As A Service:
Caching &
Queueing
Presented by : Lawrence Shea
Photo by Kleber Varejão Filho on Unsplash
Hi, I’m Lawrence Shea
- PHP Developer for 6+ years
- Worked @verizondigital since Oct’16
- @soWizardly on Twitter
- Co-Organizer, Boston PHP (Next: July 28th)
- Moderator of /r/PHPHelp
- I don’t like pina coladas, or getting caught in
the rain
Raise your
hand if your
parents ever...
Scolded you for
not putting away
your toys
Photo by Ryan Franco on Unsplash
Raise your
hand if your
parents ever...
Believed you when you said
you’d made the bed
(you hadn’t done it yet)
Photo by Ryan Franco on Unsplash
Raise your
hand if your
parents ever...
Got mad at you for
procrastinating on homework,
But you got an A anyway
Photo by Ryan Franco on Unsplash
Your Parents Were Wrong!
Dr. Jin Nam Choy
- Published in 2005 study in The
Journal of Social Psychology
- Two types of procrastinators:
Active & Passive
- Passive procrastinators are
“typical”
- Active procrastinators at least
equal to non-procrastinators
Download: PDF
- Open source
- In memory data store
- Written in ANSI C
- Works as a cache
- Works as a message broker
- Many data structures
- Built in replication
- Configurable persistence
- For beginners & enterprise
- Will do your laundry
Download: https://redis.io
Photo by Anna Samoylova on Unsplash
Photo by Anna Samoylova on Unsplash
Let’s talk about Caching
a cache /kæʃ/ KASH,[1] is a hardware or software component that
stores data so future requests for that data can be served faster;
the data stored in a cache might be the result of an earlier
computation, or the duplicate of data stored elsewhere.
- https://en.wikipedia.org/wiki/Cache_(computing)
Photo by Maico Amorim on Unsplash
But where is
CACHING
useful?
Photo by Brad Barmore on Unsplash
users
user_id | username
================
1 | Bob
2 | Alice
3 | Frank
Etc...
user_coworker
user_id | coworker_id
================
1 | 2
3 | 1
Etc...
SELECT username
FROM tbl_user_coworker
JOIN tbl_users
ON (
tbl_users.user_id = tbl_user_coworker.coworker_id)
WHERE tbl_user_coworker.user_id IN
(
SELECT uc.coworker_id
FROM tbl_user_coworker AS uc
LEFT JOIN tbl_users AS u
ON (
uc.coworker_id = u.user_id)
WHERE uc.user_id IN
(
SELECT uc.coworker_id
FROM tbl_user_coworker AS uc
LEFT JOIN tbl_users AS u
ON (
uc.coworker_id = u.user_id)
WHERE uc.user_id = 1 )
UNION
(
SELECT uc.coworker_id
FROM tbl_user_coworker AS uc
LEFT JOIN tbl_users AS u
ON (
uc.coworker_id = u.user_id)
WHERE uc.user_id = 1 ) )
AND coworker_id <> 1
ORDER BY username
Kcachegrind results on this laptop
Subsequent
request
24.53% faster
Initial request up
only 2.51%
Photo by Ben White on Unsplash
We can use
CRON JOBS
to make every
request a
subsequent
request
*sometimes
Photo by Ben White on Unsplash
Can we Cache a
LEADERBOARD?
Ask yourself & team if you
REALLY need live data.
Even just 1 minute old
data can significantly
improve performance
Photo by Leslie Jones on Unsplash
“We now sell branded hats,
t-shirts, flip flops, handbags,
bluetooth speakers,
headsets, etc, etc, etc... and
not just one of each either!
Those are just the
categories! Our inventory of
over a million products is
showing up on monday!”
Photo by Leslie Jones on UnsplashPhoto by Bernard Hermant on Unsplash
Multiple Requests
to Cache on one
page?
Cache the WHOLE
PAGE, now just one
request
#InceptionCache
Photo by Ash from Modern Afflatus on Unsplash
Weeks have gone
by, and everything
seems quiet…
Too Quiet.
Photo by Kristina Flour on Unsplash
Create a simple form, get
that on a page and a link to
it in the footer, commit that,
make a PR, get it approved,
and done. Not bad for 5pm
on a Friday.
Everything is fine, time
to go home! Photo by Rob Bye on Unsplash
The email address is
blowing up! Thousands
of requests per second
for: item exchanges,
product questions, ‘how
do i do this’ questions,
just everything you
could think of.
Photo by Arny Mogensen on Unsplash
Our simple contact
form was never
intended to handle this
kind of load! Requests
are taking 20 seconds
to complete when they
aren’t just outright
failing! Photo by Mathew Schwartz on Unsplash
How do we
handle
thousands of
contact form
submissions
per second?
Lawrence shea
myemail@ok.com
How to order just 1 shoe
HELP PLZ! I submitted this form
three times and all three times
it took 2 minutes to say internal
server error what does that mean
Photo by Anna Samoylova on Unsplash
- Instant Success message
- Actually, send job off to do later
- We can queue jobs very fast
- Do work in the background
- Huge response time improvement
- Particularly fault tolerant
- Retry failed jobs
WHY JOB QUEUES?
Photo by Julie Johnson on Unsplash
What’s the Status Code?
202 - Accepted.
The request has been accepted for processing,
but the processing has not been completed.
The request might or might not eventually be
acted upon, as it might be disallowed when
processing actually takes place
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
Photo by Jakob Owens on Unsplash
Which Package?
This is built into or easily integrated into frameworks in
many languages, but some examples are;
https://github.com/chrisboulton/php-resque for PHP
https://github.com/rq/django-rq for Python/Django &
https://github.com/smrchy/rsmq for JS
Photo by chuttersnap on Unsplash
But how fast is
JOB QUEUEING?
Photo by Ahsan Avi on Unsplash
Kcachegrind results on this laptop
But how fast is JOB QUEUEING?
Photo by Ahsan Avi on Unsplash
Sending five emails took 7.5 Seconds
Adding to queue took 2.02 Seconds
Decrease response time by 73.06%
Even when Frank
tripped over the
power cord to the
central email
server, emails
were eventually
sent. No user got
an error message!
Photo by Daniel Páscoa on Unsplash
Frank
What else can we
QUEUE?
Queue Limitations?
It’s only going to work when we don’t
actually need to respond to the user
with anything particularly useful.
Because we haven’t done the work
yet!
But can we overcome this limitation?
Photo by Feifei Peng on Unsplash
To Don’t?
Queue the addition of a task to
a to-do list? But if we do the job
later suddenly we have a
confused user.
They didn’t get an error, and
yet, there to-do app isn’t
updated with the task they just
submitted!
Photo by Jason Rosewell on Unsplash
WebSockets, an advanced
technology that makes it possible to
open an interactive communication
session between the user's browser
and a server. With this API, you can
send messages to a server and
receive event-driven responses
without having to poll the server for
a reply.
https://developer.mozilla.org/en-
US/docs/Web/API/WebSockets_A
PI
Which Package?
There are many options, but to name a few:
- Ratchet (PHP) http://socketo.me/
- WebSocketJS https://github.com/gimite/web-socket-js
- Python/Django https://github.com/jrief/django-websocket-redis
Photo by chuttersnap on Unsplash
No matter where you are on
your coder journey, it’s
never too early or too late to
improve performance by
actively procrastinating.
Procrastination
As A Service:
Caching &
Queueing
Presented by : Lawrence Shea
Photo by Kleber Varejão Filho on Unsplash
I’m still Lawrence Shea
- PHP Developer for 6+ years
- Worked @verizondigital since Oct’16
- @soWizardly on Twitter
- Co-Organizer, Boston PHP
- Moderator of /r/PHPHelp
- THANK YOU!!!

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
Comprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdfComprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdfalene1
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmDeepika Walanjkar
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfPaper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfNainaShrivastava14
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodManicka Mamallan Andavar
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communicationpanditadesh123
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptJohnWilliam111370
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solidnamansinghjarodiya
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdfAkritiPradhan2
 
signals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsignals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsapna80328
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfChristianCDAM
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsResearcher Researcher
 

Kürzlich hochgeladen (20)

Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Comprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdfComprehensive energy systems.pdf Comprehensive energy systems.pdf
Comprehensive energy systems.pdf Comprehensive energy systems.pdf
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfPaper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument method
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communication
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
Engineering Drawing section of solid
Engineering Drawing     section of solidEngineering Drawing     section of solid
Engineering Drawing section of solid
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
 
signals in triangulation .. ...Surveying
signals in triangulation .. ...Surveyingsignals in triangulation .. ...Surveying
signals in triangulation .. ...Surveying
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdf
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
Novel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending ActuatorsNovel 3D-Printed Soft Linear and Bending Actuators
Novel 3D-Printed Soft Linear and Bending Actuators
 

Empfohlen

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Empfohlen (20)

AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Procrastination as a Service: Caching and Queueing

  • 1. Procrastination As A Service: Caching & Queueing Presented by : Lawrence Shea Photo by Kleber Varejão Filho on Unsplash
  • 2. Hi, I’m Lawrence Shea - PHP Developer for 6+ years - Worked @verizondigital since Oct’16 - @soWizardly on Twitter - Co-Organizer, Boston PHP (Next: July 28th) - Moderator of /r/PHPHelp - I don’t like pina coladas, or getting caught in the rain
  • 3. Raise your hand if your parents ever... Scolded you for not putting away your toys Photo by Ryan Franco on Unsplash
  • 4. Raise your hand if your parents ever... Believed you when you said you’d made the bed (you hadn’t done it yet) Photo by Ryan Franco on Unsplash
  • 5. Raise your hand if your parents ever... Got mad at you for procrastinating on homework, But you got an A anyway Photo by Ryan Franco on Unsplash
  • 7. Dr. Jin Nam Choy - Published in 2005 study in The Journal of Social Psychology - Two types of procrastinators: Active & Passive - Passive procrastinators are “typical” - Active procrastinators at least equal to non-procrastinators Download: PDF
  • 8. - Open source - In memory data store - Written in ANSI C - Works as a cache - Works as a message broker - Many data structures - Built in replication - Configurable persistence - For beginners & enterprise - Will do your laundry Download: https://redis.io
  • 9. Photo by Anna Samoylova on Unsplash
  • 10. Photo by Anna Samoylova on Unsplash
  • 11. Let’s talk about Caching a cache /kæʃ/ KASH,[1] is a hardware or software component that stores data so future requests for that data can be served faster; the data stored in a cache might be the result of an earlier computation, or the duplicate of data stored elsewhere. - https://en.wikipedia.org/wiki/Cache_(computing) Photo by Maico Amorim on Unsplash
  • 12. But where is CACHING useful? Photo by Brad Barmore on Unsplash
  • 13. users user_id | username ================ 1 | Bob 2 | Alice 3 | Frank Etc... user_coworker user_id | coworker_id ================ 1 | 2 3 | 1 Etc... SELECT username FROM tbl_user_coworker JOIN tbl_users ON ( tbl_users.user_id = tbl_user_coworker.coworker_id) WHERE tbl_user_coworker.user_id IN ( SELECT uc.coworker_id FROM tbl_user_coworker AS uc LEFT JOIN tbl_users AS u ON ( uc.coworker_id = u.user_id) WHERE uc.user_id IN ( SELECT uc.coworker_id FROM tbl_user_coworker AS uc LEFT JOIN tbl_users AS u ON ( uc.coworker_id = u.user_id) WHERE uc.user_id = 1 ) UNION ( SELECT uc.coworker_id FROM tbl_user_coworker AS uc LEFT JOIN tbl_users AS u ON ( uc.coworker_id = u.user_id) WHERE uc.user_id = 1 ) ) AND coworker_id <> 1 ORDER BY username
  • 14. Kcachegrind results on this laptop
  • 15. Subsequent request 24.53% faster Initial request up only 2.51% Photo by Ben White on Unsplash
  • 16. We can use CRON JOBS to make every request a subsequent request *sometimes Photo by Ben White on Unsplash
  • 17. Can we Cache a LEADERBOARD? Ask yourself & team if you REALLY need live data. Even just 1 minute old data can significantly improve performance Photo by Leslie Jones on Unsplash
  • 18. “We now sell branded hats, t-shirts, flip flops, handbags, bluetooth speakers, headsets, etc, etc, etc... and not just one of each either! Those are just the categories! Our inventory of over a million products is showing up on monday!” Photo by Leslie Jones on UnsplashPhoto by Bernard Hermant on Unsplash
  • 19. Multiple Requests to Cache on one page? Cache the WHOLE PAGE, now just one request #InceptionCache Photo by Ash from Modern Afflatus on Unsplash
  • 20. Weeks have gone by, and everything seems quiet… Too Quiet. Photo by Kristina Flour on Unsplash
  • 21. Create a simple form, get that on a page and a link to it in the footer, commit that, make a PR, get it approved, and done. Not bad for 5pm on a Friday. Everything is fine, time to go home! Photo by Rob Bye on Unsplash
  • 22. The email address is blowing up! Thousands of requests per second for: item exchanges, product questions, ‘how do i do this’ questions, just everything you could think of. Photo by Arny Mogensen on Unsplash
  • 23. Our simple contact form was never intended to handle this kind of load! Requests are taking 20 seconds to complete when they aren’t just outright failing! Photo by Mathew Schwartz on Unsplash
  • 24. How do we handle thousands of contact form submissions per second? Lawrence shea myemail@ok.com How to order just 1 shoe HELP PLZ! I submitted this form three times and all three times it took 2 minutes to say internal server error what does that mean
  • 25. Photo by Anna Samoylova on Unsplash
  • 26. - Instant Success message - Actually, send job off to do later - We can queue jobs very fast - Do work in the background - Huge response time improvement - Particularly fault tolerant - Retry failed jobs WHY JOB QUEUES? Photo by Julie Johnson on Unsplash
  • 27. What’s the Status Code? 202 - Accepted. The request has been accepted for processing, but the processing has not been completed. The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html Photo by Jakob Owens on Unsplash
  • 28. Which Package? This is built into or easily integrated into frameworks in many languages, but some examples are; https://github.com/chrisboulton/php-resque for PHP https://github.com/rq/django-rq for Python/Django & https://github.com/smrchy/rsmq for JS Photo by chuttersnap on Unsplash
  • 29. But how fast is JOB QUEUEING? Photo by Ahsan Avi on Unsplash
  • 30. Kcachegrind results on this laptop
  • 31. But how fast is JOB QUEUEING? Photo by Ahsan Avi on Unsplash Sending five emails took 7.5 Seconds Adding to queue took 2.02 Seconds Decrease response time by 73.06%
  • 32. Even when Frank tripped over the power cord to the central email server, emails were eventually sent. No user got an error message! Photo by Daniel Páscoa on Unsplash Frank
  • 33. What else can we QUEUE?
  • 34. Queue Limitations? It’s only going to work when we don’t actually need to respond to the user with anything particularly useful. Because we haven’t done the work yet! But can we overcome this limitation? Photo by Feifei Peng on Unsplash
  • 35. To Don’t? Queue the addition of a task to a to-do list? But if we do the job later suddenly we have a confused user. They didn’t get an error, and yet, there to-do app isn’t updated with the task they just submitted! Photo by Jason Rosewell on Unsplash
  • 36. WebSockets, an advanced technology that makes it possible to open an interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply. https://developer.mozilla.org/en- US/docs/Web/API/WebSockets_A PI
  • 37. Which Package? There are many options, but to name a few: - Ratchet (PHP) http://socketo.me/ - WebSocketJS https://github.com/gimite/web-socket-js - Python/Django https://github.com/jrief/django-websocket-redis Photo by chuttersnap on Unsplash
  • 38. No matter where you are on your coder journey, it’s never too early or too late to improve performance by actively procrastinating.
  • 39. Procrastination As A Service: Caching & Queueing Presented by : Lawrence Shea Photo by Kleber Varejão Filho on Unsplash
  • 40. I’m still Lawrence Shea - PHP Developer for 6+ years - Worked @verizondigital since Oct’16 - @soWizardly on Twitter - Co-Organizer, Boston PHP - Moderator of /r/PHPHelp - THANK YOU!!!