SlideShare une entreprise Scribd logo
1  sur  43
Turbocharging PHP
Applications With Zend
Server.

Eric Ritchie (eric@zend.com)




                               © All rights reserved. Zend Technologies, Inc.
Eric Ritchie bids you welcome!
• Senior Technical Consultant and Trainer
  at Zend Technologies

• Zend Framework and PHP 5.3 ZCE

• Eighteen years of system administration experience

• Twelve years of PHP (3,4 & 5) and five years Zend
  Framework development experience

• Hobbies: Sampling good wines/whiskies
 (gifts welcome)




                     © All rights reserved. Zend Technologies, Inc.
Agenda

• Defining the problem
• The sharpest tool in the shed… Code Tracing
• Laziness is good (at least for web servers):
  Using caching to avoid work
• If we must work, then procrastinate: Use the Job Queue
• Taking the heat off the disk: Ways to reduce disk I/O




                       © All rights reserved. Zend Technologies, Inc.
What we will not cover (probably)

• Database optimization > caching
• Web service optimization
• Varnish and reverse proxying in general
• CDNs (Content Delivery Networks)
• Caching technology comparisons
• Operating system level optimizations
• JavaScript performance in general
• Network Traffic Analysis



                      © All rights reserved. Zend Technologies, Inc.
Defining the problem
Why is it that we always discover that we have performance
problems AFTER we go live?




                      © All rights reserved. Zend Technologies, Inc.
The evolution of an organic website
• A new website is born...




                                  Internet



LAMP Server




                      © All rights reserved. Zend Technologies, Inc.
...too much of a good thing?
• the smoke begins...




                                    Internet



LAMP Server




                        © All rights reserved. Zend Technologies, Inc.
First job: Bottleneck identification

• Many possible tools:
   Zend Server Event Monitoring

   Profiling

   microtime()

   Slow query logs

• One Swiss army knife:
   Zend Server Code Tracing




                         © All rights reserved. Zend Technologies, Inc.
Zend Code Tracing
A black box for your PHP code




                      © All rights reserved. Zend Technologies, Inc.
Zend Code Tracing: Main view




               © All rights reserved. Zend Technologies, Inc.
Zend Code Tracing: Statistics view




                © All rights reserved. Zend Technologies, Inc.
Zend Code Tracing: How to store a trace?

• Best way (in most cases)
  … Use a web browser




  Very quick and easy, but obviously not so good for POST requests

  Also, we may not be allowed!




                         © All rights reserved. Zend Technologies, Inc.
Zend Code Tracing: How to store a trace?
• The official way
   … Use event monitoring




   Works for all requests where an event is generated
   Great for catching random problems
   Custom events allow for „programmatic“ generation of traces


                          © All rights reserved. Zend Technologies, Inc.
Caching
Reducing the work load of our application architecture




                       © All rights reserved. Zend Technologies, Inc.
Zend Page Cache

• Dynamic content is expensive, so don’t regenerate
  Low impact, since no code changes may be required

  Complete request cached, so a hit is like a static request

  Multiple copies of pages can be maintained

  Controlled by flexable and comprehensive rules

• Sadly, nothing comes for free
  Page design can render page caching useless

  Highly dynamic content cannot be reasonably cached

  Problems with stale content



                        © All rights reserved. Zend Technologies, Inc.
Zend Page Caching: Custom content




               © All rights reserved. Zend Technologies, Inc.
Zend Page Cache: Configuration




               © All rights reserved. Zend Technologies, Inc.
Data caching

• Protects the data layer:
   Helps prevent repetitive DB/web service calls

   Far easier than scaling the database

• But...
   Requires code changes

   Custom data is also problematic

   Risk of delivering stale content

   De-caching can bring down the data source




                         © All rights reserved. Zend Technologies, Inc.
One common architecture
• Network data cache
  e.g. Memcache



 Internet                                                               DB Server(s)


                LB


                                                                         Cache
                                                                         Server
                                                    Web Farm


                       © All rights reserved. Zend Technologies, Inc.
Network data cache

• Some advantages
  Only one cache to update/invalidate

  Most effective way of protecting the data source

• Many disadvantages...
  Single point of failure (or uncertainty when in distributed mode)

  Limits scalability

  Performance bottleneck

  Slower




                        © All rights reserved. Zend Technologies, Inc.
A different approach
• Shared memory cache                                    Cache
  e.g. Zend Data Cache


                                                       Cache

 Internet                                                             DB Server(s)




                                                                      X
                LB                                     Cache



                                                                       Cache
                                                                       Server
                                                    Web Farm



                     © All rights reserved. Zend Technologies, Inc.
