Pour le moment, cette page n'est disponible qu'en anglais.
In this article

Introduction

PHP-based applications and services are extremely popular on the modern web, accounting for over 77% of all websites on the internet. Keeping track of performance is essential to providing the best customer experience. This topic aims to highlight several ways you can monitor and improve overall PHP performance and what metrics to track.

Why PHP monitoring is essential


PHP performance monitoring is essential for several reasons. First, PHP is a server-side scripting language that is used to create dynamic web pages. This means that code is executed on the server before the page is sent to the client. As a result, this code can have a significant impact on server resources and performance. 

Second, PHP is constantly evolving and new versions are released regularly. This can sometimes lead to unexpected performance issues and even failures (as existing functions are deprecated), so it is important to not only set up initial monitoring but to maintain and update that monitoring the same way a critical library would be. 

Finally, there’s the reality that if your application built with PHP does not function well, this will negatively affect your user experience and potentially your business’ bottom line.

What to monitor in PHP


Performance metrics are key to understanding how your PHP application is performing. By monitoring the right metrics, you can identify and fix bottlenecks, optimize resource usage, and improve overall performance. 

Here are some of the most important PHP performance metrics to keep an eye on:

  • Response time: This measures the amount of time it takes for your server to process a request and return a response. A high response time indicates that your server is overloaded or that there are bottlenecks in your application.
  • Memory usage: Memory usage measures how much memory your application is using. If your application is using too much memory, it will degrade performance and may eventually crash.
  • CPU usage: CPU usage measures how much of your server's CPU capacity is being used by your PHP application. A high CPU usage indicates that your application is processor-intensive and may benefit from optimization.
  • Database queries: Database queries measure how many database queries are being executed by your application. A high number of database queries can slow down your application and lead to poor performance.
  • Cache hits: Cache hits measure how often your application is able to serve requests from the cache instead of fetching data from the database. A high cache hit to database calls ratio indicates that your application is using caching well and is unlikely to be throttled by database access.
  • Logs: PHP log monitoring is an essential tool for PHP development and debugging because they provide a lot of valuable insights into code execution, database queries, and web server activity. They can also be used to track PHP errors, slowdowns, and potential security issues. Or, use them to debug PHP code and troubleshoot website issues. Logs can also be used to generate reports on overall performance and configured to send alerts upon encountering issues.

By monitoring these performance metrics, you can get a better understanding of how your PHP application is performing and identify areas for improvement.

PHP monitoring in an instant

Sign up for a free New Relic account to get started with our instant observability quickstart. Then take a deeper dive into the New Relic for PHP documentation.

New Relic Now Essayez la démo des intégrations agentiques le 24 juin.
Réservez votre place.