SlideShare ist ein Scribd-Unternehmen logo
1 von 45
BASIC APPLICATION OPTIMIZATION
TECHNIQUES (BACKEND)
JAB 17
Klas Berlič Fras
ABOUT ME
A founder of a boutique web and marketing communications agency Drzno,
providing integrated communication solutions with focus on the digital
communication and website development.
Marketing communication strategies. Design. Digital communication.
ABOUT ME
I try to do different stuff differently 
ABOUT ME
• Organized 48 hours music festival featuring Guano Apes (German band
performing on MTV awards at the time)
• Published a poetry book
• Ran 3 consecutive political marketing campaigns. We won in all 3.
ČELAN VIDEO
BELMONDO.SI
COMMON BOTTLENECKS
• Poorly designed database (Joomla permissions in JSON) and slow queries
• Expensive CPU operations: image resizing, calculations
• Expensive network operations: webservices, network disks
• Filesystem operations: even with SSD disks there will still be a significant amount
of latency
• All of the above inside a loop
ARCHITECTURE
Abstraction and flexibility are enemies of the performance
User interface, sofware interfaces, dependency injection, service layer, multiple
layers . The reason that each major Joomla release gets slower.
WHY?
WHY?
ARCHITECTURE
Execution trees – class that calls class.. and another ..and few another.
For each class file has to be loaded -> Anything that involves I/O operations is slow.
UI - data has to be stored somewhere, usually in DB – database lookups are much
slower than e.g. variables read from a config file on app initialisation.
Tradeoff between performance and flexibility.
ARCHITECTURE – DOS
UI only for user configurable options, file config for developer settings.
ARCHITECTURE – DOS
Design APIs to allow processing multiple items in a single call
ARCHITECTURE – DON‘T
Joomla Custom Fields and Tags
ARCHITECTURE – DOS
Parallel processing – yes, even in PHP.
 Pthreads http://pthreads.org
http://docs.php.net/manual/en/book.pthreads.php
 Using CURL to make parallel requests to php scripts :
https://github.com/marcushat/rollingcurlx
 And since SOAP https://github.com/Meabed/asynchronous-soap
ARCHITECTURE – DOS
ARCHITECTURE – DOS
Delegate some work to the client.
 Clientside rendering: supply data, render in a browser
