前回
これまでの関連記事は、下記のとおり
AppMeshの再試行を試してみます。
api01はAppMeshで3回再試行するように設定しています。
srver-error(500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511)時に再試行するように設定しています。
api01 の /retry は 500エラーを返すのでリトライするはずです。
まず、Meshの外側からアクセスしてみます。
SSMのセッションマネージャでNATインスタンスにログインし、下記コマンドを実行します。
$ curl -v http://api01.blue21.local/retry * Trying 10.0.11.150... * TCP_NODELAY set * Connected to api01.blue21.local (10.0.11.150) port 80 (#0) > GET /retry HTTP/1.1 > Host: api01.blue21.local > User-Agent: curl/7.61.1 > Accept: */* > < HTTP/1.1 500 Internal Server Error < server: envoy < date: Tue, 11 Aug 2020 01:23:13 GMT < content-type: application/json < content-length: 16 < x-amzn-trace-id: Root=1-5f31f301-f4a6bd724c6ba6749bdd2464 < x-envoy-upstream-service-time: 3 < {"status":"ng"}
api01のnginxのログを見ると以下のとおり。リトライしていません。
こんどは、Meshの内側(bff)からアクセスします。
SSMのセッションマネージャでECSインスタンスにログインし、bffのコンテナから下記コマンドを実行します。
[root@ip-10-0-11-163 app]# curl -v http://api01.blue21.local/retry * About to connect() to api01.blue21.local port 80 (#0) * Trying 10.0.11.150... * Connected to api01.blue21.local (10.0.11.150) port 80 (#0) > GET /retry HTTP/1.1 > User-Agent: curl/7.29.0 > Host: api01.blue21.local > Accept: */* > < HTTP/1.1 500 Internal Server Error < server: envoy < date: Tue, 11 Aug 2020 01:29:44 GMT < content-type: application/json < content-length: 16 < x-amzn-trace-id: Root=1-5f31f488-c724501afc0b49486a66ca28 < x-envoy-upstream-service-time: 151 < {"status":"ng"}
api01のnginxのログを見ると以下のとおり、設定どおりに3回リトライしています。
サービスマップは、下図のとおり。
トレースは、下図のとおり。再試行の様子が記録されるようです。
[MEMO]
- リトライの間隔を設定できるのか? 画面上はパラメータが見当たらない。