Tiers are the logical components of an application that can be executed on the same or different physical or virtual servers.
Two-Tiered Client-Server Architecture
In 2-tier architecture the front-end user agent connects with the back-end database server without any intermediary. Since there is a dedicated session between the client and the database server there is no shared cache on the server. The logic processing and database access are both performed by the back-end server.
Example: A website hosted on a web server is 2-tier client-server architecture.
Three-Tiered Client-Server Architecture
There are three components in 3-tier architecture: a front-end client and a back-end application server and database servers. The back-end application server is an intermediary between the client and database servers. The application server executes the logic and maps client messages to the database access request. The client has a dedicated session to the application server; these sessions are multiplexed over shared sessions between the application server and the database servers for database access. A shared object cache is present on the database server to serve the multiple clients that have been multiplexed on the same session.
Example: A website with a separate database component is 3-tier client-server architecture.
N-Tiered Client-Server Architecture
In n-tiered architecture, the application is divided into n components that execute in separate process contexts. The client is a component that runs on the user terminal and the other components are created by dividing the back-end functionality of the application into logical granules. The logical granules are created according to the functionality and scalability requirements. Multiple applications and multiple database servers can be present in the back-end. In an n-tier (n > 3) application the presentation tier and the application tier are combined into a single-tier also called middle-ware and the client can communicate with the data tier via middle-ware.
Example: The online shopping cart is an example of n-tier client-server architecture.
Locks are configured to prevent data corruption in the database due to synchronous read and write operations for the same memory location from the single or multiple users. The communication between the front-end client application and the back-end server may be HTTP/SOAP+XML, JMS, DCOM or RMI/CORBA. The communication between the back-end server components may be DCOM, JDBC or RMI-GIOP/CORBA.