CODE OPTIMIZATION
TOOLS
• Joomla debug output. Please use it.
• Xdebug profile + KCacheGrind (QCacheGrind for Windows)
• Z-ray http://www.zend.com/en/products/server/z-ray (there is plugin for Joomla)
• Blackfire https://blackfire.io
• PHPStorm
TOOLS
TOOLS
DATABASE AND QUERY
OPTIMIZATION
Query construction
• Reduce the amount of data selected in a query to only be what is required (i.e.
Type the "select" fields manually instead of using "select *")
• Don’t f.. store JSON in a relational database.
• Split complex queries into multilple calls
DATABASE AND QUERY
OPTIMIZATION
Indexes – the same as in a book. Index data is ordered according to order of columns
in create table - mysql knows where to look for data e.g. in a range from 5-10 or all
record starting with k.
• Indexes can make dramatic improvements
• B-tree indexes on columns found in WHERE, JOIN columns
• Leftmost column – MySQL can only search in it
DATABASE AND QUERY
OPTIMIZATION
Indexes – the same as in a book. Index data is ordered according to order of columns
in create table - mysql knows where to look for data e.g. in a range from 5-10 or all
record starting with k.
• Indexes can make dramatic improvements
• B-tree indexes on columns found in WHERE, JOIN columns
• Leftmost column – MySQL can only search in it
DATABASE AND QUERY
OPTIMIZATION
• Covering index – contains all data, not only conditional one
• Full text index – similar to search engines search, for MATCH operations
• Indexes are not used when optimizer determines result set will be too big
compared to all possible rows. Rule of thumb: 15-20%.
• In InnoDB you don‘t need to include pk in indexes, it is already included
• You might need to create indexes with same columns in different order
DATABASE AND QUERY
OPTIMIZATION
• Covering index – contains all data, not only conditional one
• Full text index – similar to search engines search, for MATCH operations
• Indexes are not used when optimizer determines result set will be too big
compared to all possible rows. Rule of thumb: 15-20%.
• In InnoDB you don‘t need to include pk in indexes, it is already included
• You might need to create indexes with same columns in different order
CACHING AND PRELOADING
Store already retrieved data for faster reuse. Can be combined with preloading
• It all boils down to selecting the right caching unit and cache invalidation.
Can be tricky – start simple and iterate - improve until you get the perfect result.
• Break execution cycle in smaller pieces
unless you are rendering a very simple page that generally doesn’t need cashing
at all, cache smaller pieces
• Best caching candidates
often reused data/processes and very expensive operations. Cache remote
resources whenever possible, there is no such thing as fast webservice.
• Choose memory based storage (Memcached, APCu etc).
CACHING AND PRELOADING
Caching types
• Variable caching
short lived cache that only lives during single execution cycle. Often used data is
stored in a (static) property
• J Method results caching
J implementation works fine for procedural methods or static methods, avaoid
with methods that depend on object property values. For those use J raw cache
(serialization?)
CACHING AND PRELOADING
• J Data caching
use J raw cache to store compiled datasets: queries, webservices
• J “auto” caching (view cache, cache plugin modules caching)
usable when application output only depends on URL parameters (non-
authenticated, no data from cookies or session).
• Http caching
server side, Varnish and similar, same rule as previous point.
CACHING AND PRELOADING
CACHING AND PRELOADING
Preloading
Preload frequently needed data into memory e.g. on application initialization
BUT PLEASE
CACHING AND PRELOADING
Don‘t blindly preload all items.
For 1000 concurent users == 80 GB of RAM.
CACHING AND PRELOADING
Not a realistic scenario?
CACHING AND PRELOADING
You should really use the internet some more..
CACHING AND PRELOADING
You should really use the internet some more..
Membership sites. Yes, in Joomla (not this one).
OTHER
• Use PHP 7: 40% faster
• Activate PHP opcode caching – reads files and compiles them to machine code,
without it script needs to be compiled each time. Built-in OpCache in php7 (Also
Wincache, Zend optimizer) or APC/Xcache for previous versions
• HHVM: J3.7. is compatible
• Server infrastructure: Database replication, load balancing, clouds etc.
THANK YOU 

Weitere ähnliche Inhalte

Was ist angesagt?

Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
drupalcampest
 
Escalando php e drupal- performance ao infinito e além! - Drupal camp sp 2015
Escalando php e drupal- performance ao infinito e além! - Drupal camp sp 2015Escalando php e drupal- performance ao infinito e além! - Drupal camp sp 2015
Escalando php e drupal- performance ao infinito e além! - Drupal camp sp 2015
Handrus Nogueira
 
High performance website
High performance websiteHigh performance website
High performance website
Chamnap Chhorn
 

Was ist angesagt? (18)

Orm and hibernate
Orm and hibernateOrm and hibernate
Orm and hibernate
 
hbaseconasia2017: HBase on Beam
hbaseconasia2017: HBase on Beamhbaseconasia2017: HBase on Beam
hbaseconasia2017: HBase on Beam
 
Drupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance SitesDrupalcamp Estonia - High Performance Sites
Drupalcamp Estonia - High Performance Sites
 
Data cache management in php
Data cache management in phpData cache management in php
Data cache management in php
 
Escalando php e drupal- performance ao infinito e além! - Drupal camp sp 2015
Escalando php e drupal- performance ao infinito e além! - Drupal camp sp 2015Escalando php e drupal- performance ao infinito e além! - Drupal camp sp 2015
Escalando php e drupal- performance ao infinito e além! - Drupal camp sp 2015
 
DrupalCamp SP 2015 - Escalando PHP e Drupal- Performance ao infinito e além!
DrupalCamp SP 2015 -  Escalando PHP e Drupal- Performance ao infinito e além!DrupalCamp SP 2015 -  Escalando PHP e Drupal- Performance ao infinito e além!
DrupalCamp SP 2015 - Escalando PHP e Drupal- Performance ao infinito e além!
 
