Open for commentsSelect text to comment

Note

n-Tier or multitier architectures are related to layered architectures. Tiers refer to components that are typically on different physical machines. Although the terms “tier” and “layer” are used interchangeably, they are not the same thing. n-Tier or multitier architectures are layered architectures based on tiers.

The number of tiers in an n-Tier architecture can vary, although three-tier and four-tier architectures are common. The relationship between two adjacent tiers in an n-Tier architecture is often a client/server relationship. In a client/server relationship, one program (the server) provides services such as storing information in a database or performing computation tasks upon request from another program (the client). This communication is known as the request-response.

A tier can act as both a server and a client, fulfilling the requests of its clients and making requests of its servers at the same time.

Consider the deployment diagram below, illustrating the setup of a simple media server.

Client Server n-tier-1791638915137 One computer hosts the media server process, where movies and TV shows are stored and can be streamed on demand. When a client requests a movie or TV show, the media server streams it to the client. The server process does not know the number of clients it may have. More clients can be added as necessary.

In this example, server and client processes are on different computers; however, they can run on the same machine. The media server can be hosted on computer and use either a media player on the same desktop or a mobile device such as a tablet to watch the media.

Client-host and server-host refer to machines that host client software and server software respectively. In this diagram, the top row illustrates client-hosts, and the bottom row illustrates server-hosts. This diagram is therefore a two-tier architecture. The client-hosts make up the client tier, and the media server is the data tier. A server is usually specified by the type of service it provides. For example, these servers might be called web servers, application servers, file servers, and print servers.

The request-response relationship from this example can also be illustrated in a sequence diagram. Client Server n-tier-1791639368682 The client, in this case, a media player, requests to see what the media server has in its library. The server sends that information back. After the user makes a selection, the client requests the chosen video from the media server, which starts streaming it.

Request-response relationships can be synchronous or asynchronous. Client requests are often designed to run asynchronously, because it is often preferable to have clients be responsive for other tasks even if they are waiting for information from the server.

Limiting client/server relationships to request/response messaging patterns allows for systems that can be scaled more easily by adding clients. Clients and servers are extensible, because as long as a server receives a message it knows, it will respond. The source of the message is not important to the server, so many clients can be added as needed.

n-Tier architecture can take on different numbers of tiers, based on separation of concerns. Additional tiers can be added to the system for specific purposes. The example above, of a simple client-server relationship with one server and one set of clients, is known as a two-tier architecture.

However, you could also build a three-tier architecture, where a tier is inserted between the database and end users. This tier is often referred to as a middle layer, a business layer, or an application layer, its name depends on its main responsibility. Client Server n-tier-1791640091869 The middle layer will be a client of the database, and a server for the client application software on the end users’ devices. Middle tiers help determine how or when data can be changed, and in what ways. Having a middle layer allows client application software to be thinner, as it can be focused on presentation only. This makes it easier to maintain. You could add even more tiers to your architecture if you want, as long as the tiers serve a specific relationship.

Two potential drawbacks of n-Tier architecture include:

  • It requires extra resources to manage the client/server relationships. If more tiers are added, there are more machines or processes to manage, with different communication protocols. This makes a system more complex, and therefore more difficult to change and maintain.

  • A server acts as a central point of failure Systems may have backups or mirrors, but it can take time to switch to these backups and recover the server. Redundant servers are possible but add complexity.

The advantages of n-Tier architecture are notable, however, and contribute to its common use in the software industry.

  • n-Tier architecture is very scalable. Clients can continue to be added as long as a server can handle all the requests it receives in a reasonable time.

  • Centralization of functionality allow for data to reside on one machine but to be accessible by any machine on the same network.

  • Centralization of computing power allows client machines to require less processing power. Companies can thus offer processing power as a service, which is more practical and cost effective.

  • n-Tier architecture supports separation of concerns. Middle layers can take the role of managing application logic and accessing the database directly. Adding tiers can further allow for loose coupling and levels of abstraction, making a system that is easier to change and extend.

When a system can be split into service roles and request roles, a client/server architecture should be considered.

Built with LogoFlowershow