Monitoring PHP Applications with Instana

Introducing PHP Support from Instana

PHP is one of the most popular and widely used scripting languages on the web. From it’s inception as “Personal Homepage Tools”, it has evolved to a versatile general purpose language powering everything from blogs, CRMs, eCommerce shops, online games and enterprise applications. This wide range of applications made PHP a logical choice for Instana to provide support.

Automatic Discovery of PHP infrastructure

As part of our Application Performance Management solution, Instana automatically discovers PHP running (as PHP-FPM, PHP-CGI and Apache’s mod_php Server APIs) and installs our distributed tracing technology for it. Like everything else in Instana, this installation is automated, requiring zero configuration effort.

If your server runs PHP, we will find, instrument and monitor it.

All versions of PHP starting from PHP 5.3 are supported, including the newly released PHP 7.1. This includes 32-bit and 64-bit PHP, and also covers PHP compiled with and without Zend Thread Safety (ZTS).

PHP-FPM Monitoring

For PHP-FPM, we provide live insights into its configuration and collect metrics for any configured worker pools, including accepted connections, slow requests, active and idle processes, and memory consumption. All metrics are collected at 1-second granularity.

PHP Monitoring Dashboard

We are also monitoring the health of your PHP-FPM Servers, watching for typical production issues, like when PHP-FPM has too many pending or slow requests, connection resets or worker pool restarts.

Automatic Discovery of PHP services

Instana traces PHP requests on your servers, discovers the entry points to all PHP services in your application, and displays them in the Application Map. Entry points connected to any other services or infrastructure (such as databases or message queues) are also mapped. Like any other component, the comprehensive view of your application links the physical and logical layers together, and shows traffic flow in real time.

PHP Application Map

We automatically collect key performance indicators (KPIs) for these services, like average latency, error rate, requests per second and available instances to make sure you’re alerted to any potential service health issues.

Discovery is fully automatic and continuously aligned with changes based on the real-time architecture of how requests are handled within the Application. Staying true to the Instana experience, there is no manual dashboard building or configuration required. However, we also offer a tool to tailor service discovery to your business domain if needed.

PHP Service Map

Instana traces every incoming PHP request to your application, measuring the execution time, memory consumption and any additional interesting information about the request. This includes all outgoing calls made via PDO, ext/mysqli, ext/mysql, IBM DB2, OCI, MongoDb, Predis, Memcached, cURL, pecl_http and any calls made via the HTTP streaming API. Your code does not need to be changed for this. It just works.
PHP Trace Request Screen

Support for further automatic introspection into various major frameworks, like Symfony, Laravel and Zend Framework, is scheduled for a late 2017 release. We will also add support for popular shop systems, like Magento, Shopware and Oxid, and offer an SDK for custom instrumentations.

Instana’s primary use case is production monitoring. While the sample rate of the tracing can be adjusted to a lower rate, our extension is very lightweight and there is no technical reason to trace less. We achieve this by intercepting a selected few function calls within the PHP engine and yielding control back to the original program flow very early. Unlike profilers, this approach produces minimal overhead and makes Instana PHP tracing suitable to be always enabled for production sites.

Finding PHP code problems in production using Instana

Because Instana‘s tracing is distributed end-to-end tracing, our traces contain calls from the requesting user’s browser across your entire monitored service landscape. This will give you a complete overview of the path the request took through your various service endpoints. For microservice architectures, this includes those written in other languages, like Java, Ruby, Node.js or .NET. This makes it easy to pinpoint where specific bottlenecks are.

If Instana detects errors during execution of monitored calls, the corresponding spans in the trace will be marked with an error and contain the full backtrace for this request. Instana offers a configurable backchannel into your code, which makes getting to the offending line of code as simple as a single click.

PHP Tracing Span

This way, you can start troubleshooting immediately and have almost the entire context of the request available to you, directly from your production environment. And with our TimeShift feature, you can even select a past timeframe when an error happened to see the exact state of your application at that time (form the physical infrastructure, to the logical components and down to the trace).

PHP Drill-down for debugging

As I mentioned, deployment is automatic. Try it for yourself and see what your PHP Applications are doing today. Want to dig in even deeper – read the technical PHP Monitoring documentation at instana.com.