Zend Data Cache: A shared memory cache

• Many advantages
  Completely scalable (copy/paste architecture)

  No single point of failure

  Does not require TCP/IP

  Very fast

• Some disadvantages...
  Not the path of least resistance

  More work for the data source or the developer

  Your colleagues may laugh at you (but they would be wrong)



                         © All rights reserved. Zend Technologies, Inc.
Zend Data Cache: Usage

• Inserting into the cache
   $res = zend_shm_cache_store($key, $value, $ttl)

   $res = zend_disk_cache_store($key, $value, $ttl)

• Reading from the cache
   $value = zend_shm_cache_fetch($key)

   $value = zend_disk_cache_fetch($key)

• In all cases the key can contain a namespace to allow
  grouping of data, e.g. namespace::key




                        © All rights reserved. Zend Technologies, Inc.
Zend Data Cache: Usage

• Deleting from the cache
  $res = zend_shm_cache_delete($key)

  $res = zend_disk_cache_delete($key)

• Wiping the cache
  $res = zend_shm_cache_clear()

  $res = zend_disk_cache_clear()




                       © All rights reserved. Zend Technologies, Inc.
Shared memory caching

• Taming the disadvantages
  True, we need to work a little, but...
    • We can use Zend Server‘s Job Queue to perform remote
      cache maintenance
    • We can get a list of active servers from the Web API
      provided by Zend Server
    • Really, we don‘t have to code much ourselves




                          © All rights reserved. Zend Technologies, Inc.
Remote de-caching
• With Zend Server‘s Job Queue




• ...and the job itself




                          © All rights reserved. Zend Technologies, Inc.
Shared memory cache on steroids

• Don‘t decache, update
  Regenerate the data and insert into the cache

  At a minimum do this for all components of the index page

  Reduces data source load




                       © All rights reserved. Zend Technologies, Inc.
Zend Job Queue
Why do now what you can do a little later?
Or, genius is being calm on the surface while being calculating in
the background. Your application should do just that.
Or, your server‘s marketing department.




                       © All rights reserved. Zend Technologies, Inc.
Zend Job Queue

• Doesn’t make PHP faster, but makes it look that way
  Break slow tasks out of the user workflow

  Offload the heavy lifting to a background server.

  Delay expensive tasks to off peak hours

  Helps to prevent repetitve work reducing overall load

• Possible to create jobs which depend on other jobs, run
  regularly and have set priorites
• Hooks into Zend Server‘s Event Monitoring component
  Jobs can feedback status information

  Problems appear in the central Zend Server event list


                        © All rights reserved. Zend Technologies, Inc.
Zend Job Queue: Typical example




               © All rights reserved. Zend Technologies, Inc.
Zend Job Queue: Basic use

• Would be hard to make it easier…




• We can also pass information to our job...




                      © All rights reserved. Zend Technologies, Inc.
Zend Job Queue: Basic use

• Possible to name our jobs and set an earliest start time…




• Once sheduled, it is possible to check up on jobs



                      © All rights reserved. Zend Technologies, Inc.
Zend Job Queue: Querying jobs

• Finding out the status of our job using the job id




   Find out if the job is still queued, running, completed or failed

   When finished we get a copy of the script‘s output




                          © All rights reserved. Zend Technologies, Inc.
Zend Job Queue: Querying jobs

• Searching for jobs




   Search for an existing queued job of the same type

   Useful for avoiding repetitive work

   Returns the number of matching jobs along with job details




                         © All rights reserved. Zend Technologies, Inc.
Optimization vs. Complexity




           © All rights reserved. Zend Technologies, Inc.
Optimization vs. Complexity

• With every optimization complexity increaces
   Who else dropped into the caching pitfall?

• First: implement functionality
• System performing well?
• If not, check why
• Get rid of bottlenecks




                         © All rights reserved. Zend Technologies, Inc.
Reducing Disk I/O
The only component of a web server slower than the disk
subsystem is the guy you ask to set it up.




                      © All rights reserved. Zend Technologies, Inc.
Reducing disk I/O

• Use an opcode cache e.g. Zend Optimizer+
  Avoids the need to open PHP files and compile the contents for
   every request.
  Compiled „opcodes“ are instead held in shared memory for later
   reuse.
  Particularly important for framework based projects where tens
   of files may be needed to answer one request.
  Also saves some compiler time, but disk I/O savings are usually far
   more significant.
  Most obvious benefit for scripts with short run times or running on
   loaded servers.


                        © All rights reserved. Zend Technologies, Inc.
Reducing disk I/O