Database2011 MySQL Sharding
Database2011 MySQL ShardingDatabase2011 MySQL Sharding
Database2011 MySQL Sharding
 
IWMW 1998: Publishing and devolving the maintenance of a prospectus prospectus
IWMW 1998: Publishing and devolving the maintenance of a prospectus prospectusIWMW 1998: Publishing and devolving the maintenance of a prospectus prospectus
IWMW 1998: Publishing and devolving the maintenance of a prospectus prospectus
 
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
 
Building Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff StanoBuilding Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff Stano
 
Microsoft Web Technology Stack
Microsoft Web Technology StackMicrosoft Web Technology Stack
Microsoft Web Technology Stack
 
Introduction to CosmosDB - Azure Bootcamp 2018
Introduction to CosmosDB - Azure Bootcamp 2018Introduction to CosmosDB - Azure Bootcamp 2018
Introduction to CosmosDB - Azure Bootcamp 2018
 
High performance website
High performance websiteHigh performance website
High performance website
 
ORM Methodology
ORM MethodologyORM Methodology
ORM Methodology
 
Asp.Net 3 5 Part 1
Asp.Net 3 5 Part 1Asp.Net 3 5 Part 1
Asp.Net 3 5 Part 1
 
Web Application Performance Audit and Optimization
Web Application Performance Audit and OptimizationWeb Application Performance Audit and Optimization
Web Application Performance Audit and Optimization
 
Heterogenous Persistence
Heterogenous PersistenceHeterogenous Persistence
Heterogenous Persistence
 
Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015
Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015
Escalando PHP e Drupal: performance ao infinito e além! - DrupalCamp SP 2015
 

Ähnlich wie Basic Application Performance Optimization Techniques (Backend)

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
DataWorks Summit
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
Taylor Lovett
 
Using Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your ClusterUsing Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your Cluster
MongoDB
 
Using Compass to Diagnose Performance Problems
Using Compass to Diagnose Performance Problems Using Compass to Diagnose Performance Problems
Using Compass to Diagnose Performance Problems
MongoDB
 

Ähnlich wie Basic Application Performance Optimization Techniques (Backend) (20)

From a student to an apache committer practice of apache io tdb
From a student to an apache committer  practice of apache io tdbFrom a student to an apache committer  practice of apache io tdb
From a student to an apache committer practice of apache io tdb
 
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
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
 
Best practices-wordpress-enterprise
Best practices-wordpress-enterpriseBest practices-wordpress-enterprise
Best practices-wordpress-enterprise
 
071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephen071410 sun a_1515_feldman_stephen
071410 sun a_1515_feldman_stephen
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
 
Write Generic Code with the Tooling API
Write Generic Code with the Tooling APIWrite Generic Code with the Tooling API
Write Generic Code with the Tooling API
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDB
 
Dataweek-Talk-2014
Dataweek-Talk-2014Dataweek-Talk-2014
Dataweek-Talk-2014
 
Old code doesn't stink
Old code doesn't stinkOld code doesn't stink
Old code doesn't stink
 
Meta scale kognitio hadoop webinar
Meta scale kognitio hadoop webinarMeta scale kognitio hadoop webinar
Meta scale kognitio hadoop webinar
 
Webinar: High Performance MongoDB Applications with IBM POWER8
Webinar: High Performance MongoDB Applications with IBM POWER8Webinar: High Performance MongoDB Applications with IBM POWER8
Webinar: High Performance MongoDB Applications with IBM POWER8
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - Detroit
 
AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09AWS (Hadoop) Meetup 30.04.09
AWS (Hadoop) Meetup 30.04.09
 
Challenges of Building a First Class SQL-on-Hadoop Engine
Challenges of Building a First Class SQL-on-Hadoop EngineChallenges of Building a First Class SQL-on-Hadoop Engine
Challenges of Building a First Class SQL-on-Hadoop Engine
 
Hpc lunch and learn
Hpc lunch and learnHpc lunch and learn
Hpc lunch and learn
 
Low Latency Polyglot Model Scoring using Apache Apex
Low Latency Polyglot Model Scoring using Apache ApexLow Latency Polyglot Model Scoring using Apache Apex
Low Latency Polyglot Model Scoring using Apache Apex
 
