AWS Builder Center
Debugging Distributed Systems Without SSHing Into Servers

Debugging Distributed Systems Without SSHing Into Servers

A practical guide to diagnosing production issues through logs, metrics, traces, and runtime observability instead of manually logging into machines.

A service starts returning errors at 2 AM.
You open your terminal, SSH into the application server, inspect the logs, check CPU and memory usage, look at running processes, and start investigating.
Eventually, you discover that the application is waiting on a database connection pool that has been exhausted.
You fix the issue, restart the service, and move on.
Now imagine the same problem in a system running across 30 containers, multiple availability zones, several services, and an autoscaling cluster.
Which machine do you SSH into?
The container that experienced the error might already have been replaced. The request may have passed through five different services. The issue might only happen under specific traffic conditions, and by the time you connect to a machine, the evidence may already be gone.
This is where traditional server-level debugging starts becoming a bottleneck.
In distributed systems, we should not need to know which machine handled a request to understand what happened to it.
Instead of treating servers as the primary debugging interface, we can treat the system itself as observable.
Let's explore how.

1. Stop Thinking in Terms of Servers

SSH is useful because it gives us direct access to a machine.
We can inspect files, processes, network connections, memory usage, and application logs. For a single-server application, this is often enough.
But distributed systems introduce a different set of problems:
  • Instances are frequently created and destroyed.
  • Containers move between hosts.
  • Requests cross multiple services.
  • Failures can be intermittent.
  • A single request may involve several databases and external dependencies.
  • The machine where an issue occurred might no longer exist when we investigate it.
Consider a typical request:
User
|
v
API Gateway
|
v
Order Service
|
+------> Payment Service
| |
| v
| Payment DB
|
v
Inventory Service
|
v
Inventory DB
|
v
Response
Suppose the user reports that an order took 12 seconds to complete.
Which service caused the delay?
Without visibility across the request, we might SSH into the API server, inspect its logs, and find nothing unusual.
The problem could be a slow payment provider, a database query, a connection pool, or a timeout between services.
The important shift is this:
Debug the request, not the machine.
A server is an implementation detail. The request and the operations performed to fulfill it are what we actually care about.

2. Three Things Every Distributed System Should Expose

You do not need dozens of monitoring products to get started.
A solid observability foundation comes from three complementary sources: logs, metrics, and traces.
They answer different questions.
Signal
Question it answers
Logs
What happened?
Metrics
How often is it happening?
Traces
Where did it happen?

Logs: Understand individual events

Logs provide details about application behavior.
Instead of writing unstructured messages:
Payment failed
Use structured logs:
{
"level": "error",
"service": "payment-service",
"event": "payment_failed",
"order_id": "ORD-123",
"payment_provider": "example-provider",
"error_code": "TIMEOUT",
"duration_ms": 5000,
"trace_id": "abc123"
}
Now we can search for payment failures, filter by provider, inspect durations, and connect the event to a specific request.
The important part is consistency.
Every service should follow a common logging format and include useful context.
Avoid logging secrets, access tokens, passwords, or unnecessary personal information.

Metrics: Understand system behavior

Logs are useful for individual events, but they are not the best way to understand system-wide behavior.
Imagine your payment service has a 2% failure rate.
You could search through millions of log entries to calculate it, but a metric gives you that information immediately.
Useful metrics include:
  • Request rate
  • Error rate
  • Request latency
  • Database connection pool utilization
  • Queue depth
  • Worker processing duration
  • CPU and memory utilization
  • Retry counts
Pay particular attention to latency percentiles.
Average latency can hide problems. If most requests complete in 100 ms but a small percentage take 10 seconds, the average may still look acceptable.
Monitor p50, p95, and p99 latency to understand the experience across different parts of your traffic.

Traces: Follow a request across services

Distributed tracing is where things become especially interesting.
A trace represents the journey of a request through your system.
Each operation contributes a span containing information such as:
  • Service and operation name
  • Start and end time
  • Parent-child relationships
  • Status and error information
  • Relevant attributes
