Manage features in SaaS

How does your SaaS app handle with what a user can do? How do you rollout of new features?

Plans

Your SaaS might have multiple plans that unlock access to certain features or integrations as the tier increases.

|                   | Professional | Team | Business |
|-------------------|--------------|------|----------|
| Tracked Keywords  |       1      |   3  |    10    |
| User              |       1      |   3  |     5    |
| Slack Integration |              |   x  |     x    |

Some features are volume limited and others are either enabled or not.

Rollout

You finished developing a new feature but you are not sure if the infrastructure can handle the load or if there will be bugs in production. We can do a staggered release to the userbase, releasing it to 10% of accounts randomly at a time. You can monitor the logs for errors and if looks good, ramp up the release 10% each time until the new feature is available to everyone.

To solve both issues, we can use a combination of

  • Feature Flags
  • Counts
  • API Middleware
  • Scripts

Feature Flags

To check what features a user can access based on their plan we store a set of string constants for each account in a field called features in the accounts schema.

features: ["SLACK_INTEGRATION", "FEATURE_2"]

We can update the field when

  • the user switches plans
  • we release new features and user is apart of the rollout.

Counts

We can store a field called max_${FEATURE} for each volume limited feature in the accounts schema.

max_tracked_words: 3

Then we can compare this field to the count of tracked_words and show a friendly message on the frontend if it is over the limit.

API Middleware

We can use some middleware to check for feature flags and counts under the max limit before any create or update operations for the features.

Scripts

We can use scripts to deploy the incremental rollout by adding the feature flag to 10% of the userbase that does not already have the feature. If anything goes wrong, it’s easy to revert the rollout by removing the feature flag from the accounts schema of all the users.