• Store static files elsewhere
• Do not cache to the file system
• Must have local storage? ...Use a ramdisk
• Reduce PHP/Apache logging to minimal levels
   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR

• Don‘t forget the Zend Server logs!
   Search for log_verbosity_level in the configuration




                         © All rights reserved. Zend Technologies, Inc.
File system concerns

• EXT3 – The default problem
   For a web server ReiserFS can be 20x (or more) faster, really!

   Even XFS is 2.5x faster

   If you must use EXT3/4 then throw memory at the server

• My NFS/Samba server is fast... Honest!
   Even „fast“ NFS servers have terrible performance under load

   Older implementations cannot use buffer cache

   Poor scalability

• Distributed file systems
   Extremely poor scalability

                         © All rights reserved. Zend Technologies, Inc.
PHP uses your network

• PHP communicates with network services like
   Databases (ex: MySQL, Oracle)

   Caching systems (ex: Memcache, Redis ..)

   Job Queue Systems (ex: Zend Job Queue, RabbitMQ )

   Session Clustering Daemon (ex: Zend Session Clustering)

• If one of these services overloads the network then all
  other suffer from slowdown
   Network congestion

   Insufficient bandwidth

   High latency


                         © All rights reserved. Zend Technologies, Inc.
So long...

• …and thanks for all the fish.




                       © All rights reserved. Zend Technologies, Inc.
Turbocharging PHP
Applications With Zend
Server.

Eric Ritchie (eric@zend.com)




                               © All rights reserved. Zend Technologies, Inc.

Contenu connexe

Tendances

MySQL Enterprise Backup: Better Very Large Database Backup & Recovery and More!!
MySQL Enterprise Backup: Better Very Large Database Backup & Recovery and More!!MySQL Enterprise Backup: Better Very Large Database Backup & Recovery and More!!
MySQL Enterprise Backup: Better Very Large Database Backup & Recovery and More!!Tinku Ajit
 
J2EE Performance And Scalability Bp
J2EE Performance And Scalability BpJ2EE Performance And Scalability Bp
J2EE Performance And Scalability BpChris Adkin
 
Zend Server: A Guided Tour
Zend Server: A Guided TourZend Server: A Guided Tour
Zend Server: A Guided TourShahar Evron
 
Tiery Eyed
Tiery EyedTiery Eyed
Tiery EyedZendCon
 
Hadoop Operations at LinkedIn
Hadoop Operations at LinkedInHadoop Operations at LinkedIn
Hadoop Operations at LinkedInDataWorks Summit
 
Hadoop Operations for Production Systems (Strata NYC)
Hadoop Operations for Production Systems (Strata NYC)Hadoop Operations for Production Systems (Strata NYC)
Hadoop Operations for Production Systems (Strata NYC)Kathleen Ting
 
Apache hbase for the enterprise (Strata+Hadoop World 2012)
Apache hbase for the enterprise (Strata+Hadoop World 2012)Apache hbase for the enterprise (Strata+Hadoop World 2012)
Apache hbase for the enterprise (Strata+Hadoop World 2012)jmhsieh
 
Streamline Collections by Using Document Imaging Scenarios for Accounts Recei...
Streamline Collections by Using Document Imaging Scenarios for Accounts Recei...Streamline Collections by Using Document Imaging Scenarios for Accounts Recei...
Streamline Collections by Using Document Imaging Scenarios for Accounts Recei...Verbella CMG
 
Implementing Parallelism in PostgreSQL - PGCon 2014
Implementing Parallelism in PostgreSQL - PGCon 2014Implementing Parallelism in PostgreSQL - PGCon 2014
Implementing Parallelism in PostgreSQL - PGCon 2014EDB
 
Strata + Hadoop World 2012: Apache HBase Features for the Enterprise
Strata + Hadoop World 2012: Apache HBase Features for the EnterpriseStrata + Hadoop World 2012: Apache HBase Features for the Enterprise
Strata + Hadoop World 2012: Apache HBase Features for the EnterpriseCloudera, Inc.
 
Mtc learnings from isv & enterprise interaction
Mtc learnings from isv & enterprise  interactionMtc learnings from isv & enterprise  interaction
Mtc learnings from isv & enterprise interactionGovind Kanshi
 
Mtc learnings from isv & enterprise (dated - Dec -2014)
Mtc learnings from isv & enterprise (dated - Dec -2014)Mtc learnings from isv & enterprise (dated - Dec -2014)
Mtc learnings from isv & enterprise (dated - Dec -2014)Govind Kanshi
 
