0

I am confused about the relationship between monolithic and n-tier architecture (I have only analyzed 1, 2, 3 levels and tiers).

Since n-tier architecture divides the application into logical layers (usually Presentation Layer, Business Logic Layer, Data Access layer) and physical tiers, based on how many tiers are involved, can we talk about 1-tier, 2-tier or 3-tier monoliths?

Example:

Is a desktop application that runs only locally a 1-tier since the 3 logical layers (UI, Business Logic and Data Access Layer) run on a single machine? For example MS Excel? The difference between a 2-tier and 3-tier monolith would have as its only difference the fact that in the 2-tier the Business Logic and Database layer are executed on the same machine, while in the 3-tier the database is executed on a separate machine?

When we talk about monolithic web application nowadays, do we usually refer to a 3-tier or 2-tier monolith?

Also when we talk about logical separation, ok that means that there are different components that take care of each of the respective 3 aspects (3 layers), but does this coincide with a separation at file level (for example controllers defined in a folder, views under another etc...)?

If the code has HTML, CSS, JavaScript, and server-side logic (like C#) all mixed together in the same file or component, can we still talk about a proper logical separation into layers?

I thank anyone who will try to clarify my doubts.

0

2 Answers 2

1

IMO, there is no direct relationship between Monolith and N-Tier architecture, perhaps you meant Monolith vs. N-Layer?

Here’s why:

  1. N-Tier / N-Layer is an organizational model, whereas Monolith is more of a deployment and architectural model.
  2. A Monolith is a single physical unit that contains multiple logical layers, while N-Tier refers to multiple physical units, each unit has it's own machine/server and typically containing one or more logical layers.
  3. In terms of coupling, Monolithic systems are generally tightly coupled, while N-Tier systems are loosely coupled.

N-Tier architecture refers to the physical separation of software components or functions across different infrastructure or machines—such as having the front-end on one server, business logic (APIs) on another, and the database on yet another.

By contrast, a Monolith is inherently single-tiered, with all functions and layers—both logically and physically—residing in one place.

Clarifying Tier vs. Layer (by perspective of deployment or architecture mode)

  • Tier refers to physical separation: distinct running processes or machines.
  • Layer refers to logical separation: how code is organized within the same process or application.

It's worth noting that a monolithic application can internally follow an N-Layer architectural pattern, but it cannot be considered N-Tier, since that requires physically separate deployment units.

4
  • 1
    I have one additional question regarding monolithic web applications. If we consider a web monolith, it’s typically described as a 1-tier system, but it can also be n-layer (e.g., presentation layer, business logic layer, and data access layer all in one application). Given that it's a web-based system, one might think it fits the 2-tier model (client-server architecture), but since it’s deployed on a single server, it seems to be closer to a 1-tier architecture. How do these two concepts — the 1-tier and the 2-tier model — relate in this context? Commented May 11 at 16:29
  • 1
    @NicolaSergio Nice question! there's a another concept called: Perspective/View. From a NETWORK perspective, ANY monolithic web app typically follows a 2-tier client-server model. So yes, by that perspective it is a 2-Tire model... and sometimes it's strange, bcz when pep describe a monolithic web app, they're usually referring to deployment or architecture model, not network model. Bcz they don't care or knows nothing about network... anyway other perspectives are: Filesystem structure(scaffolding), Logical architecture, Runtime flow, deployment model, network architecture, etc... Commented May 12 at 7:33
  • So according to network model is 2-tier but according to deployment model is 1-tier. Is it correct? Commented May 12 at 7:44
  • 1
    @NicolaSergio Yes. Tier refers to physical separation: distinct running processes or machines. Layer refers to logical separation: how code is organized within the same process or application. Commented May 12 at 7:54
4

In the beginning there was the big ball of mud. The application was without architectural structure. Then Trygve Reenskaug said let there be Model View Controller. And he saw that having three modules focused on their respective responsibilities was good.

Others saw that this idea was good so they changed the names, the context, and claimed it was theirs. Thus was 3 layer / n tier architecture born. Logical separation granted the potential for physical separation. And they saw that it was good.

Others saw that layers were separations drawn horizontally and decided the next step was to draw some separations vertically. This time, separations were not between concerns, but between uses. Thus micro services were born. To promote micro services a name was needed for things made in the before time. Thus the name monolith was born.

Relationship between monolithic architecture and n-tier

Monolithic is what a microservice advocate calls your n-tier application when they want you to feel out dated.

Since n-tier architecture divides the application into logical layers (usually Presentation Layer, Business Logic Layer, Data Access layer) and physical tiers, based on how many tiers are involved, can we talk about 1-tier, 2-tier or 3-tier monoliths?

Yes.

Is a desktop application that runs only locally a 1-tier since the 3 logical layers (UI, Business Logic and Data Access Layer) run on a single machine?

A logical separation does not require physical separation. It simply enables it. Tiers, layers, and modules are logical separations. Even micro services are made of logical separations before physical ones.

For example MS Excel?

Maybe. I'd have to look at the code.

The difference between a 2-tier and 3-tier monolith would have as its only difference the fact that in the 2-tier the Business Logic and Database layer are executed on the same machine, while in the 3-tier the database is executed on a separate machine?

Again, physical separation is secondary to logical separation. Without logical separation physical separation simply doesn't work. I'm happy counting the logical separations. A big reason why is because that tells me how many physical separations are possible with this code base.

But if you insist on talking about a particular deployment, well yes, you can count the physical tiers. If you count more than 1 then without changing code I can redeploy it with fewer physical tiers (ain't virtualization fun?).

Don't get too hung up on what the tiers do. That isn't standardized. Some don't even use a database for their persistence.

When we talk about monolithic web application nowadays, do we usually refer to a 3-tier or 2-tier monolith?

I talked about that before.

When I see this:

Web Browser (has state) <-> Web Server (stateless) <-> Database (has state)

I think of it as 3-tier. But that might just be me. I'd still call it 3-tier even if all three ran on the same box. It's about logical separation.

Also when we talk about logical separation, ok that means that there are different components that take care of each of the respective 3 aspects (3 layers), but does this coincide with a separation at file level (for example controllers defined in a folder, views under another etc...)?

It sounds like you're asking about package by layer. I've talked about that before. I prefer package by feature.

If the code has HTML, CSS, JavaScript, and server-side logic (like C#) all mixed together in the same file or component, can we still talk about a proper logical separation into layers?

You can talk about it. But done like that it doesn't sound like you're achieving it.

8
  • Thanks for the clear explanation. Could you give me an answer to the questions posted? I would like to know if my assumptions are correct Commented May 6 at 23:23
  • @NicolaSergio Better now? Commented May 7 at 0:05
  • Tiers are physical separation of logical layers Commented May 7 at 8:15
  • @NicolaSergio the meaningful separation is a deployment boundary. Just because something can be deployed independently doesn't mean it must be. Commented May 7 at 11:21
  • I did not understand the answer about question of differences between monolith 2-tier and monolith 3-tier. There could be a difference Commented May 7 at 12:42

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.