# blade create servlet delay

## 介绍

Java web 请求延迟

## 参数

以下是此场景特有参数，通用参数详见：\[blade create servlet]\(blade create servlet.md)

```
--time string             延迟时间，单位是毫秒，必填项
--offset string           延迟上下浮动时间，例如 --time 3000 --offset 1000，延迟时间的取值范围是 2000-4000 毫秒
```

## 案例

访问 <http://localhost:8080/dubbodemo/servlet/path?name=bob> 请求延迟 3 秒，影响 2 条请求

```
blade c servlet delay --time 3000 --requestpath /servlet/path --effect-count 2

{"code":200,"success":true,"result":"154c866919172119"}
```

访问请求进行验证。

请求参数是 name=family，延迟 2 秒，延迟时间上下浮动 1 秒，影响范围是 50% 的请求，同时开启 debug 日志用于排查问题，命令如下：

```
blade c servlet delay --time 2000 --offset 1000 --querystring name=family --effect-percent 50 --debug

{"code":200,"success":true,"result":"49236d2406d168f4"}
```

监控 应用进程用户目录/logs/chaosblade/chaosblade.log 日志

![](/files/2WZpuEDIi45oTtT5LyCZ)

可以看到下发了 create 指令并开启 debug 日志。 请求两次 <http://localhost:8080/dubbodemo/servlet/path?name=bob> ，由于参数 querystring 和下发的命令不匹配，所以没有生效 随后请求两次 <http://localhost:8080/dubbodemo/servlet/path?name=family，第一次打印了> Match rule 日志，说明匹配成功，延迟生效；第二次打印了 limited by，说明匹配成功，但是由于 effect-percent 参数的限制，所以场景被限制，此请求没有发生延迟

## 实验原理

## 常见问题


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://chaosblade-io.gitbook.io/chaosblade-help-zh-cn/blade-create-servlet/blade-create-servlet-delay.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
