adding Read buffer size argument to fasthttp server and grpc server (#2263)

* adding Read buffer size argument to fasthttp server and grpc server dapr/dapr#3346

By making a contribution to this project, I certify that:
    (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
    (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
    (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
    (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.

This is my commit message
Signed-off-by: Fang Yuan <wojiushifangyuanlove@gmail.com>

* added introduction to dapr-http-read-buffer-size

Signed-off-by: Fang Yuan <wojiushifangyuanlove@gmail.com>

* Modify the note description

Signed-off-by: Fang Yuan <wojiushifangyuanlove@gmail.com>

* Adding read buffer size argument to fasthttp server and grpc server

Signed-off-by: Fang Yuan <wojiushifangyuanlove@gmail.com>

* Added introduction to dapr-http-read-buffer-size

Signed-off-by: Fang Yuan <wojiushifangyuanlove@gmail.com>

* Modify the note description

Signed-off-by: Fang Yuan <wojiushifangyuanlove@gmail.com>

* Modify this description

Signed-off-by: Fang Yuan <wojiushifangyuanlove@gmail.com>

* Add a detailed description

Signed-off-by: Fang Yuan <wojiushifangyuanlove@gmail.com>

* Make the appropriate title changes

Signed-off-by: Fang Yuan <wojiushifangyuanlove@gmail.com>

* Modification introduction and corresponding instructions

Signed-off-by: Fang Yuan <wojiushifangyuanlove@gmail.com>

Co-authored-by: Mark Fussell <markfussell@gmail.com>
This commit is contained in:
loopFY 2022-04-01 12:51:56 +08:00 committed by GitHub
parent b601f4d99d
commit 33d756f8f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,60 @@
---
type: docs
title: "How-To: Handle large http header size"
linkTitle: "HTTP header size"
weight: 6000
description: "Configure a larger http read buffer size"
---
Dapr has a default limit of 4KB for the http header read buffer size. When sending http headers that are bigger than the default 4KB, you can increase this value. Otherwise, you may encounter a `Too big request header` service invocation error. You can change the http header size by using the `dapr.io/http-read-buffer-size` annotation or `--dapr-http-read-buffer-size` flag when using the CLI.
{{< tabs Self-hosted Kubernetes >}}
{{% codetab %}}
When running in self hosted mode, use the `--dapr-http-read-buffer-size` flag to configure Dapr to use non-default http header size:
```bash
dapr run --dapr-http-read-buffer-size 16 node app.js
```
This tells Dapr to set maximum read buffer size to `16` KB.
{{% /codetab %}}
{{% codetab %}}
On Kubernetes, set the following annotations in your deployment YAML:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: default
labels:
app: myapp
spec:
replicas: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "myapp"
dapr.io/app-port: "8000"
dapr.io/http-read-buffer-size: "16"
...
```
{{% /codetab %}}
{{< /tabs >}}
## Related links
- [Dapr Kubernetes pod annotations spec]({{< ref arguments-annotations-overview.md >}})

View File

@ -22,6 +22,7 @@ This table is meant to help users understand the equivalent options for running
| `--dapr-grpc-port` | `--dapr-grpc-port` | | not supported | gRPC port for the Dapr API to listen on (default "50001") |
| `--dapr-http-port` | `--dapr-http-port` | | not supported | The HTTP port for the Dapr API |
| `--dapr-http-max-request-size` | --dapr-http-max-request-size | | `dapr.io/http-max-request-size` | Increasing max size of request body http and grpc servers parameter in MB to handle uploading of big files. Default is `4` MB |
| `--dapr-http-read-buffer-size` | --dapr-http-read-buffer-size | | `dapr.io/http-read-buffer-size` | Increasing max size of http header read buffer in KB to handle when sending multi-KB headers. The default 4 KB. When sending bigger than default 4KB http headers, you should set this to a larger value, for example 16 (for 16KB) |
| not supported | `--image` | | `dapr.io/sidecar-image` | Dapr sidecar image. Default is `daprio/daprd:latest` |
| `--internal-grpc-port` | not supported | | not supported | gRPC port for the Dapr Internal API to listen on |
| `--enable-metrics` | not supported | | configuration spec | Enable prometheus metric (default true) |

View File

@ -40,7 +40,7 @@ dapr run [flags] [command]
| `--profile-port` | | `7777` | The port for the profile server to listen on |
| `--unix-domain-socket`, `-u` | | | Path to a unix domain socket dir mount. If specified, communication with the Dapr sidecar uses unix domain sockets for lower latency and greater throughput when compared to using TCP ports. Not available on Windows OS |
| `--dapr-http-max-request-size` | | `4` | Max size of request body in MB. |
| `--dapr-http-read-buffer-size` | | `4` | Max size of http header read buffer in KB. The default 4 KB. When sending bigger than default 4KB http headers, you should set this to a larger value, for example 16 (for 16KB). |
### Examples
```bash