Inspect a Running Application
Learn how to use observer to inspect a running application.
A running application
Let’s consider the following scenario. We see a performance problem with our production application, but we can’t quite figure out what is causing it. Our server may be having periods of slow requests, high memory usage, or failed requests. We collect metrics using StatsD or another tool, but it just doesn’t seem to pinpoint the exact problem. Luckily, we can run commands against a live server to find the problem.
In this lesson, we will look at tools for inspecting running applications and how to use them. We’ll need to have a way to log into a running server to use the tools listed in this section. If we are using Mix Release or Distillery to package our production application, we can use the remote_console
command to connect to our running server. If we do not have access to a running server, we’ll need to use collected metrics to debug performance problems.
First, we’ll look at tools that can help us collect and inspect metrics from running processes. We’ll focus heavily on a CLI-based observer tool that provides much of the same information that the GUI-based observer tool provides.
Tools for system inspection
One of the essential tools to have available in our production environment is to inspect running processes to identify performance problems. A metrics collector is vital, but sometimes it is necessary to see a performance problem happen live on a running server.
Elixir ships with several functions that provide information about processes. We can use Process.info/1
to collect information about a process. Let’s open an iex
session to try it out.
Get hands-on with 1400+ tech skills courses.