Shorts Software Engineering

Is every service a server in a microservice architecture?

“Service” and “server” are basically the same word, so it’s reasonable to question the difference between the two.

Services are abstractions we use to discuss our architecture. Servers are the hardware we use to run our system. They overlap in different ways, depending on what we’re trying to accomplish.

One-to-many; One service == Many servers

In this case, we have a service that requires more resources than a single server can provide. We could have a resource heavy service like ElasticSearch or a ML model, and we would want a cluster of servers. Or we could have service that requires high availability and we choose to run a load balancer in front of multiple servers.

Many-to-one; Many services == One server

The reverse case is where we want multiple services to run on a single server. Common cases:

  • Dev environment – We emphasize ease of creation/running/destruction on a single local machine, so we run scaled down versions of multiple services together.
  • CI/CD environments – Similar to dev environments, we’re optimizing for speed and budget, so we run a small version of our system on a single machine.
  • Small systems – With small systems, we may choose to run the system (or parts of the system) on a single server in prod to save costs or to make managing production easier.

One-to-one; One service == One server

This will always be an intentional design decision rather than something dictated by microservice architecture. For example, software may only provide a license for a single server. We could have the service run on a single server, but there is nothing architecturally stopping us from running other services on that server or from buying more licenses and running it across a cluster.

I hope that clears up the difference between services and servers. Just remember that services are an abstraction and servers are the hardware. Then, depending on what you’re trying to accomplish, you’ll know how they overlap.