BreadcrumbHomeResourcesBlog Web Application Monitoring For PHP Developers September 19, 2024 Web Application Monitoring for PHP DevelopersPHP DevelopmentPerformanceBy Connor PenhaleWeb application monitoring is a critical aspect in ensuring secure and high-performing PHP web apps. However, getting started can sometimes be a complex process. Understanding what web application monitoring is, how to evaluate your options, and how to implement solutions is essential for successful PHP monitoring.In this blog, I present the basics of PHP application monitoring, discuss considerations for building your PHP web application monitoring strategies, and provide step-by-step instructions for how Zend can help businesses establish robust and effective web application monitoring systems — regardless of developer skill level.Table of ContentsWeb Application Monitoring: OverviewWeb Application Monitoring: Performance Monitoring ConsiderationsImprove Performance With Zend PHP Web Application Monitoring ToolsHow to Use ZendPHP With Grafana for Web Application MonitoringPHP Web Application Monitoring Made Easy With Zend Admin as a ServiceFinal ThoughtsTable of Contents1 - Web Application Monitoring: Overview2 - Web Application Monitoring: Performance Monitoring Considerations3 - Improve Performance With Zend PHP Web Application Monitoring Tools4 - How to Use ZendPHP With Grafana for Web Application Monitoring5 - PHP Web Application Monitoring Made Easy With Zend Admin as a Service6 - Final ThoughtsBack to topWeb Application Monitoring: OverviewYou’re probably already a monitoring expert, even before you’ve read this blog! Let’s take a look at a monitoring dashboard many folks have already had a look at: the dashboard of a car. “Monitoring” means metrics, and there are a few of those on a car’s literal, real-world dashboard. Let’s categorize them into a few different types of metrics:Battery output, measured in voltsSpeed, measured in miles per hourEngine Revolutions Per Minute (RPM), shown on an analogue gauge with minimum and maximum vales, including a “red line” which the engine can exceed, but shouldn’t!The odometer, which shows the total number of miles the car has driven, as well as a resettable trip meter and the outside temperatureThe oil temperature and fuel level in the fuel tankOil pressure measured in barMuch like web application monitoring, each of these metrics has rules on their operation. For example, consider the differences between the odometer and the engine RPM. One of the facts we know about an odometer is that it should only go up, increasing “monotonically” as the car moves. The value should never decrease, only increase, which means if you plot it on a graph, where X is the mileage of the car and Y is time, the graph should always move up and to the right. The engine RPM, on the other hand, can have any value over time, including values over the red line. If you plot engine RPM on a graph, where X is the engine RPM and Y is time, the values should look something like a sawtooth pattern, moving up the Y axis from about 500 RPM at idle to at most 7000 RPM at load, with the RPM decreasing to a lower value as the car shifts between gears, ultimately reaching 0 RPM when the engine stops.Web application monitoring can be thought of in a similar way.What Is Web Application Monitoring?Web application monitoring is the business process of identifying important metrics that identify the health of a web application, gathering them with a monitoring tool such as Prometheus, and displaying that data in a tool like Grafana as a dashboard.To return to the car metaphor, in terms of web application monitoring, the odometer is a “counter.” Common use cases for counters in web application monitoring include requests served, batches completed number of errors, and CPU wall time used for a process. For example, while Apache HTTPD is running, one can “count” the number of requests served by Apache, with metadata around those requests, such as how many of the total requests served were “200 OK” versus “404 Not Found,” or how many requests were to “/index.php” versus “/wp-admin”For the engine RPM metric, we’d use a “gauge” in a web application monitoring context. A “gauge” is a single numerical value that can arbitrarily change. Some examples include CPU usage, memory usage, disk space, number of requests happening "at this moment" / concurrently, connected users / open sockets "at this moment " / concurrently.There are other types of metric display as well, such as a histogram and a summary, which represent a sample of an observation that can be categorized in a bucket to reduce storage complexity that also provides a sum of all observed values. For example, if we wanted to look at request duration, we could use a PromQL query such as histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le)) to produce a graph that looks like this:Source - valyala.medium.comBut let’s not get ahead of ourselves! Instead, let's take a moment to talk about why web application monitoring is important for any business, particularly for PHP web applications.Why Does PHP Application Monitoring Matter?At Zend, we’re in the business of ensuring enterprise-grade PHP applications run with performance and security. Customers often open support cases with us, and let me tell you, when an e-commerce site has a performance issue, it is absolutely business critical. Millions of dollars in sales can be lost in a short period of time due to poor PHP web application performance caused by insufficient web application monitoring.You know that discount campaign that marketing sent out for Labor Day weekend or Black Friday? The one that’s going to increase site traffic by 100x over the next three days? If you don’t have eyes on your metrics, you might not know customers abandoned their carts during checkout due to inordinately slow requests until the sale is long over and the opportunities to close the business are long gone.Read More About Why Good PHP Web Application Monitoring Matters >>Web Application Monitoring: BenefitsComprehensive web application monitoring allows you to have real-time data to form fast responses, troubleshoot issues, and more — thus better serving your user base. The engine RPM gauge is a great metric to bring back here. If you have a gauge in your web application monitoring dashboard that shows requests per minute, you now have a great way to measure how your WordPress engine is working. When you break that gauge down into successful and unsuccessful requests, and when you further break that down into requests to key URLs on your site (coupon.php, checkout.php, thank_you_for_ordering.php), now you’ve got a great view of what’s going on during the big sale. If your requests per minute spikes during the initial email blast, and coupon.php’s error count stays flat? You’re off to the races. If you start seeing the 500 Internal Server Error count spike? Better be ready for a pit stop. Back to topWeb Application Monitoring: Performance Monitoring ConsiderationsWeb application performance monitoring is only as good as your plan, tools, and processes. These considerations can help you identify the best strategy to achieve the business goals of your web application.Determine Your PHP Application Performance MetricsThe best way to determine your web application performance metrics before going live is synthetic testing. Perforce has some serious expertise here: if you’ve heard of building a performance testing suite with JMeter, you might have also heard of our BlazeMeter platform! Your developers are already likely running end-to-end tests with similar tools before you go live in production, pushing your lower environments like Dev, QA, and UAT to the limit to make sure that the latest changes aren’t going to impact performance or break the web application. Your QA team is creating metrics to determine if those changes impact performance, and you can use those same metrics in production to monitor the live experience.Evaluate Web Application Performance Monitoring ToolsEnterprises have different ways of identifying metrics, and a variety of tools that they use for this process. In a world of ever-increasing mergers and acquisitions activity, your organization might inherit tools you’re unfamiliar with, or get assigned tools you’ve never heard of! Having a cohesive platform, especially as departments integrate and operations of the web applications is shared among a wider, global team.The important thing to note with web application monitoring, especially as it relates to PHP, is that the work is equally important for both the developers of the application and the operators supporting the application in production. There should be a collaboration in requesting metrics that make troubleshooting the application easier, and a way to find metrics that can act as leading indicators for performance issues.Back to topImprove Performance With Zend PHP Web Application Monitoring ToolsZend solves the hardest problems in PHP, and that includes offering a variety of PHP app monitoring tools, support services, and other solutions for developer teams. Whether you prefer a hands-on approach or are looking to outsource your monitoring to a team of proven professionals, Zend has you covered.To help you evaluate your options, I will now go through two methods for establishing web application monitoring solutions. First, I will walk through how to use ZendPHP with Grafana to establish web app monitoring, a fitting option for experienced developers, and then I will discuss Zend Admin as a Service, an excellent choice for teams needing to focus their attention on other business concerns.Make Our PHP Experts Your PHP ExpertsThe Zend team is at your disposal. ZendPHP and Zend Admin as a Service both come with 24/7/365 support from a global team of experts.Explore ZendPHP Discover Admin as a ServiceBack to topHow to Use ZendPHP With Grafana for Web Application MonitoringZendPHP fully-supported and secure runtimes, when paired with the ZendHQ extension, deliver advanced flexibility, scalability, and observability for PHP applications. One way to take full advantage of ZendPHP capabilities is by pairing it with Grafana for advanced web application monitoring. Use this step-by-step guide to get started.Step One: Install Your ExportersWeb application monitoring with Grafana starts with an HTTP endpoint that is scraped at an interval defined on the Prometheus time-series database (TSDB) server. Grafana queries the Prometheus TSDB for metrics, and not the endpoints directly. For most PHP web applications, there are three components (excluding an external database like MariaDB or PostgreSQL) that need to be monitored:The host machine, through the node_exporterPHP-FPM, through php-fpm_exporter The Web Server, through apache_exporter for HTTPD and nginx-prometheus-exporter for nginx OSS and ngnix-plusStep Two: Securely Expose Your ExportersOnce these applications are installed, they should then be configured to accept connections on unique ports bound to localhost. From there, HTTPD or nginx can be configured to expose these ports through a reverse SSL proxy that requires basic authentication. An example for nginx is available here, and an example for Apache HTTPD is here. There should be three endpoints exposed on each ZendPHP node:/prometheus/node_exporter/prometheus/php-fpm_exporter/prometheus/http_exporterYou should be able to navigate to each of these pages over SSL with a trusted certificate, and be prompted to authenticate; once you’ve successfully authenticated, you should see a page that looks like this: Step Three: Add Your Endpoints to the Prometheus TSDB ScraperNow that you have a list of URLs that you can scrape metrics from, you need to add these endpoints to the Prometheus TSDB configuration. A good example of how to add basic authentication and SSL is available here. Once you’ve successfully scraped these endpoints, you’ll be able to see a list of endpoints that looks like this, inside of the Prometheus TSDB server user interface: Step Four: Connect Grafana to PrometheusNow that you’re collecting data in the Prometheus TSDB server, you can view that data with Grafana. After installing and configuring Grafana to your organization’s specifications, add your Prometheus server as a data source. It will look something like this: Step Five: Import Default Dashboards for Your ExportersEach of the exporters you set up in step two have default dashboards that can display your data in Grafana.node_exporterphp-fpm_exporterapache_exporter or nginx-prometheus-exporterHere’s an example of the Grafana dashboard from nginx: Final Step: Make It Your OwnWhile the default dashboards are a great place to start exploring and making correlations about system health and performance, your application has specific needs that you’ll begin discovering over time. After you create dashboards and views based on the default dashboards that are specific to your application, you’re going to be operating on a whole new level of visibility to performance and uptime. Back to topPHP Web Application Monitoring Made Easy With Zend Admin as a ServiceThe six steps above can be pretty difficult to get into production, even for senior engineers that have some Prometheus and Grafana experience. As a part of our professional services, Zend by Perforce can enable your organization to have PHP web application monitoring securely through our Admin as a Service offering. This option is a bundled package that guides your organization through every step of the process, from testing to production.Uninterrupted PHP Web App Performance MonitoringAs a managed service, our Admin as a Service offering provides continuous monitoring of your PHP application. Our team has decades of experience across all our supported platforms, from Windows to Linux, from Docker to IBM i, and across a variety of clouds like AWS and Azure.Whether you're on-premise, hybrid, or in a completely orchestrated Kubernetes environment, the experts behind Zend Admin as a Service will provide you with weekly reports detailing performance and uptime issues, and delivering recommendations to improve the reliability of your application. Your monitoring data is your own and can be explored at any time through an easy-to-use and intuitive dashboard: Web Application Monitoring From an Expert TeamIf you’ve been looking for a way to put your PHP web application’s performance and availability on auto-pilot, look no further than Zend Admin as a Service. Our solution enables all of the benefits of Prometheus and Grafana and securely allows our team of experts to work with your team on resolving performance and uptime issues before they impact your business.Back to topFinal ThoughtsWhen it comes to getting started with PHP application monitoring, there is no definitive best answer—only the best answer for your business and application. No matter which method you choose, web application monitoring will allow you to quickly identify issues in your application and address them before they become problems, improving security, user experience, and performance.Ready to Get Started With PHP Application Monitoring?Zend is ready to hear from you. Explore our professional services — including Zend Admin as a Service — to learn more about our support capabilities. Contact us today to speak with an expert about your exact application.Professional Services Contact UsAdditional Resources30-Day Free Trial - ZendPHP + ZendHQ101 Guide - PHP SecurityOn-Demand Webinar - PHP Observability and Orchestration With ZendHQWhite Paper - Developing Web Applications With PHPBlog - Why Good PHP Monitoring MattersBlog - PHP Code Tracing With ZendPHP and ZendHQBlog - Introducing JobQueue for ZendPHPBlog - How to Build a Backup and Recovery Plan for PHP AppsBack to top
Connor Penhale Manager, Global Support, Zend by Perforce An experienced enterprise software architect working to solve complex business problems since 2005, and focused on the confluence of software engineering and global support operations for the Fortune 500, Connor is enabling cloud native solutions for Perforce customers around the world.