SlideShare una empresa de Scribd logo
1 de 25
Descargar para leer sin conexión
DON'T YOU
(FORGET
ABOUT ME)
PHP Meetup Lisboa 2023
Things developers forget to
remember not to forget
Talk by Bernd Alter
PHP Meetup Lisboa 2023
Bernd Alter
Co-CTO at Turbine Kreuzberg GmbH
Twitter: @bazoo0815
Experience:
years developer
years PHP
years eCommerce
years Spryker
25+
20+
10+
7+
PHP Meetup Lisboa 2023
DEVELOPERS
ONLY CARE ABOUT
FUNCTIONALITY
PHP Meetup Lisboa 2023
"WORKS ON MY MACHINE"
DATABASE
Local development
❏ small dataset
❏ queries are fast
❏ no memory issues
❏ no latency
❏ indexes don't really matter
Production system
❏ large(r) dataset
❏ queries are slower
❏ memory/load issues
❏ large(r) latency between services/components
❏ missing indexes (can) slow down queries
PHP Meetup Lisboa 2023
"WORKS ON MY MACHINE"
TRAFFIC
Production system
❏ (huge) traffic
❏ concurrency
❏ blocking requests
❏ lack of resources
Local development
❏ no traffic (it's just you!)
❏ single requests/processes
❏ no concurrency
❏ all resources just for you
PHP Meetup Lisboa 2023
POSSIBLE SOLUTIONS
❏ SCALING
❏ PERFORMANCE OPTIMIZATION
❏ CACHING
PHP Meetup Lisboa 2023
SCALING
Easy solution:
Throw more resources at it!
Downside:
❏ more complex orchestration
❏ increasing infrastructure costs
(resources + devops ⇒ money)
PHP Meetup Lisboa 2023
What do you consider a large dataset
in your day-to-day business?
(quick show of hands)
100.000 entries?
1.000.000 entries?
10.000.000 entries?
100.000.000 entries?
more?
DATABASE PERFORMANCE
PHP Meetup Lisboa 2023
Consider payload size of query result set
❏ transfer time matters
❏ only fetch data you need
❏ limit columns in SELECT
Example: table with ~1.200 rows, total size 42 MB, avg row size ~40kB
250ms
3.5 s
DATABASE PERFORMANCE
vs
(=14x faster)
select * from myTable;
select id from myTable;
PAYLOAD SIZE
PHP Meetup Lisboa 2023
Set proper indexes
❏ analyze your queries, not your tables
(EXPLAIN is your friend!)
❏ use composite indexes
DATABASE PERFORMANCE
INDEX ANALYSIS/OPTIMIZATION
Remember: TANSTAAFL!
❏ 'no free lunch' principle: indexes come at a cost
❏ avoid large/many indexes on tables with many write operations
❏ avoid unnecessary indexes
CREATE INDEX myIndex ON myTable (lastname, firstname);
✔ SELECT * FROM myTable WHERE lastname = ‘Smith’ AND firstname = ‘John’;
✔ SELECT * FROM myTable WHERE lastname = ‘Smith’;
✖ SELECT * FROM myTable WHERE firstname = ‘John’ and lastname = ‘Smith’;
✖ SELECT * FROM myTable WHERE firstname = ‘John’;
Index used for queries:
← size order matters!
PHP Meetup Lisboa 2023
Common approach: LIMIT/OFFSET
❏ query performance is bad
Use keyset pagination (or seek pagination)
❏ no read-ahead needed
❏ only required rows are fetched/read
+ constant execution time
+ real pagination (no missed entries)
− only previous/next page (no page jumps)
DATABASE PERFORMANCE
KEYSET/CURSOR PAGINATION
PHP Meetup Lisboa 2023
Common approach: LIMIT/OFFSET
❏ query performance is bad
Use keyset pagination (or seek pagination)
❏ no read-ahead needed
❏ only required rows are fetched/read
+ constant execution time
+ real pagination (no missed entries)
− only previous/next page (no page jumps)
DATABASE PERFORMANCE
KEYSET/CURSOR PAGINATION
PHP Meetup Lisboa 2023
DATABASE PERFORMANCE
KEYSET/CURSOR PAGINATION
PHP Meetup Lisboa 2023
Don't hit the database at all (or at least less)
❏ use bulk operations over single operations
❏ select as much data at once as possible
❏ Common Table Expressions (CTE)
❏ UPSERTs for write operations
❏ avoid unnecessary queries
DATABASE PERFORMANCE
INSERT INTO myTable (...) VALUES (...) ON DUPLICATE KEY UPDATE SET ...; (MySQL)
ON CONFLICT (...) DO UPDATE SET ...; (Postgres)
PHP Meetup Lisboa 2023
CACHING
For how long? ❏ as long as possible
❏ usually trade-off between up-to-dateness and performance
How? ❏ prepare data (aggregate/transform)
❏ in-process caching (in PHP: static (member) variables)
❏ browser-caching
❏ key-value storage (e.g. Memcache, Redis)
❏ reverse proxy (e.g. Varnish)
What? ❏ time-/resource-consuming operations
❏ often used/requested data
PHP Meetup Lisboa 2023
5 days?
5 hours?
5 min?
5 sec?
CACHING
What would you consider a reasonable
amount of time to cache for?
(quick show of hands)
PHP Meetup Lisboa 2023
Even short caching periods (TTL) can boost your application’s performance significantly
CACHING
HOW LONG?
Example: Universal Music community chat (~2008)
❏ simple iframe with latest 50 messages
❏ ajax-reload every 10s
❏ ~1.000 concurrent users
⟶ ~6.000 req/min
PHP Meetup Lisboa 2023
Even short caching periods (TTL) can boost your application’s performance significantly
CACHING
HOW LONG?
Solution:
❏ local file cache with TTL of 5s
Example: Universal Music community chat (~2008)
❏ simple iframe with latest 50 messages
❏ ajax-reload every 10s
❏ ~1.000 concurrent users
⟶ ~6.000 req/min
—> 12 req/min (500x less)
PHP Meetup Lisboa 2023
CACHING
❏ ensure fast, responsive experience for all users
❏ use stale-while-revalidate mechanism
(supported by all modern browsers)
❏ after first caching, all users get always
(sufficiently) up-to-date data
ADVANCED TECHNIQUES
PHP Meetup Lisboa 2023
Try to make all your non-production environments as production-like as possible:
DEVELOP PRODUCTION-LIKE
❏ replicate infrastructure in development, testing and staging environments
❏ use Docker
❏ ideal: use same components/services in exactly same version and resources (CPU, memory, etc.)
❏ at least: use same components/services in same major version and similar resources
❏ use production-like dataset for development and staging/testing
❏ ideal: complete anonymized/pseudonymized production dump (-->GDPR!)
❏ at least: similar amount of data for crucial entities, e.g. products, prices, customers in ecommerce
PHP Meetup Lisboa 2023
There is no such thing as 'another production system'
DEVELOP PRODUCTION-LIKE
DISCLAIMER
You cannot duplicate your production system.
Period.
Live with it …
❏ traffic is different
❏ state of data is different
❏ services/components have different versions
❏ …
PHP Meetup Lisboa 2023
FEATURE TRAP
❏ also work on:
❏ tech debt
❏ updates
❏ refactoring
❏ maintenance tasks
❏ no immediate, but long-term business value
❏ stand up to your PO or stakeholders!
"WE HAVE TO BUILD FEATURES,
WE DON'T HAVE TIME FOR OTHER STUFF"
PHP Meetup Lisboa 2023
LINKS
❏ Use The Index, Luke
❏ No offset: We need tool support for keyset pagination
❏ SQL CTE (WITH Clause): The Ultimate Guide - Database Star
❏ Staleness and revalidation
❏ GitHub - DivanteLtd/anonymizer: Universal tool to anonymize database
❏ Blackfire.io - PHP profiling tool
PHP Meetup Lisboa 2023
QUESTIONS?
PHP Meetup Lisboa 2023
FOR LISTENING!

Más contenido relacionado

La actualidad más candente

Educate, Entertain or Convince: Three Beneficial Approaches to Content Marketing
Educate, Entertain or Convince: Three Beneficial Approaches to Content MarketingEducate, Entertain or Convince: Three Beneficial Approaches to Content Marketing
Educate, Entertain or Convince: Three Beneficial Approaches to Content MarketingBrian Honigman
 
Unit of Value: A Framework for Scaling
Unit of Value: A Framework for ScalingUnit of Value: A Framework for Scaling
Unit of Value: A Framework for ScalingGreylock Partners
 
Sales Decks for Founders - Founding Sales - December 2015
Sales Decks for Founders - Founding Sales - December 2015 Sales Decks for Founders - Founding Sales - December 2015
Sales Decks for Founders - Founding Sales - December 2015 Peter Kazanjy
 
Use the Progress Board to Test your Business Ideas
Use the Progress Board to Test your Business IdeasUse the Progress Board to Test your Business Ideas
Use the Progress Board to Test your Business IdeasStrategyzer
 
The Sales Hacker Deck On Sales Decks
The Sales Hacker Deck On Sales DecksThe Sales Hacker Deck On Sales Decks
The Sales Hacker Deck On Sales DecksSales Hacker
 
SBA Final - Dick's Sporting Goods
SBA Final - Dick's Sporting GoodsSBA Final - Dick's Sporting Goods
SBA Final - Dick's Sporting GoodsStephen Lukridge
 
Startup Secrets - Getting Behind the Perfect Investor Pitch
Startup Secrets - Getting Behind the Perfect Investor PitchStartup Secrets - Getting Behind the Perfect Investor Pitch
Startup Secrets - Getting Behind the Perfect Investor PitchMichael Skok
 
Zero to 100 - Part 1: Intro + First Section
Zero to 100 - Part 1: Intro + First SectionZero to 100 - Part 1: Intro + First Section
Zero to 100 - Part 1: Intro + First SectionDavid Skok
 
Zero to 100 - Part 2: Building a Repeatable, Scalable Growth Process
Zero to 100 - Part 2: Building a Repeatable, Scalable Growth ProcessZero to 100 - Part 2: Building a Repeatable, Scalable Growth Process
Zero to 100 - Part 2: Building a Repeatable, Scalable Growth ProcessDavid Skok
 
Marketing Communications Strategy
Marketing Communications StrategyMarketing Communications Strategy
Marketing Communications StrategyDmitry Dragilev
 
Transform Your Marketing
Transform Your MarketingTransform Your Marketing
Transform Your MarketingHubSpot
 
How to Craft Your Company's Storytelling Voice by Ann Handley of MarketingProfs
How to Craft Your Company's Storytelling Voice by Ann Handley of MarketingProfsHow to Craft Your Company's Storytelling Voice by Ann Handley of MarketingProfs
How to Craft Your Company's Storytelling Voice by Ann Handley of MarketingProfsMarketingProfs
 
The Hero's Journey (For movie fans, Lego fans, and presenters!)
The Hero's Journey (For movie fans, Lego fans, and presenters!)The Hero's Journey (For movie fans, Lego fans, and presenters!)
The Hero's Journey (For movie fans, Lego fans, and presenters!)Dan Roam
 
Pixar's 22 Rules to Phenomenal Storytelling
Pixar's 22 Rules to Phenomenal StorytellingPixar's 22 Rules to Phenomenal Storytelling
Pixar's 22 Rules to Phenomenal StorytellingGavin McMahon
 
LinkedIn b2b marketing
LinkedIn b2b marketingLinkedIn b2b marketing
LinkedIn b2b marketingKannan Gophal
 

La actualidad más candente (20)

Educate, Entertain or Convince: Three Beneficial Approaches to Content Marketing
Educate, Entertain or Convince: Three Beneficial Approaches to Content MarketingEducate, Entertain or Convince: Three Beneficial Approaches to Content Marketing
Educate, Entertain or Convince: Three Beneficial Approaches to Content Marketing
 
Unit of Value: A Framework for Scaling
Unit of Value: A Framework for ScalingUnit of Value: A Framework for Scaling
Unit of Value: A Framework for Scaling
 
Science: An lntellectual Adventure
Science: An lntellectual AdventureScience: An lntellectual Adventure
Science: An lntellectual Adventure
 
Sales Decks for Founders - Founding Sales - December 2015
Sales Decks for Founders - Founding Sales - December 2015 Sales Decks for Founders - Founding Sales - December 2015
Sales Decks for Founders - Founding Sales - December 2015
 
The Build Trap
The Build TrapThe Build Trap
The Build Trap
 
Use the Progress Board to Test your Business Ideas
Use the Progress Board to Test your Business IdeasUse the Progress Board to Test your Business Ideas
Use the Progress Board to Test your Business Ideas
 
The Sales Hacker Deck On Sales Decks
The Sales Hacker Deck On Sales DecksThe Sales Hacker Deck On Sales Decks
The Sales Hacker Deck On Sales Decks
 
Damn Good Advice
Damn Good AdviceDamn Good Advice
Damn Good Advice
 
SBA Final - Dick's Sporting Goods
SBA Final - Dick's Sporting GoodsSBA Final - Dick's Sporting Goods
SBA Final - Dick's Sporting Goods
 
Startup Secrets - Getting Behind the Perfect Investor Pitch
Startup Secrets - Getting Behind the Perfect Investor PitchStartup Secrets - Getting Behind the Perfect Investor Pitch
Startup Secrets - Getting Behind the Perfect Investor Pitch
 
Zero to 100 - Part 1: Intro + First Section
Zero to 100 - Part 1: Intro + First SectionZero to 100 - Part 1: Intro + First Section
Zero to 100 - Part 1: Intro + First Section
 
Zero to 100 - Part 2: Building a Repeatable, Scalable Growth Process
Zero to 100 - Part 2: Building a Repeatable, Scalable Growth ProcessZero to 100 - Part 2: Building a Repeatable, Scalable Growth Process
Zero to 100 - Part 2: Building a Repeatable, Scalable Growth Process
 
Marketing Communications Strategy
Marketing Communications StrategyMarketing Communications Strategy
Marketing Communications Strategy
 
Peter thiel’s cs183
Peter thiel’s cs183Peter thiel’s cs183
Peter thiel’s cs183
 
Transform Your Marketing
Transform Your MarketingTransform Your Marketing
Transform Your Marketing
 
How to Craft Your Company's Storytelling Voice by Ann Handley of MarketingProfs
How to Craft Your Company's Storytelling Voice by Ann Handley of MarketingProfsHow to Craft Your Company's Storytelling Voice by Ann Handley of MarketingProfs
How to Craft Your Company's Storytelling Voice by Ann Handley of MarketingProfs
 
The Hero's Journey (For movie fans, Lego fans, and presenters!)
The Hero's Journey (For movie fans, Lego fans, and presenters!)The Hero's Journey (For movie fans, Lego fans, and presenters!)
The Hero's Journey (For movie fans, Lego fans, and presenters!)
 
Writing Effective Creative Briefs
Writing Effective Creative BriefsWriting Effective Creative Briefs
Writing Effective Creative Briefs
 
Pixar's 22 Rules to Phenomenal Storytelling
Pixar's 22 Rules to Phenomenal StorytellingPixar's 22 Rules to Phenomenal Storytelling
Pixar's 22 Rules to Phenomenal Storytelling
 
LinkedIn b2b marketing
LinkedIn b2b marketingLinkedIn b2b marketing
LinkedIn b2b marketing
 

Similar a Don't you (forget about me) - PHP Meetup Lisboa 2023

Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!mold
 
Headless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in MagentoHeadless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in MagentoSander Mangel
 
How to deploy & optimize eZ Publish
How to deploy & optimize eZ PublishHow to deploy & optimize eZ Publish
How to deploy & optimize eZ PublishKaliop-slide
 
Kill mysql-performance
Kill mysql-performanceKill mysql-performance
Kill mysql-performancekriptonium
 
Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)Klas Berlič Fras
 