For example, a request might produce this timeline:
POST /orders 12,000 ms
|
+-- order-service 11,900 ms
| |
| +-- validate-order 30 ms
| |
| +-- payment-service 8,500 ms
| | |
| | +-- external-payment-api 8,300 ms
| |
| +-- inventory-service 3,200 ms
| |
| +-- inventory-db-query 3,100 ms
|
+-- response serialization 20 ms
Instead of checking every server, you can immediately see where the time was spent.
This is the real value of distributed tracing: understanding the execution path without needing direct access to the machines involved.

3. Make OpenTelemetry Your Instrumentation Layer

One of the most useful technologies to adopt is OpenTelemetry.
OpenTelemetry provides vendor-neutral APIs, SDKs, and instrumentation for collecting traces, metrics, and logs.
The interesting part is that your application does not need to be tightly coupled to a particular monitoring provider.
You instrument your application once and export telemetry to a backend of your choice.
For example:
Application Services
|
v
OpenTelemetry SDK
|
v
OpenTelemetry Collector
|
+------> Metrics Backend
|
+------> Trace Backend
|
+------> Log Backend
The OpenTelemetry Collector is particularly useful.
It can receive telemetry from multiple services, process it, filter sensitive information, batch data, and export it to different backends.
This gives you flexibility to change observability vendors without rewriting instrumentation throughout your application.
For a Node.js service, getting started is relatively straightforward.
Install the OpenTelemetry packages and configure instrumentation before your application starts:
npm install \
@opentelemetry/api \
@opentelemetry/sdk-node \
@opentelemetry/auto-instrumentations-node \
@opentelemetry/exporter-trace-otlp-http
A simplified setup:
import { NodeSDK } from "@opentelemetry/sdk-node";
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";

const sdk = new NodeSDK({
traceExporter: new OTLPTraceExporter(),
instrumentations: [getNodeAutoInstrumentations()],
});

sdk.start();
This is a starting point, not a complete production configuration. You still need to configure the exporter endpoint, resource attributes, sampling, shutdown handling, and any required instrumentation for your environment.
Automatic instrumentation can capture useful information from supported HTTP clients, frameworks, and database libraries.
For application-specific operations, you can also create custom spans.
For example, if your order service performs a business-critical operation, you can explicitly instrument it rather than relying entirely on automatic instrumentation.
The goal is not to instrument every line of code.
It is to make important operations visible.

4. Correlation IDs Are More Important Than You Think

Imagine a request travels through five services.
Each service produces logs, but how do you know which log entries belong to the same request?
This is where correlation IDs and trace context become essential.
A trace ID identifies the overall distributed operation. Individual spans have their own span IDs, and parent-child relationships connect them.
When a request enters your system, the tracing instrumentation establishes or extracts the trace context.
That context should propagate across service boundaries.
For HTTP services, the W3C Trace Context standard defines headers such as:
traceparent: 00-<trace-id>-<parent-id>-01
The exact values are generated by the tracing implementation.
When the next service receives the request, it extracts the context and creates a child span.
Now logs from different services can include the same trace ID.
A debugging session becomes much simpler:
  1. Find the failed request.
  1. Copy its trace ID.
  1. Search logs across all services using that ID.
  1. Open the corresponding trace.
  1. Inspect the operation that failed or took unusually long.
One request ID can connect what would otherwise be thousands of unrelated log entries.
For asynchronous systems, context propagation matters just as much.
When publishing a message to a queue, preserve the trace context in the message metadata. The consumer can then continue the trace or establish a linked trace, depending on the processing model.
Without this, tracing often stops at the message broker, leaving an important part of the workflow invisible.

5. What About Debugging a Running Process?

