Search Sreeni's Insights

Filter by content type
technical August 26, 2020 17 min read

How We Selected New Relic for One of Our Flagship PHP-Based Products

How we selected New Relic for a flagship PHP product by comparing APM, database, browser, alerting and integration capabilities.

Share:

How We Selected New Relic for One of Our Flagship PHP-Based Products

Background

Currently, FundNexus(fabricated name of actual product) relies on sentry to track exceptions, but development teams looking for a full pledged application performance monitoring (APM) tools to enhance the observability of FundNexus applications and their dependent components.

Side effects of not having a full-fledged APM

Sentry is good at what it does, it tells us when an exception is thrown and where in the code it happened. But in our setup, it was used only for exception tracking, and an exception is just one symptom. Most of our production incidents and performance issues didn’t throw any exception at all. A page became slow, a background job took twice the time, a database query started to struggle under load, and Sentry was silent. These were our grey areas, and we only came to know about them when somebody complained.

Here are the side effects we lived with,

  • Customers found the issues first - Without request level telemetry, we didn’t know a page was slow until a customer or the support team reported it. Our first response was always reactive.
  • Firefighting instead of investigating - Every incident started with the same questions, is it the PHP code, the database, the web server, the network or a third-party service? Without the end to end trace, we had to collect the clues manually from web server logs, application logs, database stats and server metrics, and connect them by timestamps. It took several people and a lot of time to find where the problem actually was.
  • Long time to detect and resolve - Because we were blind until someone reported the issue, the Mean Time To Detect (MTTD) was long. And because we had to dig through multiple sources to find the root cause, the Mean Time To Resolve (MTTR) was long as well.
  • Guesswork on performance - We couldn’t answer simple questions like which transactions are the slowest, which database queries take the most time, or how the response time changed after the last deployment. Performance tuning was based on assumptions and on what we could reproduce locally, which is often very different from production.
  • Issues we couldn’t reproduce - Some issues happened only under production load or only for specific data. Without production telemetry, these issues stayed open for a long time and came back again and again.
  • No baseline, no proactive action - Without metrics like response time, throughput and Apdex score over the time, we didn’t have a baseline to compare with. So, we couldn’t set meaningful alerts and take action just before an issue impacted our customers.
  • Developer time drained - Every hour spent on firefighting is an hour not spent on the product. The same few people who knew the system well were pulled into every incident, and it was not sustainable.

Because of the above reasons, we decided that we need a full-fledged APM which can automatically collect the requests, dependencies, database queries, browser performance and infrastructure metrics, and connect them end to end. In simple terms, we wanted to move from firefighting to being proactive.

Why Application Insights is not suitable?

Application Insights is our existing APM within our organization, but there are no dedicated PHP agents available for it and we only have the SDK option but a few years ago, Microsoft stopped developing the SDK Application Insights and put into archival, again this SDK is not capable of doing automatically collecting of requests, dependencies and metrics.

Auto telemetry collection is the most important feature of any APM, otherwise we have to manually collect all types telemetry and metrics from the code as well as OS/web server level and it leads a lot of code changes in the application, it requires building a separate component to gather telemetry and metrics at the OS/Web server level, it requires home grounded experts and will take some time to come up with a mature solution.

How about OpenTelemetry?

OpenTelemetry was formed to provide the open standards for collecting telemetry data and forward to any backend. It provides a vendor agnostic agent to automatically collect telemetry data and push to any APMs for many languages. It could be the one of the solution to collect and transmit all PHP telemetry data to Application Insights, unfortunately it is in beta now and it does not support much functionality at the moment.

Decision:

Application Insights is not suitable with given limitations, we can probably come back when Open Telemetry supports all required functionality.

Considerations

The following features are taken into consideration in selecting the APM.

