How to manage environments in a microservice app?

github logo ・1 min read

I'm getting into microservices architecture. However, I don't know how to manage application enviroments (QA, Development, PreProduction, Production). It's common to deploy microservices apps in multiples virtual machines with Docker (docker-swarm or kubernetes). Let's supose I have a microservices app which uses 10 VMs, how can I handle applications enviroments? Do I need to instanciate 10 more for each environment?

twitter logo DISCUSS (2)
markdown guide

You need to use a container orchestrator to run your containers. Something like Kubernetes or Docker Swarm. Any orchestrator will have a way to get variables into the environment of the container. All languages should have a way to get values from the environment (e.g. process.env in Node). Pull all your config from there and let the orchestrator handle the different environments.

The orchestrator will abstract away whether your system is running on one dev machine or 10 EC2 nodes and you just use hostnames to talk to other services.

Read about 12 Factor App and container orchestration.


At my workplace, we've taken the view that simpler is better (for now) and are using AWS-provided solutions for managing both environments and service deployments.

Environments => Cloud Formation templates to create each complete network of VPCs, gateways, firewalls, storage accounts, key managers, etc.

Service deployments => Fargate to deploy docker instances into the service VPC for an environment, and some plumbing through API Gateway to route traffic - all automated through scripts called from our deployment pipelines in Azure DevOps.

If you aren't comfortable binding this closely to a specific cloud provider, then tools such as Terraform can help isolate things, as can working solely with portable orchestrators such as Kubernetes & Helm - we started with these but decided the complexity wasn't worth it yet.

Classic DEV Post from May 23 '18

Dynamic Programming – 7 Steps to Solve any DP Interview Problem

Simple 7 step tutorial to solve any Dynamic Programming interview problem - explained with a clear and easy example.

l222p profile image
Computer Sciences Engineer focused on Web Development and Cloud Computing (microservices)

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❀️