Optimizing Python
Optimizing PythonOptimizing Python
Optimizing PythonAdimianBE
 
My Database Skills Killed the Server
My Database Skills Killed the ServerMy Database Skills Killed the Server
My Database Skills Killed the ServerColdFusionConference
 
SOUG_Deployment__Automation_DB
SOUG_Deployment__Automation_DBSOUG_Deployment__Automation_DB
SOUG_Deployment__Automation_DBUniFabric
 
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...javier ramirez
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalabilityWim Godden
 
Black Friday and Cyber Monday- Best Practices for Your E-Commerce Database
Black Friday and Cyber Monday- Best Practices for Your E-Commerce DatabaseBlack Friday and Cyber Monday- Best Practices for Your E-Commerce Database
Black Friday and Cyber Monday- Best Practices for Your E-Commerce DatabaseTim Vaillancourt
 
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
 
Lunch & Learn BigQuery & Firebase from other Google Cloud customers
Lunch & Learn BigQuery & Firebase from other Google Cloud customersLunch & Learn BigQuery & Firebase from other Google Cloud customers
Lunch & Learn BigQuery & Firebase from other Google Cloud customersDaniel Zivkovic
 
MySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossukMySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossukValeriy Kravchuk
 
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...it-people
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Wim Godden
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindSam Keen
 
DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.Vlad Fedosov
 

Similar a Don't you (forget about me) - PHP Meetup Lisboa 2023 (20)

Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!
 
Headless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in MagentoHeadless approach for offloading heavy tasks in Magento
Headless approach for offloading heavy tasks in Magento
 
How to deploy & optimize eZ Publish
How to deploy & optimize eZ PublishHow to deploy & optimize eZ Publish
How to deploy & optimize eZ Publish
 
Kill mysql-performance
Kill mysql-performanceKill mysql-performance
Kill mysql-performance
 
Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)Basic Application Performance Optimization Techniques (Backend)
Basic Application Performance Optimization Techniques (Backend)
 
Optimizing Python
Optimizing PythonOptimizing Python
Optimizing Python
 
My Database Skills Killed the Server
My Database Skills Killed the ServerMy Database Skills Killed the Server
My Database Skills Killed the Server
 
SOUG_Deployment__Automation_DB
SOUG_Deployment__Automation_DBSOUG_Deployment__Automation_DB
SOUG_Deployment__Automation_DB
 
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
Cómo se diseña una base de datos que pueda ingerir más de cuatro millones de ...
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
Black Friday and Cyber Monday- Best Practices for Your E-Commerce Database
Black Friday and Cyber Monday- Best Practices for Your E-Commerce DatabaseBlack Friday and Cyber Monday- Best Practices for Your E-Commerce Database
Black Friday and Cyber Monday- Best Practices for Your E-Commerce Database
 
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
 