Acquia Managed Cloud: Highly Available Architecture for Highly Unpredictable ...
Acquia Managed Cloud: Highly Available Architecture for Highly Unpredictable ...Acquia Managed Cloud: Highly Available Architecture for Highly Unpredictable ...
Acquia Managed Cloud: Highly Available Architecture for Highly Unpredictable ...Acquia
 
HDFS Futures: NameNode Federation for Improved Efficiency and Scalability
HDFS Futures: NameNode Federation for Improved Efficiency and ScalabilityHDFS Futures: NameNode Federation for Improved Efficiency and Scalability
HDFS Futures: NameNode Federation for Improved Efficiency and ScalabilityHortonworks
 
High Scalability Toronto: Meetup #2
High Scalability Toronto: Meetup #2High Scalability Toronto: Meetup #2
High Scalability Toronto: Meetup #2ScribbleLive
 
What Can FPGA Designers Do With Personal Data Centers?
What Can FPGA Designers Do With Personal Data Centers?What Can FPGA Designers Do With Personal Data Centers?
What Can FPGA Designers Do With Personal Data Centers?plunify
 
Thousands of Threads and Blocking I/O
Thousands of Threads and Blocking I/OThousands of Threads and Blocking I/O
Thousands of Threads and Blocking I/OGeorge Cao
 
What's New and Upcoming in HDFS - the Hadoop Distributed File System
What's New and Upcoming in HDFS - the Hadoop Distributed File SystemWhat's New and Upcoming in HDFS - the Hadoop Distributed File System
What's New and Upcoming in HDFS - the Hadoop Distributed File SystemCloudera, Inc.
 

Tendances (20)

MySQL Enterprise Backup: Better Very Large Database Backup & Recovery and More!!
MySQL Enterprise Backup: Better Very Large Database Backup & Recovery and More!!MySQL Enterprise Backup: Better Very Large Database Backup & Recovery and More!!
MySQL Enterprise Backup: Better Very Large Database Backup & Recovery and More!!
 
J2EE Performance And Scalability Bp
J2EE Performance And Scalability BpJ2EE Performance And Scalability Bp
J2EE Performance And Scalability Bp
 
Zend Server: A Guided Tour
Zend Server: A Guided TourZend Server: A Guided Tour
Zend Server: A Guided Tour
 
Tiery Eyed
Tiery EyedTiery Eyed
Tiery Eyed
 
Hadoop Operations at LinkedIn
Hadoop Operations at LinkedInHadoop Operations at LinkedIn
Hadoop Operations at LinkedIn
 
Hadoop Operations for Production Systems (Strata NYC)
Hadoop Operations for Production Systems (Strata NYC)Hadoop Operations for Production Systems (Strata NYC)
Hadoop Operations for Production Systems (Strata NYC)
 
Hadoop on Virtual Machines
Hadoop on Virtual MachinesHadoop on Virtual Machines
Hadoop on Virtual Machines
 
Apache hbase for the enterprise (Strata+Hadoop World 2012)
Apache hbase for the enterprise (Strata+Hadoop World 2012)Apache hbase for the enterprise (Strata+Hadoop World 2012)
Apache hbase for the enterprise (Strata+Hadoop World 2012)
 
Streamline Collections by Using Document Imaging Scenarios for Accounts Recei...
Streamline Collections by Using Document Imaging Scenarios for Accounts Recei...Streamline Collections by Using Document Imaging Scenarios for Accounts Recei...
Streamline Collections by Using Document Imaging Scenarios for Accounts Recei...
 
Implementing Parallelism in PostgreSQL - PGCon 2014
Implementing Parallelism in PostgreSQL - PGCon 2014Implementing Parallelism in PostgreSQL - PGCon 2014
Implementing Parallelism in PostgreSQL - PGCon 2014
 
Strata + Hadoop World 2012: Apache HBase Features for the Enterprise
Strata + Hadoop World 2012: Apache HBase Features for the EnterpriseStrata + Hadoop World 2012: Apache HBase Features for the Enterprise
Strata + Hadoop World 2012: Apache HBase Features for the Enterprise
 
Mtc learnings from isv & enterprise interaction
Mtc learnings from isv & enterprise  interactionMtc learnings from isv & enterprise  interaction
Mtc learnings from isv & enterprise interaction
 
Mtc learnings from isv & enterprise (dated - Dec -2014)
Mtc learnings from isv & enterprise (dated - Dec -2014)Mtc learnings from isv & enterprise (dated - Dec -2014)
Mtc learnings from isv & enterprise (dated - Dec -2014)
 