Features RequiredMoSCow
Auto collection of Server requestsMUST
Auto dependencies collectionMUST
Auto collection of Browser requestsMUST
Database/query trackingMUST
Error AnalyticsMUST
Request CorrelationMUST
Apdex ScoreMUST
DSL/Query Support for logsMUST
Infrastructure metricsMUST
Essential Reports and DashboardMUST
AlertsMUST
Synthetic or health checkSHOULD
Custom and Centralized loggingMUST
Data Retention - 3 MonthsSHOULD
Deployment MarkersMUST
SPA SupportsSHOULD
Real-Time User MonitoringCOULD
Integration supports with CI/CD pipelineCOULD

Other considerations:

  1. License model of the product. - We’re not interested in a host-based license.
  2. On-premise and azure/cloud supportability
  3. How easy to setup?
  4. How much developer-friendly information will be provided? (since developer going to use this tool as primary investigation tool)
  5. End to end tracing between across multiple components
  6. How easy to understand?
  7. How easy to create a custom report?
  8. How easy to integrate with third-party BI tools like Power BI, etc.?

Environments to Support

ComponentSupport Required
DatabasePostgres Sql >= 10.11 version
Mongo Db >= 3.2.22
FrameworksLaravel
Symfony
Php Cli
OSCent OS >= 7
Web ServerApache >=2.4

APM Candidates

The following APMs were considered for APM selection process

APM NameIs Right Candidate?RemarksWebsite
AtatusNoNo sufficient featureshttps://www.atatus.com/for/php
GermainNoNo sufficient featureshttps://germainapm.com/features/application-performance-monitoring/
Hello blackfireNoNot released yethttps://hello.blackfire.io/apm
AppdynamicsNoNo sufficient featureshttps://www.appdynamics.com/
NewRelicYeshttps://newrelic.com/
RetraceYeshttps://stackify.com/retrace/
DataDogYeshttps://www.datadoghq.com/

Shortlisted candidates:

  • NewRelic
  • Retrace
  • DataDog

Features comparisons

CategoryRequired FeaturesNew RelicRetraceDatadog
IntegrationAgentYesYesYes
SDKNoNoNo
License ModelAPMConsumptionConsumptionPer host
InfrastructureConsumptionConsumptionPer host
LogsConsumptionConsumptionConsumption
BrowserConsumptionConsumptionConsumption
Synthetics/Health checksConsumptionConsumptionConsumption
AlertsConsumptionConsumptionConsumption
APMWeb Transactions chartYesYesYes
Apdex ScoreYesYesYes
Database MonitoringYesYesYes
  PostgresYesYesYes
  MongoYesYesYes
Top TransactionsYesYesYes
Error AnalyticsYesYesYes
Deployment NotificationYesYesPartial
Code profilingYesYesNo
Custom Metrics and eventsYes but there is a limitNo No support for phpYes
Application MapYesNoYes
Support for Laravel & SymfonyYesYesYes
Metrics Summary retention90 days13 months - customizable15 days
Trace data retention7 days7 days15 days
Workitem creationYes only JIRAYes Azure DevOps and JIRANo
CI/CD supportNo Can use the APINo Can use the APINo Can use the API
BrowserPage view Load time chartYesYesYes
Error AnalyticsYesYesYes
Apdex ScoreYesYesYes
Har based request trace viewYesNoNo
SPA supportYesYesYes
SPA Load time chartYesNoNo
Real time user monitoringYes Partial SupportYes Partial SupportYes
AlertMetrics AlertYesYesYes
Alerts with custom logsYesYes Partial supportPartial
Integration with PagerDutyYesNo but integrate through webhookYes
SyntheticUrl based MonitorYesYesYes
Log MangementApplication LogsYesYesYes
Log filteringYesYesYes
Log query/DSLYesNoNo
Retention30 days to one year90 days to one year60 days Partial
DashboardCustom dashboardYesYes PartialYes Partial
Usability/UIUser experienceExcellentGoodVery good

Final Candidate:

New Relic.

License Model:

  • Telemetry Data Platform
    • Basic users get platform access to ingest, query, and dashboard telemetry data at $0 per user.
    • Free up to 100 GB/month.
    • $0.25 per GB ingested beyond free limit.
  • Full stack observability(portal, deployment notification, SSO, support, custom retentions, etc.)
    • Pro subscription cost about 276/349 USD per user
    • Unlimited basic users

