Skip to content

Lesson 8 of 9 · 25m

Observability, Security, and Operational Hygiene

Instrument RPCs with meaningful cardinality, secure channels and identity, protect message boundaries, and build runbooks around real gRPC failure modes.

gRPC services often look healthy right up until clients are failing. CPU is fine, connections are stable, and dashboards are green because nobody measured the actual RPC surface: method, status, latency, cancellation, stream lifetime, retry amplification, and backend distribution. Production hygiene starts with measuring the protocol you actually run.

Metrics that answer questions

At minimum, collect:

rpc_server_started_total{service,method}
rpc_server_handled_total{service,method,code}
rpc_server_handling_seconds_bucket{service,method}
active_streams{service,method}
message bytes in/out
deadline exceeded and cancellation counts

Keep cardinality under control. Method and status are useful; raw object IDs, tenant IDs, emails, and error strings are cardinality bombs and privacy leaks.

Traces need business context carefully

Distributed tracing shows whether the budget was consumed in queueing, downstream calls, serialization, or storage. Propagate traceparent or OpenTelemetry baggage according to your platform standard. Add low-cardinality attributes such as operation type and retry attempt. Do not put payload contents into spans "temporarily"; temporary debug data has a way of becoming permanent.

TLS is table stakes, identity is the point

In production, encrypted transport should be normal. Service identity is the deeper question:

who may call this method?
which workload identity is presented?
which tenant or user is being impersonated?
is this traffic service-to-service or user-delegated?

SPIFFE/SPIRE, mesh mTLS, or platform workload identity can authenticate services. Do not confuse a valid service identity with permission to perform every user action.

Message sizes are security boundaries

Set explicit maximum send/receive sizes. Compression is useful but can amplify memory cost. Validate bounded collections, string lengths, nesting, and binary sizes before trusting generated types. Protobuf parsing is efficient, not magically safe against malicious allocation patterns.

Operational runbooks should mention gRPC realities

Useful runbook entries look like:

active streams rising + memory rising -> inspect slow consumers
UNAVAILABLE spike after deploy -> check endpoint discovery and health state
one backend hot -> verify connection balancing and stream lifetime
DEADLINE_EXCEEDED with successful writes -> inspect retry and idempotency

Generic "restart the service" advice destroys evidence and often amplifies connection storms.

Field notes

  • Sample traces intelligently; 100 percent tracing of high-volume RPCs is a budget decision.
  • Logs need request correlation IDs, not full sensitive payloads.
  • TLS certificate rotation failure often appears as UNAVAILABLE, not a helpful certificate error.
  • Alert on client-visible symptoms and server resource exhaustion separately.
  • Practice rollback and drain behavior. gRPC connection reuse makes abrupt restarts more visible to clients.

Was this lesson helpful?

Sign in to rate