Skip to main content

How to Target Features by Tenants with Feature Flags

· 5 min read
David Herbert

Feature Flagging is a powerful technique that gives businesses and organizations granular control over features by providing the ability to scope these features to a specific segment of users.

Feature flags are helpful for many reasons - one of which is they allow organizations and engineering teams in a multi-tenant software application to limit access to certain features by mapping them to the various tenants in the application or organization.

What is a Tenant?

Cover Image

In software, a tenant refers to a group of users who share resources in a single software deployment with a common set of privileges. Each tenant, however, is guaranteed privacy and specific configuration. Within an organization, this expression describes a local/smaller part or division within the organization.

Multi-tenant applications typically require a high level of customization to meet the needs of each target division in an organization, which is often achievable using feature flags. E.g. Erste Bank in Austria might want to enable certain features for only their internal offices in the state of Tyrol.

Feature flags can be used in a multi-tenant application for a variety of reasons:

  • Using Feature Flags in multi-tenant organizations makes it possible to have an ideal isolation level between your business domains, business concepts, application users, and internal teams.

  • Feature Flags make it possible to gradually expose new features to some tenants with testing purposes in mind to ensure it is adopted progressively before rolling them out to the public.

How to Target Features by Tenants Using ConfigCat.

There are various ways to target tenants using ConfigCat.

Solution 1: Using Custom Attributes to Target Tenants

A custom attribute can be used to target specific users within an application. Since tenants are just an internal group of users, you can create a custom attribute in ConfigCat with special rules (like limiting or granting access to features) and assign this attribute to users within a specific tenancy in your organization.

This allows you to remotely set targeting rules for certain features, so only users associated with this custom property can access these features. To do this, log into your ConfigCat dashboard, create a feature flag and click on the "TARGET SPECIFIC USERS" button.

Target Specific Tenant Users

The first step to targeting your tenants is to select the user's comparison attribute tab, then choose "Custom", and provide a unique custom attribute. For example, "Tenant_ID" and then assign a value associated with every user in that tenant. After comparing it to the specified custom attribute, the value provided will be used to identify the target users (unique tenants).

Set Custom Tenant Attribute

Now all your application needs to do is pass this custom tenants attribute's value to ConfigCat for comparison to determine what tenants should have access to the feature.

Solution 2: Using Segmentation to Group and Target Tenants

A different approach to achieving the results above is using the segmentation feature in ConfigCat. Segment allows you to group your users according to any property they possess.

Using this feature, you can separate your users or tenants into unique segments, each representing individual tenants. To use this feature, click on the "TARGET SEGMENT" button on any feature flag.

Target Segment

After which, you can specify what users you want to group and target by an identifier, their email, country or any other unique custom attribute about these users.

Add New Tenant Segment

Now access is only given to users whose emails end with "@tyrol.examplebank.com", who are tenants of the Tyrol office, e.g. "[email protected]”.

Target Tenant by Segment

Solution 3: Giving Tenants a dedicated Environment in ConfigCat

A more visually appealing solution to handling tenants in ConfigCat is by separating these tenants based on isolated environments. By mapping tenants to multi-environments, users can only access certain features depending on the environment they belong to.

Each environment config can have its own unique SDK Key which can be used to initialize the ConfigCat SDK for that tenant within your application. You can then configure dedicated flags and targeting rules that allow teams to release features in one or a combination of environments (i.e. tenants).

To create these environments, go to your ConfigCat dashboard > Products > Environment > Add Environment.

Add New Tenant Environment

You can name these environments based on the various tenants.

Tenant Environments

Now for each feature flag created, you can specify the various environments these flags should serve.

Release Flag to Tenant

And each of these environments has unique SDK keys that only serve that isolated environment or tenant.

Tenant Environment SDK Key

Key takeaways

  • Multi-tenancy addresses the needs of organizations and SaaS applications to enable multiple users to access data while effectively isolating the data, its configurations, and end-users.

  • When developing a multi-tenant software application, you'll need to restrict access to certain features somehow; feature flags make that possible.

  • Organizations can use feature flags to structure the permission level and by product teams to control how a feature is adopted progressively before rolling it out.

  • ConfigCat makes it possible to target different features to different Tenants, and there are three possible solutions: Target by custom attributes, by segmentation, and by environments.

If you found this helpful and would like to explore more about feature flagging, you can follow ConfigCat on Twitter, Facebook, and LinkedIn.