Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tocrafty committed Aug 30, 2023
1 parent 77f1149 commit 19a287f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 10 additions & 8 deletions slime/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
English | [中文](./README_zh_CN.md)

## Supported Protocols
<span style="color:red">**DO NOT enable retry/hedging for non-idempotent requests**</span>.
<span style="color:red">Not all protocols can use retry/hedging</span>.
Expand Down Expand Up @@ -28,7 +30,7 @@ gives a very detailed introduction of gRPC design. gRPC-java has implemented it.
* [bRPC](https://github.com/apache/incubator-brpc): In bRPC, a hedging request is called a backup request. This [doc](https://github.com/apache/incubator-brpc/blob/master/docs/cn/backup_request.md) gives a brief introduction, and its c++ implementation is relative simple.
* [finagle](https://github.com/twitter/finagle): finagle is a java RPC open source framework, it also implements [backup request](https://twitter.github.io/finagle/guide/MethodBuilder.html#backup-requests).
* [pegasus](https://github.com/apache/incubator-pegasus): Pegasus is a kv database that supports simultaneous reading data from multiple copies. [Backup request] is used to improve performance.
* [envoy](https://www.envoyproxy.io/docs/envoy/latest/): Envoy, as a proxy service, is widely used in cloud native. It also supports [request hedging](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/http/http_routing#request-hedging)
* [envoy](https://www.envoyproxy.io/docs/envoy/latest/): Envoy, as a proxy service, is widely used in cloud native. It also supports [request hedging](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/http/http_routing#request-hedging).

This article will introduce retry/hedging of the tRPC framework. In next section, we briefly introduced the rationale for retry hedging. The next two sectinos describe more implementation details. We introduced the basic package of retry/hedging, and the slime is a manager based on these basic capabilities, which provides you with yaml-based configuration. Finally, we list some problems you may encounter.

Expand Down Expand Up @@ -91,8 +93,8 @@ Don't get discouraged if you're using a load balancer that doesn't support skipp
## Introduce to Basic Retry/Hedging Packages
This chapter only briefly introduces the basic package of retry/hedging as the basis of next section. Although we provide some usage examples, please <span style="color:red">try to avoid using them directly at the application layer</span>. You should use slime to enable retry/hedging.

### [retry](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/retry)
[retry](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/retry) provides the basic retry strategy.
### [retry](./retry)
[retry](./retry) provides the basic retry strategy.

`New` creates a new retry strategy, you must specify the maximum number of retries and retryable error codes. You can also customize the retryable error through `WithRetryableErr`, which has an OR relationship with the retryable error codes.

Expand Down Expand Up @@ -120,8 +122,8 @@ r, _ := retry.New(4, []int{errs.RetClientNetErr}, retry.WithLinearBackoff(time.M
rsp, _ := clientProxy.Hello(ctx, req, client.WithFilter(r.Invoke))
```

### [Hedging](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/hedging)
[Hedging](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/hedging) provides the basic hedging strategy.
### [Hedging](./hedging)
[Hedging](./hedging) provides the basic hedging strategy.

`New` creates a new hedging strategy. You must specify the maximum number of retries and non-fatal error codes. You can also customize non-fatal errors through `WithNonFatalError`, which has an OR relationship with non-fatal error codes.

Expand All @@ -138,8 +140,8 @@ h, _ := hedging.New(2, []int{errs.RetClientNetErr}, hedging.WithStaticHedgingDel
rsp, _ := clientProxy.Hello(ctx, req, client.WithFilter(h.Invoke))
```

### [Throttle](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/throttle)
[Throttle](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/throttle) is a used to avoid retry/hedging write amplification.
### [Throttle](./throttle)
[Throttle](./throttle) is a used to avoid retry/hedging write amplification.

The `throttler` interface provides three methods:
```Go
Expand Down Expand Up @@ -387,7 +389,7 @@ There are a few points you need to pay attention to:

### Metrics
Similar to conditional logs, retry/hedge monitoring is also based on
[`view.Stat`](https://github.com/trpc-ecosystem/go-filter/blob/main/slime/view/stat.go).
[`view.Stat`](./view/stat.go).

slime provides four metrics: application layer request number, actual request number, application layer time
consumption, and actual time consumption.
Expand Down
18 changes: 10 additions & 8 deletions slime/README_zh_CN.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[English](./README.md) | 中文

## 支持的协议
<span style="color:red">**请不要对非幂等请求开启重试/对冲功能**</span>。
<span style="color:red">并非所有协议都能使用重试/对冲</span>。
Expand All @@ -8,7 +10,7 @@
|trpc||| 原生的 trpc 协议。 |
|trpc SendOnly||| 不支持,重试/对冲根据返回的错误码进行判断,而 SendOnly 请求不会回包。 |
|trpc 流式||| 暂不支持。 |
|[http](https://github.com/trpc-group/trpc-go/tree/main/http)||| slime v0.2.2 后支持。 |
|[http](https://github.com/trpc-group/trpc-go/tree/main/http)||||
|[Kafaka](https://github.com/trpc-ecosystem/go-database/tree/main/kafka)||| 不支持对冲功能。 |
|[MySQL](https://github.com/trpc-ecosystem/go-database/tree/main/mysql)||| <span style="color:red">除 [Query](https://github.com/trpc-ecosystem/go-database/blob/6f75e87fecfc5411e54d93fd1aad5e7afa9a0fcf/mysql/client.go#L40)[Transaction](https://github.com/trpc-ecosystem/go-database/blob/6f75e87fecfc5411e54d93fd1aad5e7afa9a0fcf/mysql/client.go#L42) 两个方法外,其他都支持</span>。这两个方法以函数闭包作为参数,slime 无法保证数据的并发安全性,可以使用 `slime.WithDisabled` 关闭重试/对冲。 |

Expand Down Expand Up @@ -87,8 +89,8 @@ server pushback 用于服务端显式地控制客户端的重试/对冲策略。
## retry hedging 基础包介绍
本章只是简要介绍重试/对冲的基础包,以作为后一章的基础。尽管我们提供了一些使用范例,但还是请<span style="color:red">尽量避免直接在应用层使用它们</span>。你应该通过 Slime 来使用重试/对冲功能。

### [retry](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/retry)
[retry](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/retry) 包提供了基础的重试策略。
### [retry](./retry)
[retry](./retry) 包提供了基础的重试策略。

`New` 创建一个新的重试策略,你必须指定最大重式次数和可重试错误码。你也可以通过 `WithRetryableErr` 自定义可重试错误,它和可重试错误码是或关系。

Expand All @@ -114,8 +116,8 @@ r, _ := retry.New(4, []int{errs.RetClientNetErr}, retry.WithLinearBackoff(time.M
rsp, _ := clientProxy.Hello(ctx, req, client.WithFilter(r.Invoke))
```

### [hedging](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/hedging)
[hedging](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/hedging) 包提供了基础的对冲策略。
### [hedging](./hedging)
[hedging](./hedging) 包提供了基础的对冲策略。

`New` 创建一个新的对冲策略。你必须指定最大重试次数和非致命错误码。你也可以通过 `WithNonFatalError` 自定义非致命错误,它和非致命错误码是或关系。

Expand All @@ -131,8 +133,8 @@ h, _ := hedging.New(2, []int{errs.RetClientNetErr}, hedging.WithStaticHedgingDel
rsp, _ := clientProxy.Hello(ctx, req, client.WithFilter(h.Invoke))
```

### [throttle](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/throttle)
[throttle](https://github.com/trpc-ecosystem/go-filter/tree/main/slime/throttle) 用来限制重试/对冲时的写放大。
### [throttle](./throttle)
[throttle](./throttle) 用来限制重试/对冲时的写放大。

`throttler` interface 提供了三个方法:
```Go
Expand Down Expand Up @@ -367,7 +369,7 @@ func (l *ConsoleLog) Println(s string) {
* 最后一条 slime 日志是对所有尝试的汇总。

### 监控
与条件日志类似,重试/对冲的监控也是基于 [`view.Stat`](https://github.com/trpc-ecosystem/go-filter/blob/main/slime/view/stat.go) 的。
与条件日志类似,重试/对冲的监控也是基于 [`view.Stat`](./view/stat.go) 的。

slime 提供了四个监控项:应用层请求数、实际请求数、应用层耗时、实际耗时。

Expand Down

0 comments on commit 19a287f

Please sign in to comment.