Acquia Managed Cloud: Highly Available Architecture for Highly Unpredictable ...
Acquia Managed Cloud: Highly Available Architecture for Highly Unpredictable ...Acquia Managed Cloud: Highly Available Architecture for Highly Unpredictable ...
Acquia Managed Cloud: Highly Available Architecture for Highly Unpredictable ...
 
HDFS Futures: NameNode Federation for Improved Efficiency and Scalability
HDFS Futures: NameNode Federation for Improved Efficiency and ScalabilityHDFS Futures: NameNode Federation for Improved Efficiency and Scalability
HDFS Futures: NameNode Federation for Improved Efficiency and Scalability
 
High Scalability Toronto: Meetup #2
High Scalability Toronto: Meetup #2High Scalability Toronto: Meetup #2
High Scalability Toronto: Meetup #2
 
What Can FPGA Designers Do With Personal Data Centers?
What Can FPGA Designers Do With Personal Data Centers?What Can FPGA Designers Do With Personal Data Centers?
What Can FPGA Designers Do With Personal Data Centers?
 
Thousands of Threads and Blocking I/O
Thousands of Threads and Blocking I/OThousands of Threads and Blocking I/O
Thousands of Threads and Blocking I/O
 
What's New and Upcoming in HDFS - the Hadoop Distributed File System
What's New and Upcoming in HDFS - the Hadoop Distributed File SystemWhat's New and Upcoming in HDFS - the Hadoop Distributed File System
What's New and Upcoming in HDFS - the Hadoop Distributed File System
 
Scaling CQ5
Scaling CQ5Scaling CQ5
Scaling CQ5
 

Similaire à Turbocharging PHP Apps with Zend Server Code Tracing and Caching

PHP Apps on the Move - Migrating from In-House to Cloud
PHP Apps on the Move - Migrating from In-House to Cloud  PHP Apps on the Move - Migrating from In-House to Cloud
PHP Apps on the Move - Migrating from In-House to Cloud RightScale
 
Scalable High-Availability Session Storage with ZSCM
Scalable High-Availability Session Storage with ZSCMScalable High-Availability Session Storage with ZSCM
Scalable High-Availability Session Storage with ZSCMZend by Rogue Wave Software
 
How to scale PHP applications
How to scale PHP applicationsHow to scale PHP applications
How to scale PHP applicationsEnrico Zimuel
 
What's new with Zend server
What's new with Zend serverWhat's new with Zend server
What's new with Zend serverCOMMON Europe
 
How to Manage Cloud Infrastructures using Zend Framework
How to Manage Cloud Infrastructures using Zend FrameworkHow to Manage Cloud Infrastructures using Zend Framework
How to Manage Cloud Infrastructures using Zend FrameworkZend by Rogue Wave Software
 
Zend In The Cloud
Zend In The CloudZend In The Cloud
Zend In The Cloudphptechtalk
 
Standard CMS on standard PHP Stack - Drupal and Zend Server
Standard CMS on standard PHP Stack - Drupal and Zend ServerStandard CMS on standard PHP Stack - Drupal and Zend Server
Standard CMS on standard PHP Stack - Drupal and Zend ServerZend by Rogue Wave Software
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)Tech in Asia ID
 
The Perils and Triumphs of using Cassandra at a .NET/Microsoft Shop
The Perils and Triumphs of using Cassandra at a .NET/Microsoft ShopThe Perils and Triumphs of using Cassandra at a .NET/Microsoft Shop
The Perils and Triumphs of using Cassandra at a .NET/Microsoft ShopJeff Smoley
 
Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...
Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...
Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...Zend by Rogue Wave Software
 
Accelerating Application Performance with Amazon ElastiCache (DAT207) | AWS r...
Accelerating Application Performance with Amazon ElastiCache (DAT207) | AWS r...Accelerating Application Performance with Amazon ElastiCache (DAT207) | AWS r...
Accelerating Application Performance with Amazon ElastiCache (DAT207) | AWS r...Amazon Web Services
 
Cloudy in Indonesia: Java and Cloud
Cloudy in Indonesia: Java and CloudCloudy in Indonesia: Java and Cloud
Cloudy in Indonesia: Java and CloudEberhard Wolff
 
Running Oracle EBS in the cloud (DOAG TECH17 edition)
Running Oracle EBS in the cloud (DOAG TECH17 edition)Running Oracle EBS in the cloud (DOAG TECH17 edition)
Running Oracle EBS in the cloud (DOAG TECH17 edition)Andrejs Prokopjevs
 
Zend Products and PHP for IBMi
Zend Products and PHP for IBMi  Zend Products and PHP for IBMi
Zend Products and PHP for IBMi Shlomo Vanunu
 
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020Derek Ashmore
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetImproving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetAchieve Internet
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetImproving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetAchieve Internet
 
Optimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend ServerOptimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend Servervarien
 

Similaire à Turbocharging PHP Apps with Zend Server Code Tracing and Caching (20)

PHP Apps on the Move - Migrating from In-House to Cloud
PHP Apps on the Move - Migrating from In-House to Cloud  PHP Apps on the Move - Migrating from In-House to Cloud
PHP Apps on the Move - Migrating from In-House to Cloud
 
Performance tuning PHP on IBMi
Performance tuning PHP on IBMiPerformance tuning PHP on IBMi
Performance tuning PHP on IBMi
 
Scalable High-Availability Session Storage with ZSCM
Scalable High-Availability Session Storage with ZSCMScalable High-Availability Session Storage with ZSCM
Scalable High-Availability Session Storage with ZSCM
 
How to scale PHP applications
How to scale PHP applicationsHow to scale PHP applications
How to scale PHP applications
 
What's new with Zend server
What's new with Zend serverWhat's new with Zend server
What's new with Zend server
 
How to Manage Cloud Infrastructures using Zend Framework
How to Manage Cloud Infrastructures using Zend FrameworkHow to Manage Cloud Infrastructures using Zend Framework
How to Manage Cloud Infrastructures using Zend Framework
 
Zend In The Cloud
Zend In The CloudZend In The Cloud
Zend In The Cloud
 
Application Deployment on IBM i
Application Deployment on IBM iApplication Deployment on IBM i
Application Deployment on IBM i
 
Standard CMS on standard PHP Stack - Drupal and Zend Server
Standard CMS on standard PHP Stack - Drupal and Zend ServerStandard CMS on standard PHP Stack - Drupal and Zend Server
Standard CMS on standard PHP Stack - Drupal and Zend Server
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
 
The Perils and Triumphs of using Cassandra at a .NET/Microsoft Shop
The Perils and Triumphs of using Cassandra at a .NET/Microsoft ShopThe Perils and Triumphs of using Cassandra at a .NET/Microsoft Shop
The Perils and Triumphs of using Cassandra at a .NET/Microsoft Shop
 
Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...
Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...
Costruire un sito e-commerce in alta affidabilità con Magento e Zend Server C...
 
Accelerating Application Performance with Amazon ElastiCache (DAT207) | AWS r...
Accelerating Application Performance with Amazon ElastiCache (DAT207) | AWS r...Accelerating Application Performance with Amazon ElastiCache (DAT207) | AWS r...
Accelerating Application Performance with Amazon ElastiCache (DAT207) | AWS r...
 
Cloudy in Indonesia: Java and Cloud
Cloudy in Indonesia: Java and CloudCloudy in Indonesia: Java and Cloud
Cloudy in Indonesia: Java and Cloud
 
Running Oracle EBS in the cloud (DOAG TECH17 edition)
Running Oracle EBS in the cloud (DOAG TECH17 edition)Running Oracle EBS in the cloud (DOAG TECH17 edition)
Running Oracle EBS in the cloud (DOAG TECH17 edition)
 
Zend Products and PHP for IBMi
Zend Products and PHP for IBMi  Zend Products and PHP for IBMi
Zend Products and PHP for IBMi
 
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetImproving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
 
Improving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve InternetImproving Website Performance with Memecached Webinar | Achieve Internet
Improving Website Performance with Memecached Webinar | Achieve Internet
 
Optimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend ServerOptimizing Magento Performance with Zend Server
Optimizing Magento Performance with Zend Server
 

Dernier

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 

Dernier (20)

"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 

