• Home
  • Integrations
  • SDKs
  • Guides
  • API docs
No results for ""
EXPAND ALL

EDIT ON GITHUB

Big Segments

Read time: 1 minute
Last edited: Sep 24, 2021
Big Segments is an Enterprise feature

Big Segments is available to customers on an Enterprise plan. To learn more, read about our pricing. To upgrade your plan, contact Sales.

Overview

This topic explains how the Big Segments feature works in the LaunchDarkly SDKs that support it.

Big Segments are a type of user segment that can contain an arbitrarily large number of users. To learn more, read Big Segments.

Using Big Segments

Client-side SDKs support Big Segments by default, so no additional SDK configuration is required. However, if you use the Relay Proxy with client-side SDKs, then the Relay Proxy must be configured to use persistent storage.

You must configure server-side SDKs to use the Relay Proxy to get Big Segments data from the Relay Proxy persistent storage.

To learn more, read Configuring the Relay Proxy for Big Segments.

Details about each server-side SDK's Big Segments feature are available in the SDK-specific sections below.

Server-side SDKs

Server-side SDK configuration for Big Segments is comprised of two parts:

  1. The specific database options to get Big Segments data: for example, which database to use, and any other parameters supported by the SDK to configure that database. These are the same database options you specify when configuring server-side SDKs to use external databases as persistent feature stores. For example, key prefix or DynamoDB table name. To learn more about these database options, read Storing data.
Only certain types of database integration supports Big Segments

Only the Redis and DynamoDB integrations support Big Segments.

  1. The general options for the SDK's Big Segments behavior: the table below lists all the general options available. They are all optional and valid for all server-side SDKs and can be used for any supported database integration.
Config optionDescription
user cache sizeThe maximum number of users whose Big Segments status the SDK can cache. A user's Big Segments status includes all of the Big Segments the user is a part of. A higher value means that the SDK queries the database for recently-referenced users' Big Segments statuses less often. If not specified, the default value is 1000.
user cache timeThe maximum length of time that the SDK caches the Big Segments status for a user. If you do not specify a value, the default is five seconds.
status poll intervalThe interval at which the SDK polls the Big Segments store to make sure it is available and to determine how long ago it was updated. If not specified, the default value is five seconds.
stale afterThe maximum length of time between updates of Big Segments data before the SDK considers the data out of date. If you do not specify a value, the default is two minutes.

In all the server-side SDK code examples below, the configuration is set as follows:

  • using a Redis server at my-redis:6379
  • with a key prefix of my-key-prefix
  • user cache size: 2000
  • user cache time: 30 seconds

This feature is available in the listed versions and later of the following server-side SDKs:

.NET

Big Segments is available in version 6.2.0 and later:

1using LaunchDarkly.Sdk.Server;
2using LaunchDarkly.Sdk.Server.Integrations;
3var config = Configuration.Builder("my-sdk-key")
4 .BigSegments(
5 Components.BigSegments(
6 Redis.DataStore()
7 .HostAndPort("my-redis", 6379)
8 .Prefix("my-key-prefix")
9 )
10 .UserCacheSize(2000)
11 .UserCacheTime(TimeSpan.FromSeconds(30))
12 )
13 .Build();
14var client = new LDClient(config);

To learn more about the available Big Segments configuration options, read BigSegmentsConfigurationBuilder.

Go

Big Segments is available in version 5.5.0 and later:

1import (
2 ld "gopkg.in/launchdarkly/go-server-sdk.v5"
3 "gopkg.in/launchdarkly/go-server-sdk.v5/ldcomponents"
4 ldredis "github.com/launchdarkly/go-server-sdk-redis"
5)
6
7var config ld.Config
8config.BigSegments = ldcomponents.BigSegments(
9 ldredis.DataStore().
10 HostAndPort("my-redis", 6379).
11 Prefix("my-key-prefix"),
12 ).
13 UserCacheSize(2000).
14 UserCacheTime(time.Second * 30)
15client := ld.MakeCustomClient(sdkKey, config, waitTime)

To learn more about the available Big Segments configuration options, read BigSegmentsConfigurationBuilder.

Node.js (server-side)

Big Segments is available in version 6.2.0 and later:

1const LaunchDarkly = require('launchdarkly-node-server-sdk');
2const { RedisBigSegmentStore } = require('launchdarkly-node-server-sdk-redis');
3
4const store = RedisBigSegmentStore({
5 redisOpts: { url: 'redis://my-redis:6379' },
6 prefix: 'my-key-prefix'
7});
8
9const config = {
10 bigSegments: {
11 store: store,
12 userCacheSize: 2000,
13 userCacheTime: 30
14 }
15};
16const client = LaunchDarkly.init(sdkKey, config);

To learn more about the available Big Segments configuration options, read LDBigSegmentsOptions.