Mastering configuration for multi-environment web applications
Setting expectations
This article is aimed at technical people that have interacted with a web application. It sets the foundation for a series of articles where I am talking about configuration management for web applications.
Throughout the articles, I will consider a fictional, single page web application, called Meowsee. It allows cat owners to share pictures of their cats doing funny things, identify breeds and connect with other owners around the world. The application is actively developed by a team of a few hundred engineers spanned around multiple geos, following a continuous deployment model.
What’s the deal with configuration?
Modern web applications, such as Meowsee, can run either in a browser or embedded in a shell, in the case of hybrid mobile applications, and connect to various backend services. We can refer to the web application as to the client.
To be functional, the client needs information such as: the URLs and API keys for backend services, what is the display order of various content sections, whether specific functionalities are enabled or not for an end user etc. This information is generally called configuration, and it is split into feature flags and settings.
Settings and feature flags can be similar and quite different at the same time. Let’s see what they are and when to use one versus the other:
Moving forward with this example, the Meowsee app requires a feature flag (allowMeowTranslation) and two settings (meowTranslationApiUrl, meowTranslationApiKey) to integrate the translation functionality – sounds easy to manage, right?
The challenge of managing configuration
Well, managing a 3-dimensional configuration sounds simple enough, but there are some challenges that might not be so obvious in the beginning:
So how do we manage all the possible combinations to keep everyone happy, while ensuring high quality standards for what is delivered in production?
Enter configuration overrides
The solution is to allow configuration to be overridden at runtime and load time. The idea relies heavily on object-oriented programming and sounds like this:
Recommended by LinkedIn
Now we have defined a solution that fulfils the requirements mentioned above:
One environment, countless configuration flavours
But how exactly do software engineers and product managers manage to do their job in a timely manner if they must always start by defining configuration overrides?
Meowsee solves this by allowing engineers to define custom routes to override configuration. When accessing the route, the user sees the application loading normally, just as it does on the default route.
For instance, if we consider https://meowsee.cat to be the application’s host, then we can imagine the following routes:
allowMeowTranslation=True
allowMeowTranslation=True
meowTranslationApiUrl=”https://meow-translation.com/api/v2”
Wrapping things up
We have defined what is a setting and a feature flag and when to use each. Then we saw what the hidden challenges are when configuring web applications and how we can deal with them.
In the next article I will go into more details about how Meowsee’s custom routes work and how they go hand in hand with caching at the edge and authorization checks. I will tackle things like CloudFront, Lambdas and K8s. Stay tuned!
Delivery Lead
1y🚀🚀🚀