DEV Community

Cover image for System Design - Three-Tier Architecture 
João Godinho
João Godinho

Posted on

System Design - Three-Tier Architecture 

Tier vs Layer

  • You will commonly read about the Three-Tier Architecture using the word “layer”, but actually these are different concepts.

Tier:

  • Physical separation of parts of the system, usually running on different servers or processes and communicating over the network.

Layer:

  • Logical division of responsibilities inside the software (often inside the application tier), organizing code by concerns such as presentation, business logic, and data access.

IBM - "The Contacts app on your phone, for example, is a three-layer application, but a single-tier application, because all three layers run on your phone.”


Presentation Tier

  • The frontend of your application (mobile, web, desktop, etc) the piece of your software in which user will interact and will request something. Examples are: html + css + js website, ios mobile app made with swift, etc…

Application Tier

  • The tier where the application’s business logic runs, typically in a backend that users cannot access directly. Examples are: backend APIs, background workers, Business Logic Services (order service, payment service), lambda functions, and more.

Data Tier

  • Where the application's data is securely stored. Examples include: databases (SQL, MongoDB), object storage (AWS S3), caches (Redis), search indexes (Elasticsearch), and more.

A Three-Tier Application requires that all communication goes through the Application Tier. Presentation Tier cannot communicate directly with Data tier.


Benefits of Three-Tier Architecture

  • Development: Each tier can be developed simultaneously by different teams.
  • Scalability: Any tier can be scaled independently of the others as needed.
  • Reliability: Outage in one tier normally does not affect availability of another tier.
  • Security: Presentation and data tiers can’t communicate directly; having a well-designed application tier can prevent malicious exploits such as SQL injection.

Other Multitier Architectures

  • It's important to note that the Three-Tier Architecture is the most widely adopted. But there are also other options

Two-Tier Architecture:

  • Client-server where application logic can reside in the presentation tier, the data tier, or both. The presentation tier, and sometimes the end user, may have direct access to the data tier, but business logic can also reside on the server.
    • Example: Contact management application, where users can enter and retrieve contact data.
  • It could be: presentation → api + db on same server, in which case the client wouldn’t have direct access to the db. This is the difference of Three-Tier in which we segregate application and data tiers.

N-tier Architecture:

  • A system split into multiple logical tiers with multiple servers/services that communicate over the network.
  • Example1:
    • Presentation → CDN → API Gateway → Auth Service → Orders Service → Message Broker → Worker → Cache → Database
    • There are multiple application services.
  • Example2: Grouping conceptually as 3-tier (specific case of n-tier → 3-tier)
    • Presentation → CDN → Load balancer → API → Cache → Database
    • We can group it conceptually as a Three-Tier Architecture:
      • Presentation tier: Client / CDN
      • Application tier: Load balancer + API
      • Data tier: Cache + Database

References

Top comments (0)