Lunch & Learn BigQuery & Firebase from other Google Cloud customers
Lunch & Learn BigQuery & Firebase from other Google Cloud customersLunch & Learn BigQuery & Firebase from other Google Cloud customers
Lunch & Learn BigQuery & Firebase from other Google Cloud customers
 
Ad505 dev blast
Ad505 dev blastAd505 dev blast
Ad505 dev blast
 
MySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossukMySQL Performance schema missing_manual_flossuk
MySQL Performance schema missing_manual_flossuk
 
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
 
pm1
pm1pm1
pm1
 
Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011Caching and tuning fun for high scalability @ FrOSCon 2011
Caching and tuning fun for high scalability @ FrOSCon 2011
 
Profiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / WebgrindProfiling PHP with Xdebug / Webgrind
Profiling PHP with Xdebug / Webgrind
 
DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.DevOps Fest 2020. immutable infrastructure as code. True story.
DevOps Fest 2020. immutable infrastructure as code. True story.
 

Último

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Último (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Don't you (forget about me) - PHP Meetup Lisboa 2023

  • 1. DON'T YOU (FORGET ABOUT ME) PHP Meetup Lisboa 2023 Things developers forget to remember not to forget Talk by Bernd Alter
  • 2. PHP Meetup Lisboa 2023 Bernd Alter Co-CTO at Turbine Kreuzberg GmbH Twitter: @bazoo0815 Experience: years developer years PHP years eCommerce years Spryker 25+ 20+ 10+ 7+
  • 3. PHP Meetup Lisboa 2023 DEVELOPERS ONLY CARE ABOUT FUNCTIONALITY
  • 4. PHP Meetup Lisboa 2023 "WORKS ON MY MACHINE" DATABASE Local development ❏ small dataset ❏ queries are fast ❏ no memory issues ❏ no latency ❏ indexes don't really matter Production system ❏ large(r) dataset ❏ queries are slower ❏ memory/load issues ❏ large(r) latency between services/components ❏ missing indexes (can) slow down queries
  • 5. PHP Meetup Lisboa 2023 "WORKS ON MY MACHINE" TRAFFIC Production system ❏ (huge) traffic ❏ concurrency ❏ blocking requests ❏ lack of resources Local development ❏ no traffic (it's just you!) ❏ single requests/processes ❏ no concurrency ❏ all resources just for you
  • 6. PHP Meetup Lisboa 2023 POSSIBLE SOLUTIONS ❏ SCALING ❏ PERFORMANCE OPTIMIZATION ❏ CACHING
  • 7. PHP Meetup Lisboa 2023 SCALING Easy solution: Throw more resources at it! Downside: ❏ more complex orchestration ❏ increasing infrastructure costs (resources + devops ⇒ money)
  • 8. PHP Meetup Lisboa 2023 What do you consider a large dataset in your day-to-day business? (quick show of hands) 100.000 entries? 1.000.000 entries? 10.000.000 entries? 100.000.000 entries? more? DATABASE PERFORMANCE
  • 9. PHP Meetup Lisboa 2023 Consider payload size of query result set ❏ transfer time matters ❏ only fetch data you need ❏ limit columns in SELECT Example: table with ~1.200 rows, total size 42 MB, avg row size ~40kB 250ms 3.5 s DATABASE PERFORMANCE vs (=14x faster) select * from myTable; select id from myTable; PAYLOAD SIZE
  • 10. PHP Meetup Lisboa 2023 Set proper indexes ❏ analyze your queries, not your tables (EXPLAIN is your friend!) ❏ use composite indexes DATABASE PERFORMANCE INDEX ANALYSIS/OPTIMIZATION Remember: TANSTAAFL! ❏ 'no free lunch' principle: indexes come at a cost ❏ avoid large/many indexes on tables with many write operations ❏ avoid unnecessary indexes CREATE INDEX myIndex ON myTable (lastname, firstname); ✔ SELECT * FROM myTable WHERE lastname = ‘Smith’ AND firstname = ‘John’; ✔ SELECT * FROM myTable WHERE lastname = ‘Smith’; ✖ SELECT * FROM myTable WHERE firstname = ‘John’ and lastname = ‘Smith’; ✖ SELECT * FROM myTable WHERE firstname = ‘John’; Index used for queries: ← size order matters!
  • 11. PHP Meetup Lisboa 2023 Common approach: LIMIT/OFFSET ❏ query performance is bad Use keyset pagination (or seek pagination) ❏ no read-ahead needed ❏ only required rows are fetched/read + constant execution time + real pagination (no missed entries) − only previous/next page (no page jumps) DATABASE PERFORMANCE KEYSET/CURSOR PAGINATION
  • 12. PHP Meetup Lisboa 2023 Common approach: LIMIT/OFFSET ❏ query performance is bad Use keyset pagination (or seek pagination) ❏ no read-ahead needed ❏ only required rows are fetched/read + constant execution time + real pagination (no missed entries) − only previous/next page (no page jumps) DATABASE PERFORMANCE KEYSET/CURSOR PAGINATION
  • 13. PHP Meetup Lisboa 2023 DATABASE PERFORMANCE KEYSET/CURSOR PAGINATION
  • 14. PHP Meetup Lisboa 2023 Don't hit the database at all (or at least less) ❏ use bulk operations over single operations ❏ select as much data at once as possible ❏ Common Table Expressions (CTE) ❏ UPSERTs for write operations ❏ avoid unnecessary queries DATABASE PERFORMANCE INSERT INTO myTable (...) VALUES (...) ON DUPLICATE KEY UPDATE SET ...; (MySQL) ON CONFLICT (...) DO UPDATE SET ...; (Postgres)
  • 15. PHP Meetup Lisboa 2023 CACHING For how long? ❏ as long as possible ❏ usually trade-off between up-to-dateness and performance How? ❏ prepare data (aggregate/transform) ❏ in-process caching (in PHP: static (member) variables) ❏ browser-caching ❏ key-value storage (e.g. Memcache, Redis) ❏ reverse proxy (e.g. Varnish) What? ❏ time-/resource-consuming operations ❏ often used/requested data
  • 16. PHP Meetup Lisboa 2023 5 days? 5 hours? 5 min? 5 sec? CACHING What would you consider a reasonable amount of time to cache for? (quick show of hands)
  • 17. PHP Meetup Lisboa 2023 Even short caching periods (TTL) can boost your application’s performance significantly CACHING HOW LONG? Example: Universal Music community chat (~2008) ❏ simple iframe with latest 50 messages ❏ ajax-reload every 10s ❏ ~1.000 concurrent users ⟶ ~6.000 req/min
  • 18. PHP Meetup Lisboa 2023 Even short caching periods (TTL) can boost your application’s performance significantly CACHING HOW LONG? Solution: ❏ local file cache with TTL of 5s Example: Universal Music community chat (~2008) ❏ simple iframe with latest 50 messages ❏ ajax-reload every 10s ❏ ~1.000 concurrent users ⟶ ~6.000 req/min —> 12 req/min (500x less)
  • 19. PHP Meetup Lisboa 2023 CACHING ❏ ensure fast, responsive experience for all users ❏ use stale-while-revalidate mechanism (supported by all modern browsers) ❏ after first caching, all users get always (sufficiently) up-to-date data ADVANCED TECHNIQUES
  • 20. PHP Meetup Lisboa 2023 Try to make all your non-production environments as production-like as possible: DEVELOP PRODUCTION-LIKE ❏ replicate infrastructure in development, testing and staging environments ❏ use Docker ❏ ideal: use same components/services in exactly same version and resources (CPU, memory, etc.) ❏ at least: use same components/services in same major version and similar resources ❏ use production-like dataset for development and staging/testing ❏ ideal: complete anonymized/pseudonymized production dump (-->GDPR!) ❏ at least: similar amount of data for crucial entities, e.g. products, prices, customers in ecommerce
  • 21. PHP Meetup Lisboa 2023 There is no such thing as 'another production system' DEVELOP PRODUCTION-LIKE DISCLAIMER You cannot duplicate your production system. Period. Live with it … ❏ traffic is different ❏ state of data is different ❏ services/components have different versions ❏ …
  • 22. PHP Meetup Lisboa 2023 FEATURE TRAP ❏ also work on: ❏ tech debt ❏ updates ❏ refactoring ❏ maintenance tasks ❏ no immediate, but long-term business value ❏ stand up to your PO or stakeholders! "WE HAVE TO BUILD FEATURES, WE DON'T HAVE TIME FOR OTHER STUFF"
  • 23. PHP Meetup Lisboa 2023 LINKS ❏ Use The Index, Luke ❏ No offset: We need tool support for keyset pagination ❏ SQL CTE (WITH Clause): The Ultimate Guide - Database Star ❏ Staleness and revalidation ❏ GitHub - DivanteLtd/anonymizer: Universal tool to anonymize database ❏ Blackfire.io - PHP profiling tool
  • 24. PHP Meetup Lisboa 2023 QUESTIONS?
  • 25. PHP Meetup Lisboa 2023 FOR LISTENING!