# Rate Limiting by namespace

**URL:** <https://community.temporal.io/t/rate-limiting-by-namespace/1335>\
**Category:** Community Support\
**Created:** [January 20, 2021, 12:50am UTC](https://community.temporal.io/t/rate-limiting-by-namespace/1335 "2021-01-20T00:50:12Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven\_Sun](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/steven_sun/32/29_2.png) [@Steven\_Sun](https://community.temporal.io/u/Steven_Sun)\
**Post date:** [January 20, 2021, 12:50am UTC](https://community.temporal.io/t/rate-limiting-by-namespace/1335/1 "2021-01-20T00:50:12Z")

</div>

Hi QQ,  
Is there a way we can configure rate limit by namespace in the temporal server?

---

<div class="post-metadata">

**Author:** ![samar](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/samar/32/12_2.png) [@samar](https://community.temporal.io/u/samar)\
**Post date:** [January 20, 2021, 1:40am UTC](https://community.temporal.io/t/rate-limiting-by-namespace/1335/2 "2021-01-20T01:40:54Z")

</div>

You can use dynamic config to control namespace rps per instance of frontend role:

> <https://github.com/temporalio/temporal/blob/7d29b54365e39c19d083ae40df7ed8a7ccafd1b3/common/service/dynamicconfig/constants.go#L98>

---

<div class="post-metadata">

**Author:** ![Steven\_Sun](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/steven_sun/32/29_2.png) [@Steven\_Sun](https://community.temporal.io/u/Steven_Sun)\
**Post date:** [January 20, 2021, 10:59pm UTC](https://community.temporal.io/t/rate-limiting-by-namespace/1335/3 "2021-01-20T22:59:48Z")

</div>

> [@samar](#):
>
> `PSPerInstance: "frontend.namespacerps",`

@samar thank you, does that mean once I set this, all namespace will share the same limit. we cannot do per namespace limit yet, right?

---

<div class="post-metadata">

**Author:** ![samar](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/samar/32/12_2.png) [@samar](https://community.temporal.io/u/samar)\
**Post date:** [January 21, 2021, 2:44am UTC](https://community.temporal.io/t/rate-limiting-by-namespace/1335/4 "2021-01-21T02:44:07Z")

</div>

This limit will be enforced per namespace. Meaning let’s say you set `frontend.namespacerps` to 100 then both namespace A and B can perform 100 rps per frontend host before getting throttled. So overall frontend rps could be 200. This knob allows to configure different limits per namespace. For instance you can have a limit of 100 for namespaceA and 500 for namespaceB. If you want to have a global limit for the entire frontend please use `frontend.rps`.

---

<div class="post-metadata">

**Author:** ![Steven\_Sun](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/steven_sun/32/29_2.png) [@Steven\_Sun](https://community.temporal.io/u/Steven_Sun)\
**Post date:** [January 22, 2021, 11:08pm UTC](https://community.temporal.io/t/rate-limiting-by-namespace/1335/5 "2021-01-22T23:08:46Z")

</div>

> [@samar](#):
>
> `frontend.namespacerps`

to have different value for different namesapce, whats the example value?

- value:  
“namespaceA”: “valueA”  
“namespaceB”: “valueB”  
Or something else?

---

<div class="post-metadata">

**Author:** ![Steven\_Sun](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/steven_sun/32/29_2.png) [@Steven\_Sun](https://community.temporal.io/u/Steven_Sun)\
**Post date:** [January 25, 2021, 8:25pm UTC](https://community.temporal.io/t/rate-limiting-by-namespace/1335/6 "2021-01-25T20:25:09Z")

</div>

@samar can you answer my question above? what the example for value for per namespace rate limiting

---

<div class="post-metadata">

**Author:** ![samar](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/samar/32/12_2.png) [@samar](https://community.temporal.io/u/samar)\
**Post date:** [January 26, 2021, 5:50am UTC](https://community.temporal.io/t/rate-limiting-by-namespace/1335/7 "2021-01-26T05:50:05Z")

</div>

Hey @Steven_Sun, you can provide a custom value which applies to all namespaces by updating the dynamic config. The following dynamic config will apply the limit of 2000 rps for each namespace on a single host.

```auto
frontend.namespacerps:
- value: 2000
  constraints: {}

```

If you want to have a different value for namespaces you can specify namespace constraints for each namespace with a different value.

```auto
frontend.namespacerps:
- value: 2000
- value: 100
  constraints:
    namespace: "namespaceA"
- value: 500
  constraints:
    namespace: "namespaceB"

```

The above config will limit `namespaceA` rps to 100 and `namespaceB` rps to 500. All others will use 2000 rps.

Please refer to dynamic config [docs](https://github.com/temporalio/temporal/tree/master/config/dynamicconfig) for more information.

---

<div class="post-metadata">

**Author:** ![Steven\_Sun](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/steven_sun/32/29_2.png) [@Steven\_Sun](https://community.temporal.io/u/Steven_Sun)\
**Post date:** [January 26, 2021, 10:32pm UTC](https://community.temporal.io/t/rate-limiting-by-namespace/1335/8 "2021-01-26T22:32:30Z")

</div>

Thanks Samar

---

<div class="post-metadata">

**Author:** ![maki\_XIE](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maki_xie/32/2040_2.png) [@maki\_XIE](https://community.temporal.io/u/maki_XIE)\
**Post date:** [July 18, 2023, 8:12am UTC](https://community.temporal.io/t/rate-limiting-by-namespace/1335/9 "2023-07-18T08:12:18Z")

</div>

Hey dear, I have a follow-up question. I see these rate-limit configs are all for one instance of frontend, and is there a way to config a shared ratelimit value for all the frontend instances combined?

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [July 18, 2023, 2:32pm UTC](https://community.temporal.io/t/rate-limiting-by-namespace/1335/10 "2023-07-18T14:32:54Z")

</div>

See dynamic config `frontend.globalNamespaceRPS` (rate limit per second across all frontend hosts)
