Tiers and Layers, in portuguese, are translated to the same word: “camadas”, so, unfortunately there’s no way to understand what they really means, because are two different things and very important. Regardless of language translation, I intend to explain the difference between them on this post.
- Physical separations between parts of the system.
- It envolves system components that runs or could easily run on separated machines.
- Tiers Example: Web Server, Database, Distributed Cache, Application Server, etc.
- Logical separations between parts of the system.
- Layers Example: MVC, DDD, etc.
- Focus on organizing your code.
Layers help decrease coupling and improve separation of responsibilities for better maintenance, evolution and organization of the system.
2 TIERS x 3 TIERS x N-TIERS
– 2 TIERS
Example: Clients accessing a database with business logic in stored procedures.
- Database dependency
- Difficulty of integration
- Low separation of responsibilities
- Low maintainability
- Point of failure
- Difficulty keeping all clients up to date
– 3 TIERS
Example: The remote client, the Web Server and the database.
P.S.: In this case, it loses the meaning of business logic to stay in Stored Procedures. Business logic would now be run in the middle tier (business tier).
- Ease of updating
- Ease of integration
- Separation of responsabilities
- Easy to keep all clients up to date
- Better maintainability
- Points of failure
- Less performance
3-Tiers variation. Usually 3-tiers with additional tiers as replication in clusters, load balancers and other tiers. It is also common to say that 3-Tiers are N-Tiers where N is equal to 3.
Attention to adding new tiers:
- It might impact performance
- Significant improvement in scalability
- Improvement in disponibility
- It might impact complexity
- It can make it difficult to manage and maintain the entire infrastructure
That’s it folks, I hope you liked it.
References: Introdução À Arquitetura e Design de Software, https://www.casadocodigo.com.br/products/livro-arquitetura-java