Required Licenses:

  • How many pro licenses required? - Developers/System Admins
  • How many basic users required? - Can view dashboard and push data through API.

Findings:

General:

  • APM transaction names need to be updated for sub-pages.
    • Currently, APM tracking all KIID page as /kiiddocument and it should be changed to track all sub pages like /kiiddocment/prevalidation, /kiiddocument/valid, etc. The same thing can be applicable to other pages.
  • Nearly all browser transactions grouped into the root url of the site(like https://testing.fundnexus.example.com/). Prober transaction name need to be added here.
  • Proper application grouping required. Currently, both web site and background jobs grouped into one application.
  • Structure logs with monolog should add to both web and background jobs where ever possible.
  • Add filters to send only required logs
  • Add logs parser to convert the unstructured logs to structured logs
  • Custom attribute can be added to web application for better tracing.
  • A public health endpoint required.

MI Logs:

New Relic support to push the MI logs and we can also extend the retention for one year. However, it provides the API just to push the data and not to pull the data out. It has CSV export option again, it only supports 2000 rows max. If we want to want play around the data within the New Relic, it is perfectly fine, but if we want to align with our org wide MI log process, we need to look for an alternative.

Alternative solution:

Pushing the MI logs into Log analytics through Monolog.

Wrap up

Selecting a tool looks like a simple task, but it is one of the decisions that the team is going to live with for years. Normally, we fall into one of two traps while selecting a tool.

  • Streetlight approach - We search only where it is easy to search, like the drunk man who looks for his lost keys under the streetlight, because that is where the light is. In tool selection, it means picking the tool we already have in the organization or the one that is easy to get approval for, even if it does not solve our problem. In our case, Application Insights was the streetlight. It was already our organization APM, but it could not auto collect the PHP telemetry, and we would have ended up building and maintaining our own collectors.
  • Favouritism approach - We pick the tool that someone in the team already likes, has used in the previous project or is popular in the market at the moment. The decision is made first and the justification comes later.

Both approaches skip the most important question, what problem are we trying to solve? Because of the above reasons, we followed a simple and systematic approach and it can be applied to any tool selection, not just APM.

  1. Start with the need, not the tool. Write down the current pain and why the existing tool cannot address it. Be honest about the existing tool’s limitations.
  2. Define the required features and prioritize them with MoSCoW (Must, Should, Could, Won’t). It avoids the endless wish list and keeps the focus on the must have features.
  3. Capture the constraints of your environment, like languages, frameworks, databases, OS and web servers. A great tool is useless if it does not support your tech stack.
  4. Add the other considerations, like the license model, on-premise and cloud supportability, ease of setup, developer friendliness and integration with other tools. In our case, a host-based license was a deal breaker.
  5. Prepare a long list of candidates and filter out quickly the ones which do not meet the must have features, then shortlist the remaining (we shortlisted three).
  6. Do the head to head comparison of the shortlisted candidates against the same set of features. Keep it evidence based and record the partial support and limits as well, not just yes or no.
  7. Validate the winner with a POC on a real application. The POC brings out the findings which you will never find in the product documents, like our transaction naming and MI logs export limits.
  8. Size the license based on the actual usage (who needs full access and who only needs to view) and then take the go/no-go decision.
  9. Record the decision with the reasons, the people involved and the known gaps. When the context changes (for example, when OpenTelemetry matures), you can revisit the decision with the same criteria instead of starting from scratch.

Keep in mind that there is no perfect tool. New Relic also had gaps in our case, especially with the MI logs, and we had to plan an alternative for it. The systematic approach does not give you a perfect tool, but it gives you the right tool for your context and, most importantly, a decision that you can explain and defend.

In this article, we have looked at why our existing APM was not suitable, how we defined the selection criteria, how we compared the candidates and what we learned from the POC with New Relic. I really appreciate that you took the time to read this article and I hope it provided you some insights into how to select a tool systematically.

Related Posts