The Feature Flag Service is a gRPC-based microservice built with Spring Boot that dynamically enables or disables features for users at runtime.
It allows controlled feature rollouts without redeploying applications. Feature availability is determined using configurable business rules such as user role, plan, location, app version, and rollout percentage.
This service is designed to be scalable, deterministic, and production-ready for distributed environments.
For a given user and feature name, the service:
- Retrieves the user from the database
- Fetches feature configuration (cached)
- Evaluates feature rules:
- Feature active status
- Pin code restrictions
- Role restrictions
- Plan restrictions
- App version rules
- Percentage rollout
- Returns a boolean response indicating whether the feature is enabled
The service follows a fail-safe approach: if any error occurs, the feature is returned as disabled.
- Rule-based feature enablement
- Deterministic percentage rollout
- Version-based feature gating
- Role and plan targeting
- Location (pin code) targeting
- gRPC communication for high performance
- Cache-backed feature lookup
- Stateless design for horizontal scaling
Rollout percentage is calculated using a deterministic hashing strategy:
- A hash is generated from
userId + featureName - Result is bucketed into 0–99
- Feature is enabled if bucket value is less than rollout percentage
This ensures:
- Consistent results per user
- Gradual feature rollouts (10%, 25%, 50%, etc.)
- Safe production experimentation
- Java 21
- Spring Boot
- gRPC
- Protobuf
- Maven
- JPA / Hibernate
- Caching (e.g., Redis or in-memory cache)
- Docker
- Stateless microservice
- Database-backed feature configuration
- Cache-first feature retrieval
- Deterministic evaluation logic
- Designed for Kubernetes or containerized deployments
The service exposes a gRPC endpoint.
Request:
- User ID
- Feature Name
Response:
enabled: true | false
- Gradual feature rollout
- A/B testing foundation
- Role-based feature gating
- Safe production releases
- Mobile app version control
The service can be:
- Run locally using Maven
- Packaged as a Docker container
- Deployed to Kubernetes
- Integrated into CI/CD pipelines
- Fail-safe by default (disabled on failure)
- Deterministic behavior
- High performance via gRPC
- Clean separation of concerns
- Extensible rule evaluation logic