Get Insights into backend infrastructure with Caches, Queues, Requests, & Queries
![Ben Coe image](https://images.ctfassets.net/em6l9zw4tzag/1q6SD6TX4kKtmos6Eqobbr/ee67d181c1f2b39ae762a89df1b88180/dog.png?w=32&h=32&q=50&fm=png)
Ben Coe -
![Get Insights into backend infrastructure with Caches, Queues, Requests, & Queries](https://images.ctfassets.net/em6l9zw4tzag/2nrcqB5m3mITUcgiojwRnK/4fff745aeb4f442f1b3f3be4037a37bc/crons-hero.jpg?w=2520&h=945&fl=progressive&q=50&fm=jpg)
To create exceptional products, developers need to understand the behavior of backed systems; however, we generally have the most control over the applications we’re deploying (not their dependent infrastructure). With this in mind, we’ve added new Insights to Sentry, providing visibility into common backend building blocks such as Caches, Queues, Queries, and Outbound Requests so you can quickly troubleshoot and debug issues when they occur.
A lesson learned over time…
I started my software development career in 2009 at a company called FreshBooks. Their product, a suite of tools that helped small businesses invoice their customers, was somewhat ahead of its time. It had a decoupled frontend and backend codebase, similar to web applications today. My time was split between building the frontend invoice UI (in jQuery of course) and corresponding backend logic in PHP. When it came time to release, the code would be thrown over the fence to a separate ops team and 🌟magic 🌟 would happen. I would gradually learn that this disconnect lead to building worse software (a slow database results in a slow frontend).
Quite a bit changed in the intervening 15 years. Full-stack engineering became popular, with many developers, myself included, better understanding the nuances of the databases, queues, caches, and other backend infrastructure they relied on. However, while It’s less common for companies to have a fully separate ops team, there’s still often a gap between a software developer and their backend machinery. For instance, if you’re using a hosted database service, you may not have visibility into its CPU and memory usage (your perspective is your application’s query performance). This is where Insights come in…
Getting backend infrastructure insights with Sentry
Insights are views into how your application interacts with the infrastructure that powers modern websites, like databases, queues, upstream APIs, and caches. They provide actionable workflows to help you debug problems in your application and improve its performance (even when you don’t directly control the upstream infrastructure). As an example, when using a hosted database solution, it’s still important to identify and improve slow queries. Queries insights make this easy.
Sentry provides insights for the following common backend components:
Databases
Queries insights help you understand your application’s interactions with databases, such as PostgreSQL, and MySQL.
They group together common queries in your application and provide aggregate metrics summarizing throughput (how often is the query called in your application?) and duration (how long, on average, does the query take to run?). With this information, you can identify query performance that’s regressed over time (perhaps a table that’s growing and missing an index) and, using Time Spent (a measure of duration × throughput), make decisions about queries that are worth further optimizing and/or refactoring.
Queues
Queues insights allow you to track background jobs in your application, from enqueuing through to completion. We launched with support for the popular Python queue abstraction Celery. Using manual instrumentation, you can add instrumentation for any popular messaging system, such as SQS, Cloud Tasks, or Kafka.
Queues Insights allow you to see how long messages take to complete in your system, this is useful for time-sensitive background jobs. For instance, you want a background job that generates hourly reports to complete in under an hour. Queues Insights also allows you to see if job processing is keeping up with job publishing, so you can identify and correct a common failure mode of messaging systems, insurmountable queue backlogs.
APIs
Request insights allow you to see the outbound HTTP requests being made to internal and external APIs. Many of the most popular HTTP clients are auto-instrumented, such as fetch for JavaScript, and requests for Python.
Outbound requests are grouped by domain, allowing you to observe aggregate trends in status codes, latency, and throughput. Perhaps you notice a third-party API frequently has bursts of 4xx errors that correlate with high traffic times for your application; this may point to an API quota that’s being hit (this can be confirmed by digging into the traces corresponding to individual requests). Perhaps you notice that an upstream dependency is simply flaky, returning 5xx statuses periodically for no obvious reason. This may help you decide to program more defensively, retrying the request with an exponential backoff.
Caches
Cache insights allow you to observe and debug the application-level caching. Currently, Cache insights supports Django’s cache framework for Python, and Redis for Node.js. It is also possible to instrument other cache frameworks with manual instrumentation.
Cache insights breakdown your application’s caching behavior by route. I once deployed code to npmjs.com that created a malformed cache key. When I did so, a high-traffic route went from being cached 98% of the time to 0% of the time, creating a huge load on the backed system protected by the cache (people install a lot of JavaScript). Cache Insights shows Miss Rate over time, which would have helped me identify this type of error quickly.
Above are just some specific examples of how insights can be used to help full-stack developers debug backend systems.
Modern full-stack development made easier
In modern web applications, it becomes less and less likely that a developer has complete control over their backend infrastructure — nor should they want to. At the same time, “throwing software over the fence to ops” isn’t how truly great products are made. The backend Insights we’ve been adding to Sentry, combined with tools such as Tracing, give you a whole toolkit for understanding your application’s interactions with first-party and third-party backend infrastructure so you can build best-in-class software that’s performant, error-free, and delightful to use.
Get started with Insights
Insights is available to all Business and Enterprise plans. To get started, follow the instructions in our docs to set up Tracing and you will start collecting insights for many common types of backend infrastructure (steps for custom instrumentation are also documented).
Get help and give feedback
If you have thoughts, feedback, or feature requests for backend Insights, reach out on GitHub or get in touch on Discord.