Can you identify a monolithic pattern vs. microservices? microservices vs. serverless?
Technology terms evolve over time. Sometimes, the meaning is stuck in the past. Sometimes, not everyone has caught up with the current interpretation. Sometimes, the meaning is mired by misconceptions.
Is it a monolith?
Are they microservices?
Is it serverless?
For each one below, take a look at the diagram and consider the question. Then, consider my take (apologies in advance for the LinkedIn speak). Afterward, I'd appreciate yours in the comments or a Restack.
Is it a monolith?
Is a monolith just a single block of software, or does it extend to the SQL database?
What if you distribute events?
What if your UI is served from the same container?
What if you scale a giant container horizontally to meet demand?
What if your job workers are instances of the same container as your API?
Is it still a monolith?
Someone told me, "You can’t scale a monolith horizontally. You can only scale it vertically." That seems silly because I’ve scaled huge monoliths across hundreds of small servers.
Whether it’s a monolith has nothing to do with the size of the application or how you scale it.
If multiple applications must always be redeployed together when one changes, they are not microservices. They are parts of a distributed monolith.
Web applications are almost always multi-component systems.
Even the simplest monolith of UI -> web server -> application -> SQL
is not a single block of software.
What makes it a monolith?
Not how many repositories it has.
Not how many containers it has.
Not how many lambdas it has.
Not how many teams it has.
Tight coupling makes it a monolith.
Are they microservices?
Is a microservice completely isolated, or can it share databases?
What if it's the same database server?
What if it's the same logical database?
What if they use different tables?
What if they use the same table?
Are they still microservices?
Someone told me, "If they share even the same database server, they aren't microservices." That seems silly because running a database server per microservice would be costly and complicated to maintain.
What if you used DynamoDB and had a separate table for each microservice. Are they using the same server? Are they running on the same machine? You don't know and don't care.
Whether it’s a microservice has nothing to do with if they share the same database server.
What matters is how tightly coupled the services are to dependencies, each other, and the data they manage.
If multiple applications own the same data, they are not microservices. If each application owns data isolated from data owned by other services, then they might be microservices.
Databases have different ways of logically separating data, including logical databases, namespaces, and tables.
What makes it a microservice?
Not how many repositories it has.
Not how many databases it has.
Not how many lambdas it has.
Not how many teams it has.
Loose coupling and high cohesion make it a microservice.
Is it serverless?
Is it serverless because the functions are built and run on demand?
What if the code runs in containers?
What if containers are pre-built?
What if it's microservices?
What if it's a monolith?
Is it still serverless?
Someone told me, "Only Functions as a Service is serverless." That seems silly because I've used serverless solutions with monoliths, microservices, databases, and machine learning without a single server to worry about.
Whether it’s serverless has nothing to do with if its built on demand or if it uses FaaS like AWS Lambda or Google Cloud Functions.
What matters is that you don't have to manage the servers. That the instances can scale to zero or there are no instances to think about. That it scales up with demand. That you are only billed for what you use.
OpenFaaS uses pre-built containers. AWS Fargate and Google Cloud Run manage and run containers for you. S3 is serverless storage. AWS Aurora is serverless Postgres DB.
Monoliths, microservices, databases, storage, API gateways, event buses, and even complex software like machine learning models can be serverless.
What makes it serverless?
Not where it's built.
Not if it uses functions.
Not if it uses containers.
Not how many APIs it exposes.
The abstraction of infrastructure management makes it serverless.
(Because "serverless" was originally associated with FaaS, people are now using "Serverless Functions" and "Serverless Containers" to distinguish the type of serverless architecture.)
("serverless" actually goes back much further. It originally, originally meant "only clients" as in peer-to-peer. That all changed in 2014 at re:Invent when Amazon announced Lamba)
Next actions
What are your thoughts?
I originally posted these on LinkedIn. They sparked some interesting discussions.
1. "Tight coupling makes it a monolith."
2. "Loose coupling and high cohesion make it a microservice."
3. "The abstraction of infrastructure management makes it serverless."
Such a brilliant post Mike! I am seeing many people are stuck in the useless terminologies. Any working solution to solve a real business problem has many blocks. Plumbing together the blocks in a most relevant way is what we do. Some nomenclature is useful but it is wasteful if something becomes a cult.
Very interesting overview Mike, thanks. I indeed assumed serverless is only FaaS solutions, but your definition makes much more sense.