SharePoint 2013 Performance Analysis - Robi Vončina
SharePoint 2013 Performance Analysis - Robi VončinaSharePoint 2013 Performance Analysis - Robi Vončina
SharePoint 2013 Performance Analysis - Robi Vončina
 
Using Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your ClusterUsing Compass to Diagnose Performance Problems in Your Cluster
Using Compass to Diagnose Performance Problems in Your Cluster
 
Using Compass to Diagnose Performance Problems
Using Compass to Diagnose Performance Problems Using Compass to Diagnose Performance Problems
Using Compass to Diagnose Performance Problems
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
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
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Basic Application Performance Optimization Techniques (Backend)

  • 1. BASIC APPLICATION OPTIMIZATION TECHNIQUES (BACKEND) JAB 17 Klas Berlič Fras
  • 2. ABOUT ME A founder of a boutique web and marketing communications agency Drzno, providing integrated communication solutions with focus on the digital communication and website development. Marketing communication strategies. Design. Digital communication.
  • 3. ABOUT ME I try to do different stuff differently 
  • 4. ABOUT ME • Organized 48 hours music festival featuring Guano Apes (German band performing on MTV awards at the time) • Published a poetry book • Ran 3 consecutive political marketing campaigns. We won in all 3.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 13. COMMON BOTTLENECKS • Poorly designed database (Joomla permissions in JSON) and slow queries • Expensive CPU operations: image resizing, calculations • Expensive network operations: webservices, network disks • Filesystem operations: even with SSD disks there will still be a significant amount of latency • All of the above inside a loop
  • 14. ARCHITECTURE Abstraction and flexibility are enemies of the performance User interface, sofware interfaces, dependency injection, service layer, multiple layers . The reason that each major Joomla release gets slower.
  • 15. WHY?
  • 16. WHY?
  • 17. ARCHITECTURE Execution trees – class that calls class.. and another ..and few another. For each class file has to be loaded -> Anything that involves I/O operations is slow. UI - data has to be stored somewhere, usually in DB – database lookups are much slower than e.g. variables read from a config file on app initialisation. Tradeoff between performance and flexibility.
  • 18. ARCHITECTURE – DOS UI only for user configurable options, file config for developer settings.
  • 19. ARCHITECTURE – DOS Design APIs to allow processing multiple items in a single call
  • 20. ARCHITECTURE – DON‘T Joomla Custom Fields and Tags
  • 21. ARCHITECTURE – DOS Parallel processing – yes, even in PHP.  Pthreads http://pthreads.org http://docs.php.net/manual/en/book.pthreads.php  Using CURL to make parallel requests to php scripts : https://github.com/marcushat/rollingcurlx  And since SOAP https://github.com/Meabed/asynchronous-soap
  • 23. ARCHITECTURE – DOS Delegate some work to the client.  Clientside rendering: supply data, render in a browser
  • 24.
  • 26. TOOLS • Joomla debug output. Please use it. • Xdebug profile + KCacheGrind (QCacheGrind for Windows) • Z-ray http://www.zend.com/en/products/server/z-ray (there is plugin for Joomla) • Blackfire https://blackfire.io • PHPStorm
  • 27. TOOLS
  • 28. TOOLS
  • 29. DATABASE AND QUERY OPTIMIZATION Query construction • Reduce the amount of data selected in a query to only be what is required (i.e. Type the "select" fields manually instead of using "select *") • Don’t f.. store JSON in a relational database. • Split complex queries into multilple calls
  • 30. DATABASE AND QUERY OPTIMIZATION Indexes – the same as in a book. Index data is ordered according to order of columns in create table - mysql knows where to look for data e.g. in a range from 5-10 or all record starting with k. • Indexes can make dramatic improvements • B-tree indexes on columns found in WHERE, JOIN columns • Leftmost column – MySQL can only search in it
  • 31. DATABASE AND QUERY OPTIMIZATION Indexes – the same as in a book. Index data is ordered according to order of columns in create table - mysql knows where to look for data e.g. in a range from 5-10 or all record starting with k. • Indexes can make dramatic improvements • B-tree indexes on columns found in WHERE, JOIN columns • Leftmost column – MySQL can only search in it
  • 32. DATABASE AND QUERY OPTIMIZATION • Covering index – contains all data, not only conditional one • Full text index – similar to search engines search, for MATCH operations • Indexes are not used when optimizer determines result set will be too big compared to all possible rows. Rule of thumb: 15-20%. • In InnoDB you don‘t need to include pk in indexes, it is already included • You might need to create indexes with same columns in different order
  • 33. DATABASE AND QUERY OPTIMIZATION • Covering index – contains all data, not only conditional one • Full text index – similar to search engines search, for MATCH operations • Indexes are not used when optimizer determines result set will be too big compared to all possible rows. Rule of thumb: 15-20%. • In InnoDB you don‘t need to include pk in indexes, it is already included • You might need to create indexes with same columns in different order
  • 34. CACHING AND PRELOADING Store already retrieved data for faster reuse. Can be combined with preloading • It all boils down to selecting the right caching unit and cache invalidation. Can be tricky – start simple and iterate - improve until you get the perfect result. • Break execution cycle in smaller pieces unless you are rendering a very simple page that generally doesn’t need cashing at all, cache smaller pieces • Best caching candidates often reused data/processes and very expensive operations. Cache remote resources whenever possible, there is no such thing as fast webservice. • Choose memory based storage (Memcached, APCu etc).
  • 35. CACHING AND PRELOADING Caching types • Variable caching short lived cache that only lives during single execution cycle. Often used data is stored in a (static) property • J Method results caching J implementation works fine for procedural methods or static methods, avaoid with methods that depend on object property values. For those use J raw cache (serialization?)
  • 36. CACHING AND PRELOADING • J Data caching use J raw cache to store compiled datasets: queries, webservices • J “auto” caching (view cache, cache plugin modules caching) usable when application output only depends on URL parameters (non- authenticated, no data from cookies or session). • Http caching server side, Varnish and similar, same rule as previous point.
  • 38. CACHING AND PRELOADING Preloading Preload frequently needed data into memory e.g. on application initialization
  • 40. CACHING AND PRELOADING Don‘t blindly preload all items. For 1000 concurent users == 80 GB of RAM.
  • 41. CACHING AND PRELOADING Not a realistic scenario?
  • 42. CACHING AND PRELOADING You should really use the internet some more..
  • 43. CACHING AND PRELOADING You should really use the internet some more.. Membership sites. Yes, in Joomla (not this one).
  • 44. OTHER • Use PHP 7: 40% faster • Activate PHP opcode caching – reads files and compiles them to machine code, without it script needs to be compiled each time. Built-in OpCache in php7 (Also Wincache, Zend optimizer) or APC/Xcache for previous versions • HHVM: J3.7. is compatible • Server infrastructure: Database replication, load balancing, clouds etc.

