Reusable Asset: N-Tier Pattern
A computing pattern in which presentation, application processing, and data management functions are logically separated. The most widespread use of multi-tier architecture is the three-tier architecture.
Main Description

Introduction

N-Tier is a multi-tier architecture (often referred to as n-tier architecture) is a client–server architecture in which presentation, application processing, and data management functions are logically separated (Wikipedia 2013).

Problem Description

Flexibility for a changing environment is required, which is provided through the separation of applications and data. The problem is divided into separate components that are then distributed in a systematic and controlled fashion. The information and accesses need to be controlled, and the maintenance of the information and applications is a large factor in the operation of the system. Security aspects are also an important part of the problem.

Applicable Context

This pattern is best applied where the different tiers, and associated hardware and software, need to be separately managed and upgraded. Flexibility is important along with scalability and distributed management and development.

Pattern Constraints

This pattern is not applicable if the application or the information cannot be distributed. The scalability of the applications and information access needs to be examined and managed, since this may be an issue if growth is expected. Also, since the information and application is centralized on a server, reliability may be impacted unless the solution is carefully designed and deployed.

Pattern Solution

The most common application of multi-tier architecture is the three-tier architecture pattern. It is a client–server architecture pattern in which the user interface (presentation), functional logic (business rules), data storage and access are separated into three layers as shown in the figure.

There are the usual advantages of modular software with well-defined interfaces, but the three-tier architecture also allows any of the tiers to be upgraded or replaced independently in response to changes in requirements or technology. For example, a change of operating system in the presentation tier would only affect the desktop application.

Typically, the user interface runs on a desktop workstation and uses a standard graphical user interface. The application logic may consist of one or more separate modules running on the workstation or an application server in the logic tier, and a database server or mainframe containing the computer data storage logic.

The middle tier in this pattern may be multi-tiered itself, in which case the overall architecture is called an "n-tier architecture". 

Client-Server Pattern

Presentation Tier

This is the top level of the application. It displays information related to the application, and provides the required services to the user. It communicates with other tiers to provide this service. 

Logic Tier

The logical tier controls an application’s functionality by performing detailed processing, supporting the presentation tier and using the data tier.

Data Tier

The data tier provides persistence and the data access services.  The data access layer provides an Application Programming Interface (API) to the Logical Tier that exposes methods of managing the stored data without exposing or creating dependencies on the data storage mechanisms.

Avoiding dependencies between tiers trough the definition of APIs is very important. As with any type of distributed system, there are added costs for implementation and to performance in exchange for improved scalability and maintainability.

Related Patterns

Other variations and related patterns to the client-server pattern are:

  • Distributed Computing Pattern - a system in which peer components, located on distributed and networked computers coordinate their activity through the passing of messages.

Distributed Computing 

  • Service-oriented Architecture  - an architecture pattern where discrete applications provide services to other discrete applications, which together provide the required functionality.

Service Oriented Architecture

  • Peer-to-peer Architectural Pattern - a distributed network architecture in which individual nodes (peers) in the network are both suppliers and consumers of services and resources.

Peer-to-Peer