Duration
4 days
Overview
PHP is a powerful and versatile web development platform that is widely used throughout the industry. Although it has a lot in common with other web platforms, there are specific aspects that set it apart from the other technologies. This is also true from a risk perspective. PHP applications are generally affected by most of the same risks that affect web applications written in other languages.
Performance, particularly on busy sites, can be critical. There are a number of ways you can improve the performance of your scripts, and we will be covering as many as have space for. We will also be dispelling various myths about optimisation, and hopefully by the end of this course you will be more confident about to re-write fundamentally flawed algorithms, tune implementations of good algorithms, make your MySQL queries fly, and more.
Prerequisites
Students should be familiar with the basic PHP programming language and MySQL.
Objectives
- Script performance optimising
- SQL performance by optimising
- Server optimization
- Script Caching
- CGI vs WebServer (Apache)
Outline
Code Optimization 1
- Write your code sensibly
- Using tools wisely
- Using functions carefully for maximum performance
- The Zend Optimizer for older PHP versions
- Code cache for newer PHP versions
- The manual
- Get your loops right first
- Pre-increment and post
- RAM usage
- Garbage collection,
- Errors
- Updates
- Cache array data
- Compress outputs
- Debugging the code
- Cache your data with memcache
- Appropriate persistent connections
- New features
- Correct Compilation
- Ignoring the myths
Code Optimization 2
- Update PHP
- Use an opcode cache
- Use autoloading
- Optimize your sessions
- Use a distributed data cache
- Do blocking work in the background
- Leverage HTTP caching
- Optimize your favorite framework
- Memory measurement
- Reduced Memory Usage
- GC performance influences
- Watching process
- Process caching
- Loops and Sleep
- Job Queues using worker and client technique
- Database access awareness
- Traffic awareness
Optimising your SQL
- Prioritize your data
- Optimize your tables
- Select as little data as possible
- Use shorter queries where possible
- Use the EXPLAIN statement
- Change your hardware
- Choose your data types carefully
- Size vs. Speed
- Fields NOT NULL
- Load data intelligently
- Splitting off variable-length fields
- Be wary of locks
- Consider switching OS
- Spotting the slow queries
- Perform joins awareness
- Indexing
- Normalisation
- Upgrade MySQL
- Increase your buffers
- Keep tabs on your server
- Lock your tables when appropriate
- Don't rely on automatic type conversion
- The Benchmark
- Know the MySQL's strengths
Server
- The WebServers
PHP Accelerators
- Acceleration
Caching PHP
- Understanding Cache
PHP as a CGI or a module?
- Why?
Size of scripts
- Code sizing
Programme scope, delivery arrangements and suitability are confirmed during enquiry.