Add example

This commit is contained in:
Marco Munizaga 2022-08-10 17:21:08 -07:00
parent 056c0f6622
commit 703898608a

View File

@ -284,13 +284,24 @@ go-libp2p process. For the default definitions see `DefaultLimits` and
### Tweaking Defaults ### Tweaking Defaults
If the defaults seem mostly okay, but you want to adjust one facet you can do If the defaults seem mostly okay, but you want to adjust one facet you can do
simply copy the defaults and update the field you want to change. You can simply copy the default struct object and update the field you want to change. You can
apply changes to a `BaseLimit`, `BaseLimitIncrease`, and `LimitConfig` with apply changes to a `BaseLimit`, `BaseLimitIncrease`, and `LimitConfig` with
`.Apply`. `.Apply`.
Example
```
// An example on how to tweak the default limits
tweakedDefaults := DefaultLimits
tweakedDefaults.ProtocolBaseLimit.Apply(BaseLimit{
Streams: 1024,
StreamsInbound: 512,
StreamsOutbound: 512,
})
```
### How to tune your limits ### How to tune your limits
Once you've set your limits and monitoring (see below) you can now tune your Once you've set your limits and monitoring (see [Monitoring](#monitoring) below) you can now tune your
limits better. The `blocked_resources` metric will tell you what was blocked limits better. The `blocked_resources` metric will tell you what was blocked
and for what scope. If you see a steady stream of these blocked requests it and for what scope. If you see a steady stream of these blocked requests it
means your resource limits are too low for your usage. If you see a rare sudden means your resource limits are too low for your usage. If you see a rare sudden
@ -305,9 +316,9 @@ define your initial limits. Disable the limits by using `InfiniteLimits`.
### Debug "resource limit exceeded" errors ### Debug "resource limit exceeded" errors
These errors occur whenever we've hit a limit. For example we'll get this error These errors occur whenever a limit is hit. For example you'll get this error if
if we are at our limit for the number of streams we can have, and we try to open you are at your limit for the number of streams you can have, and you try to
one more. open one more.
If you're seeing a lot of "resource limit exceeded" errors take a look at the If you're seeing a lot of "resource limit exceeded" errors take a look at the
`blocked_resources` metric for some information on what was blocked. Also take `blocked_resources` metric for some information on what was blocked. Also take