diff --git a/frontend/src/component/segments/SegmentDocs.tsx b/frontend/src/component/segments/SegmentDocs.tsx index 27c4d0fca6..5bf66f4eb9 100644 --- a/frontend/src/component/segments/SegmentDocs.tsx +++ b/frontend/src/component/segments/SegmentDocs.tsx @@ -1,7 +1,7 @@ import { Alert } from '@mui/material'; import { useSegmentLimits } from 'hooks/api/getters/useSegmentLimits/useSegmentLimits'; -export const SegmentDocsValuesWarning = () => { +export const SegmentDocsValuesInfo = () => { const { segmentValuesLimit } = useSegmentLimits(); if (typeof segmentValuesLimit === 'undefined') { @@ -9,9 +9,16 @@ export const SegmentDocsValuesWarning = () => { } return ( - - Segments is an experimental feature, currently limited to at most{' '} - {segmentValuesLimit} values. + + A segment can have{' '} + + at most {segmentValuesLimit} across all of its contraints + + . ); }; @@ -25,8 +32,15 @@ export const SegmentDocsValuesError = (props: { values: number }) => { return ( - Segments are limited to at most {segmentValuesLimit} values. This - segment currently has {props.values}{' '} + A segment can have{' '} + + at most {segmentValuesLimit} across all of its contraints + + . This segment has {props.values}{' '} {props.values === 1 ? 'value' : 'values'}. ); @@ -41,8 +55,8 @@ export const SegmentDocsStrategyWarning = () => { return ( - Strategies are limited to {strategySegmentsLimit} segments.{' '} - + You can't apply more than {strategySegmentsLimit} segments to a + strategy. ); }; @@ -50,16 +64,14 @@ export const SegmentDocsStrategyWarning = () => { const SegmentLimitsLink = () => { return ( <> - Please{' '} - get in touch + Get in touch {' '} - if you would like this limit increased. + if you'd like to increase this limit. ); }; diff --git a/frontend/src/component/segments/SegmentFormStepTwo.tsx b/frontend/src/component/segments/SegmentFormStepTwo.tsx index 7921bc5d11..4c13cf7ac4 100644 --- a/frontend/src/component/segments/SegmentFormStepTwo.tsx +++ b/frontend/src/component/segments/SegmentFormStepTwo.tsx @@ -23,7 +23,7 @@ import { IAutocompleteBoxOption, } from 'component/common/AutocompleteBox/AutocompleteBox'; import { - SegmentDocsValuesWarning, + SegmentDocsValuesInfo, SegmentDocsValuesError, } from 'component/segments/SegmentDocs'; import { useSegmentValuesCount } from 'component/segments/hooks/useSegmentValuesCount'; @@ -43,7 +43,7 @@ const StyledForm = styled('div')(({ theme }) => ({ height: '100%', })); -const StyledWarning = styled('div')(({ theme }) => ({ +const StyledInfo = styled('div')(({ theme }) => ({ marginBottom: '1.5rem', })); @@ -130,9 +130,9 @@ export const SegmentFormStepTwo: React.FC = ({ return ( <> - - - + + +
Select the context fields you want to include in the diff --git a/website/docs/reference/deploy/configuring-unleash.md b/website/docs/reference/deploy/configuring-unleash.md index 2c61d0629a..cb904cafc7 100644 --- a/website/docs/reference/deploy/configuring-unleash.md +++ b/website/docs/reference/deploy/configuring-unleash.md @@ -180,6 +180,20 @@ const start = async () => { start(); ``` +### Segment limits {#segments} + +:::caution + +Changing segment limits could have a negative impact on the performance of Unleash SDKs and cause network congestion. Think twice before changing these values. + +::: + +Some facets of the [segments feature](../segments.mdx) can be customized via environment variables. This lets you change the [segment limits](../segments.mdx#segment-limits) that Unleash uses. + +`UNLEASH_STRATEGY_SEGMENTS_LIMIT` controls the maximum number of segments that can be applied to a single strategy. The default is 5. + +`UNLEASH_SEGMENT_VALUES_LIMIT` controls the maximum number of values that you can assign across a segment's constraints. The default is 100. + ## Securing Unleash {#securing-unleash} You can integrate Unleash with your authentication provider (OAuth 2.0). Read more about [securing unleash](./securing-unleash.md). diff --git a/website/docs/reference/segments.mdx b/website/docs/reference/segments.mdx index 5ded1c3724..917adc535d 100644 --- a/website/docs/reference/segments.mdx +++ b/website/docs/reference/segments.mdx @@ -38,6 +38,22 @@ Segments are collections of strategy constraints. To satisfy a segment, _all_ th If an activation strategy has a segment _and_ additional constraints applied, the segment _and_ the strategies must all be satisfied. Similarly, if an activation strategy has multiple segments, then they must _must all be satisfied_. +## Segment limits + +In theory, you could create segments with a thousand constraints, each with a million values. But this wouldn't scale well, so there are limitations in place to stop you from doing this. Unleash enforces the following limits on use of segments: + +1. By default, a segment can have **at most 100 values** specified across all of its constraints. That means that if you add a constraint that uses 10 values, you will have 90 more values to use for any other constraints you add to the same segment. + +2. By default, you can apply **at most 5 segments to any one strategy**. Separate strategies (even on the same feature) do not count towards the same total, so you can have two strategies with 5 segments each. + +You **can** [configure segment limits](deploy/configuring-unleash.md#segments) with environment variables. + +### A note on large segments {#large-segments} + +Segments are just constraints, so any limitations that apply to constraints also apply to segments. + +This means that if you want to add a hundred different user IDs to one of your constraints, you are most likely better off thinking about finding another way to solve this problem. That may be using a different abstraction or finding another pattern that you can use instead. Refer to the section on [constraint limitations](../reference/strategy-constraints.md#limitations) for a more thorough explanation. + ## Creating, updating, and deleting segments Segments can be created, edited, and deleted from the segments page in the admin UI or via the API (see the [segments API documentation](/reference/api/legacy/unleash/admin/segments.mdx)). @@ -45,9 +61,3 @@ Segments can be created, edited, and deleted from the segments page in the admin A segment that is in use **cannot** be deleted. If you'd like to delete a segment that is in use, you must first remove the segment from all the activation strategies that are currently using it. ![The Segments page, listing two existing segments: "Mobile users" and "Users in the APAC region". The navigation menu with the Segments page link is opened and highlighted to provide navigation help.](/img/segments-page.png) - -### A note on large segments and limits {#large-segments} - -In theory, you could you create segments with a thousand constraints, each with a million values. But this wouldn't scale well, so there are limitations in place to stop you from doing this. Segments are just constraints, so any limitations that apply to constraints also apply to segments. - -This means that if you want to add a hundred different user IDs to one of your constraints, you are most likely better off thinking about finding another way to solve this problem. That may be using a different abstraction or finding another pattern that you can use instead. Refer to the section on [constraint limitations](../reference/strategy-constraints.md#limitations) for a more thorough explanation.