There is an important limitation to logs, metrics, and traces.
Sometimes you need to understand what a process is doing right now.
For example:
  • A Node.js service has unusually high memory usage.
  • A worker is consuming CPU without making progress.
  • A process has a growing number of open file descriptors.
  • A service is experiencing event-loop delays.
  • A request is stuck waiting on an operation.
You still do not necessarily need SSH.
There are ways to collect runtime information without manually connecting to the machine.

Continuous profiling

Profiling helps answer questions that ordinary application metrics cannot.
For example, CPU profiling can reveal which functions consume the most processing time.
Memory profiling can help identify allocation patterns and potential leaks.
Continuous profiling tools can collect profiles over time and let you compare healthy and unhealthy periods.
Some options include:
  • Pyroscope
  • Parca
  • Grafana Alloy with profiling integrations
  • Cloud provider profiling services
Instead of connecting to a particular instance and running a profiler manually, you can investigate profiles across services and deployment versions.

Runtime metrics

Expose application-level runtime metrics.
For Node.js, useful examples include:
  • Event-loop delay
  • Heap usage
  • Garbage collection activity
  • Active handles
  • Process memory
  • CPU utilization
For Go, you might expose goroutine counts and garbage collection statistics.
For Java, you might monitor JVM heap, thread counts, garbage collection, and application-level metrics.
These signals help identify runtime problems before they become complete outages.

On-demand diagnostics

Sometimes you still need a heap snapshot, thread dump, or other detailed diagnostic artifact.
You can build controlled diagnostic workflows that collect these artifacts from a running workload and store them securely for investigation.
For containerized applications, this can be integrated into your orchestration and operations tooling.
The important distinction is that diagnostics should be deliberate, permission-controlled, and observable themselves. They should not require unrestricted shell access to every production machine.

6. Use Deployment Metadata to Connect Bugs to Changes

A particularly frustrating production issue is one that appears after a deployment.
You know something changed, but you do not know which service version is responsible.
This is why telemetry should include deployment metadata.
Useful attributes include:
{
"service.name": "order-service",
"service.version": "1.8.2",
"deployment.environment": "production",
"cloud.region": "ap-south-1",
"container.image.tag": "1.8.2",
"git.commit.sha": "a1b2c3d"
}
The exact attributes depend on your instrumentation and telemetry conventions.
With this information, you can ask:
  • Did error rates increase after version 1.8.2?
  • Are only new containers affected?
  • Is one availability zone experiencing higher latency?
  • Did a database migration introduce a regression?
  • Does the issue affect a particular dependency version?
This makes debugging much more systematic.
You can even compare traces from before and after a deployment to identify changes in execution time or behavior.
A useful practice is to annotate dashboards and traces with deployment events.
That way, a sudden spike in latency is visible alongside the deployment that preceded it.

7. Queues and Background Workers Need Special Attention

Not every distributed workflow happens during an HTTP request.
Many systems rely on queues and background workers.
For example:
API
|
v
SQS Queue
|
+----> Worker 1
|
+----> Worker 2
|
+----> Worker 3
|
v
Database
Suppose users report that their uploaded files take 15 minutes to process.
The API might be perfectly healthy.
The problem could be:
  • Queue depth increasing.
  • Too few workers.
  • Slow processing.
  • Repeated retries.
  • Poison messages.
  • Database contention.
  • A dependency becoming unavailable.
For queue-based systems, monitor more than just the number of messages.
Useful metrics include:
Metric
Why it matters
Queue depth
How much work is waiting?
Oldest message age
How long are users waiting?
Processing duration
How long does each task take?
Retry count
Are workers repeatedly failing?
Dead-letter queue depth
Are messages permanently failing?
Worker concurrency
Are enough workers available?
Also make sure that message processing is observable.
A message should carry enough context to connect it to the original operation. If the original trace context is propagated, you can follow the workflow beyond the HTTP request.
For AWS systems, this is particularly useful with services such as Amazon SQS, Lambda, ECS, and EventBridge.

8. An AWS-Oriented Observability Stack