Hinweis der Redaktion

  1. Poenostavljeno rečeno..
  2. Poenostavljeno rečeno..
  3. Poenostavljeno rečeno..
  4. Poenostavljeno rečeno..
  5. Poenostavljeno rečeno..
  6. Poenostavljeno rečeno..
  7. Poenostavljeno rečeno..
  8. Poenostavljeno rečeno..
  9. Poenostavljeno rečeno..
  10. Poenostavljeno rečeno..
  11. Poenostavljeno rečeno..
  12. Poenostavljeno rečeno..
  13. Poenostavljeno rečeno..
  14. Poenostavljeno rečeno..
  15. Poenostavljeno rečeno..
  16. Poenostavljeno rečeno..
  17. Poenostavljeno rečeno..
  18. Poenostavljeno rečeno..
  19. Poenostavljeno rečeno..
  20. Poenostavljeno rečeno..
  21. Poenostavljeno rečeno..
  22. Poenostavljeno rečeno..
  23. Poenostavljeno rečeno..
  24. Poenostavljeno rečeno..
  25. Poenostavljeno rečeno..
  26. Poenostavljeno rečeno..
  27. Poenostavljeno rečeno..
  28. Poenostavljeno rečeno..
  29. Poenostavljeno rečeno..
  30. Poenostavljeno rečeno..
  31. Poenostavljeno rečeno..