Turbocharging PHP Apps with Zend Server Code Tracing and Caching

  • 1. Turbocharging PHP Applications With Zend Server. Eric Ritchie (eric@zend.com) © All rights reserved. Zend Technologies, Inc.
  • 2. Eric Ritchie bids you welcome! • Senior Technical Consultant and Trainer at Zend Technologies • Zend Framework and PHP 5.3 ZCE • Eighteen years of system administration experience • Twelve years of PHP (3,4 & 5) and five years Zend Framework development experience • Hobbies: Sampling good wines/whiskies (gifts welcome) © All rights reserved. Zend Technologies, Inc.
  • 3. Agenda • Defining the problem • The sharpest tool in the shed… Code Tracing • Laziness is good (at least for web servers): Using caching to avoid work • If we must work, then procrastinate: Use the Job Queue • Taking the heat off the disk: Ways to reduce disk I/O © All rights reserved. Zend Technologies, Inc.
  • 4. What we will not cover (probably) • Database optimization > caching • Web service optimization • Varnish and reverse proxying in general • CDNs (Content Delivery Networks) • Caching technology comparisons • Operating system level optimizations • JavaScript performance in general • Network Traffic Analysis © All rights reserved. Zend Technologies, Inc.
  • 5. Defining the problem Why is it that we always discover that we have performance problems AFTER we go live? © All rights reserved. Zend Technologies, Inc.
  • 6. The evolution of an organic website • A new website is born... Internet LAMP Server © All rights reserved. Zend Technologies, Inc.
  • 7. ...too much of a good thing? • the smoke begins... Internet LAMP Server © All rights reserved. Zend Technologies, Inc.
  • 8. First job: Bottleneck identification • Many possible tools:  Zend Server Event Monitoring  Profiling  microtime()  Slow query logs • One Swiss army knife:  Zend Server Code Tracing © All rights reserved. Zend Technologies, Inc.
  • 9. Zend Code Tracing A black box for your PHP code © All rights reserved. Zend Technologies, Inc.
  • 10. Zend Code Tracing: Main view © All rights reserved. Zend Technologies, Inc.
  • 11. Zend Code Tracing: Statistics view © All rights reserved. Zend Technologies, Inc.
  • 12. Zend Code Tracing: How to store a trace? • Best way (in most cases)  … Use a web browser  Very quick and easy, but obviously not so good for POST requests  Also, we may not be allowed! © All rights reserved. Zend Technologies, Inc.
  • 13. Zend Code Tracing: How to store a trace? • The official way  … Use event monitoring  Works for all requests where an event is generated  Great for catching random problems  Custom events allow for „programmatic“ generation of traces © All rights reserved. Zend Technologies, Inc.
  • 14. Caching Reducing the work load of our application architecture © All rights reserved. Zend Technologies, Inc.
  • 15. Zend Page Cache • Dynamic content is expensive, so don’t regenerate  Low impact, since no code changes may be required  Complete request cached, so a hit is like a static request  Multiple copies of pages can be maintained  Controlled by flexable and comprehensive rules • Sadly, nothing comes for free  Page design can render page caching useless  Highly dynamic content cannot be reasonably cached  Problems with stale content © All rights reserved. Zend Technologies, Inc.
  • 16. Zend Page Caching: Custom content © All rights reserved. Zend Technologies, Inc.
  • 17. Zend Page Cache: Configuration © All rights reserved. Zend Technologies, Inc.
  • 18. Data caching • Protects the data layer:  Helps prevent repetitive DB/web service calls  Far easier than scaling the database • But...  Requires code changes  Custom data is also problematic  Risk of delivering stale content  De-caching can bring down the data source © All rights reserved. Zend Technologies, Inc.
  • 19. One common architecture • Network data cache e.g. Memcache Internet DB Server(s) LB Cache Server Web Farm © All rights reserved. Zend Technologies, Inc.
  • 20. Network data cache • Some advantages  Only one cache to update/invalidate  Most effective way of protecting the data source • Many disadvantages...  Single point of failure (or uncertainty when in distributed mode)  Limits scalability  Performance bottleneck  Slower © All rights reserved. Zend Technologies, Inc.
  • 21. A different approach • Shared memory cache Cache e.g. Zend Data Cache Cache Internet DB Server(s) X LB Cache Cache Server Web Farm © All rights reserved. Zend Technologies, Inc.
  • 22. Zend Data Cache: A shared memory cache • Many advantages  Completely scalable (copy/paste architecture)  No single point of failure  Does not require TCP/IP  Very fast • Some disadvantages...  Not the path of least resistance  More work for the data source or the developer  Your colleagues may laugh at you (but they would be wrong) © All rights reserved. Zend Technologies, Inc.
  • 23. Zend Data Cache: Usage • Inserting into the cache  $res = zend_shm_cache_store($key, $value, $ttl)  $res = zend_disk_cache_store($key, $value, $ttl) • Reading from the cache  $value = zend_shm_cache_fetch($key)  $value = zend_disk_cache_fetch($key) • In all cases the key can contain a namespace to allow grouping of data, e.g. namespace::key © All rights reserved. Zend Technologies, Inc.
  • 24. Zend Data Cache: Usage • Deleting from the cache  $res = zend_shm_cache_delete($key)  $res = zend_disk_cache_delete($key) • Wiping the cache  $res = zend_shm_cache_clear()  $res = zend_disk_cache_clear() © All rights reserved. Zend Technologies, Inc.
  • 25. Shared memory caching • Taming the disadvantages  True, we need to work a little, but... • We can use Zend Server‘s Job Queue to perform remote cache maintenance • We can get a list of active servers from the Web API provided by Zend Server • Really, we don‘t have to code much ourselves © All rights reserved. Zend Technologies, Inc.
  • 26. Remote de-caching • With Zend Server‘s Job Queue • ...and the job itself © All rights reserved. Zend Technologies, Inc.
  • 27. Shared memory cache on steroids • Don‘t decache, update  Regenerate the data and insert into the cache  At a minimum do this for all components of the index page  Reduces data source load © All rights reserved. Zend Technologies, Inc.
  • 28. Zend Job Queue Why do now what you can do a little later? Or, genius is being calm on the surface while being calculating in the background. Your application should do just that. Or, your server‘s marketing department. © All rights reserved. Zend Technologies, Inc.
  • 29. Zend Job Queue • Doesn’t make PHP faster, but makes it look that way  Break slow tasks out of the user workflow  Offload the heavy lifting to a background server.  Delay expensive tasks to off peak hours  Helps to prevent repetitve work reducing overall load • Possible to create jobs which depend on other jobs, run regularly and have set priorites • Hooks into Zend Server‘s Event Monitoring component  Jobs can feedback status information  Problems appear in the central Zend Server event list © All rights reserved. Zend Technologies, Inc.
  • 30. Zend Job Queue: Typical example © All rights reserved. Zend Technologies, Inc.
  • 31. Zend Job Queue: Basic use • Would be hard to make it easier… • We can also pass information to our job... © All rights reserved. Zend Technologies, Inc.
  • 32. Zend Job Queue: Basic use • Possible to name our jobs and set an earliest start time… • Once sheduled, it is possible to check up on jobs © All rights reserved. Zend Technologies, Inc.
  • 33. Zend Job Queue: Querying jobs • Finding out the status of our job using the job id  Find out if the job is still queued, running, completed or failed  When finished we get a copy of the script‘s output © All rights reserved. Zend Technologies, Inc.
  • 34. Zend Job Queue: Querying jobs • Searching for jobs  Search for an existing queued job of the same type  Useful for avoiding repetitive work  Returns the number of matching jobs along with job details © All rights reserved. Zend Technologies, Inc.
  • 35. Optimization vs. Complexity © All rights reserved. Zend Technologies, Inc.
  • 36. Optimization vs. Complexity • With every optimization complexity increaces  Who else dropped into the caching pitfall? • First: implement functionality • System performing well? • If not, check why • Get rid of bottlenecks © All rights reserved. Zend Technologies, Inc.
  • 37. Reducing Disk I/O The only component of a web server slower than the disk subsystem is the guy you ask to set it up. © All rights reserved. Zend Technologies, Inc.
  • 38. Reducing disk I/O • Use an opcode cache e.g. Zend Optimizer+  Avoids the need to open PHP files and compile the contents for every request.  Compiled „opcodes“ are instead held in shared memory for later reuse.  Particularly important for framework based projects where tens of files may be needed to answer one request.  Also saves some compiler time, but disk I/O savings are usually far more significant.  Most obvious benefit for scripts with short run times or running on loaded servers. © All rights reserved. Zend Technologies, Inc.
  • 39. Reducing disk I/O • Store static files elsewhere • Do not cache to the file system • Must have local storage? ...Use a ramdisk • Reduce PHP/Apache logging to minimal levels  E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR • Don‘t forget the Zend Server logs!  Search for log_verbosity_level in the configuration © All rights reserved. Zend Technologies, Inc.
  • 40. File system concerns • EXT3 – The default problem  For a web server ReiserFS can be 20x (or more) faster, really!  Even XFS is 2.5x faster  If you must use EXT3/4 then throw memory at the server • My NFS/Samba server is fast... Honest!  Even „fast“ NFS servers have terrible performance under load  Older implementations cannot use buffer cache  Poor scalability • Distributed file systems  Extremely poor scalability © All rights reserved. Zend Technologies, Inc.
  • 41. PHP uses your network • PHP communicates with network services like  Databases (ex: MySQL, Oracle)  Caching systems (ex: Memcache, Redis ..)  Job Queue Systems (ex: Zend Job Queue, RabbitMQ )  Session Clustering Daemon (ex: Zend Session Clustering) • If one of these services overloads the network then all other suffer from slowdown  Network congestion  Insufficient bandwidth  High latency © All rights reserved. Zend Technologies, Inc.
  • 42. So long... • …and thanks for all the fish. © All rights reserved. Zend Technologies, Inc.
  • 43. Turbocharging PHP Applications With Zend Server. Eric Ritchie (eric@zend.com) © All rights reserved. Zend Technologies, Inc.