Skip to content

Commit 5c16c34

Browse files
Merge pull request #1525 from redis/DOC-5195-go-prod-usage
DOC-5195 added Go production usage page
2 parents f0f4447 + 76a4878 commit 5c16c34

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
categories:
3+
- docs
4+
- develop
5+
- stack
6+
- oss
7+
- rs
8+
- rc
9+
- oss
10+
- kubernetes
11+
- clients
12+
description: Get your `go-redis` app ready for production
13+
linkTitle: Production usage
14+
title: Production usage
15+
weight: 6
16+
---
17+
18+
This guide offers recommendations to get the best reliability and
19+
performance in your production environment.
20+
21+
## Checklist
22+
23+
Each item in the checklist below links to the section
24+
for a recommendation. Use the checklist icons to record your
25+
progress in implementing the recommendations.
26+
27+
{{< checklist "goprodlist" >}}
28+
{{< checklist-item "#health-checks" >}}Health checks{{< /checklist-item >}}
29+
{{< checklist-item "#error-handling" >}}Error handling{{< /checklist-item >}}
30+
{{< checklist-item "#monitor-performance-and-errors">}}Monitor performance and errors{{< /checklist-item >}}
31+
{{< /checklist >}}
32+
33+
## Recommendations
34+
35+
The sections below offer recommendations for your production environment. Some
36+
of them may not apply to your particular use case.
37+
38+
### Health checks
39+
40+
If your code doesn't access the Redis server continuously then it
41+
might be useful to make a "health check" periodically (perhaps once
42+
every few seconds). You can do this using a simple
43+
[`PING`]({{< relref "/commands/ping" >}}) command:
44+
45+
```go
46+
err := rdb.Ping(ctx).Err()
47+
48+
if err != nil {
49+
// Report failed health check.
50+
}
51+
```
52+
53+
Health checks help to detect problems as soon as possible without
54+
waiting for a user to report them.
55+
56+
### Error handling
57+
58+
The `Result()` method of a command returns both the command result
59+
and an error value. Although you are mainly interested in the result,
60+
you should also always check that the error value is `nil` before
61+
proceeding. Errors can be returned for failed connections, network
62+
problems, and invalid command parameters, among other things.
63+
64+
### Monitor performance and errors
65+
66+
`go-redis` supports [OpenTelemetry](https://opentelemetry.io/). This lets
67+
you trace command execution and monitor your server's performance.
68+
You can use this information to detect problems before they are reported
69+
by users. See [Observability]({{< relref "/develop/clients/go#observability" >}})
70+
for more information.

0 commit comments

Comments
 (0)