If you are building on AWS, you do not need to assemble everything from scratch.
A practical starting point could look like this:
Requirement
AWS option
Application logs
Amazon CloudWatch Logs
Metrics and alarms
Amazon CloudWatch
Distributed tracing
AWS X-Ray
OpenTelemetry collection
AWS Distro for OpenTelemetry
Container monitoring
CloudWatch Container Insights
Managed Prometheus
Amazon Managed Service for Prometheus
Managed dashboards
Amazon Managed Grafana
For example, an ECS-based application can send application logs to CloudWatch Logs, expose container and application metrics, and use OpenTelemetry instrumentation to export traces.
For Kubernetes workloads, you can use OpenTelemetry Collectors alongside your existing monitoring infrastructure.
The important thing is to avoid creating isolated monitoring systems for every service.
A distributed system needs a consistent way to correlate telemetry across its components.
Also, remember that observability has a cost. High-cardinality labels, excessive log volume, and unsampled traces can become expensive quickly. Define retention policies, sampling strategies, and access controls from the beginning.

9. A Practical Workflow for Debugging Without SSH

Let's put everything together.
Imagine your production API starts experiencing intermittent latency.
Here is how I would investigate it.
Step 1: Start with the symptom
Check your dashboards.
Is the problem an increase in error rate, latency, queue depth, or resource utilization?
Identify when it started and which services are affected.
Step 2: Check deployment history
Did a new version go live around the same time?
Compare affected and unaffected service versions.
Step 3: Find a representative trace
Select a slow or failed request.
Inspect its complete execution path across services.
Step 4: Identify the bottleneck
Look for unusually slow spans, failed dependencies, repeated calls, or unexpected retries.
Step 5: Correlate with logs
Use the trace ID to find the relevant structured logs across services.
Inspect the actual application-level events.
Step 6: Check runtime and infrastructure metrics
If the trace points to a particular service, inspect its CPU, memory, connection pools, event-loop delay, and other runtime metrics.
Step 7: Collect deeper diagnostics if necessary
If the problem is still unclear, use profiling, heap snapshots, thread dumps, or controlled runtime diagnostics.
Step 8: Fix and verify
Deploy the fix and compare the same metrics and traces before and after the change.
This approach does not eliminate the need for SSH. It makes SSH the exception rather than the first debugging tool.

10. Does This Mean SSH Is Dead?

Not at all.
There are situations where direct machine access is still useful:
  • A broken host-level networking configuration.
  • An operating system issue.
  • A kernel or filesystem problem.
  • A misconfigured container runtime.
  • A machine that cannot export telemetry.
  • A debugging scenario requiring direct inspection of a process.
But these should be exceptional situations.
If your routine application debugging requires SSHing into random production instances, that is often a sign that your observability infrastructure is incomplete.
There is also a security benefit to reducing routine SSH access.
Fewer persistent access paths mean fewer credentials to manage, fewer opportunities for accidental changes, and a smaller operational attack surface.
You can still maintain controlled break-glass access for exceptional incidents.
The goal is not to remove access to machines. It is to stop depending on manual access to understand normal application behavior.

Conclusion

Distributed systems make traditional server-centric debugging increasingly difficult.
Instances are ephemeral, requests cross multiple services, and failures often happen somewhere other than where they first become visible.
The answer is not to become better at SSHing into more machines.
It is to make your system observable.
Start with structured logs, useful metrics, and distributed traces. Add consistent context propagation, deployment metadata, runtime profiling, and visibility into background workers.
Most importantly, make sure every important operation can be connected to the request or workflow that caused it.
When something breaks, you should be able to answer:
  • What happened?
  • Which service was involved?
  • Where did the request spend its time?
  • What changed before the issue started?
  • Which dependency or operation caused the failure?
And ideally, you should be able to answer all of that from a dashboard without opening a terminal.
The best debugging experience is not having SSH access to every server. It is not needing it in the first place.



Further Reading

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article