|
|
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 2 of 4
A one-tier application is simply a program that doesn't need to access the network while running. Most simple desktop applications, like word processors or compilers, fall into this category.
The advent of the Web complicates this definition a bit. As I mentioned earlier, a Web browser is part of a two-tier application (a Web server being the other part). But what happens if that Web browser downloads a Java applet and runs it? If the applet doesn't access the network while running, is it a one-tier or two-tier application? For present purposes, we will say that the self-contained applet is a one-tier application, since it is contained entirely on the client computer. By this definition, a program written in JavaScript or VBScript and deployed inside an HTML page would also qualify as a one-tier application.
One-tier architecture has a huge advantage: simplicity. One-tier applications don't need to handle any network protocols, so their code is simpler. Such code also benefits from being part of an independent operation. It doesn't need to guarantee synchronization with faraway data, nor does it need exception-handling routines to deal with network failure, bogus data from a server, or a server running different versions of a protocol or program.
Moreover, a one-tier application can have a major performance advantage. The user's requests don't need to cross the network, wait their turn at the server, and then return. This has the added effect of not weighing down your network with extra traffic, and not weighing down your server with extra work.
A two-tier architecture actually has three parts: a client, a server, and a protocol. The protocol bridges the gap between the client and server tiers. The two-tier design is very effective for network programming as well as for GUI programs, in which you can allocate functionality to the host. Traditionally, GUI code lives on the client host, and the so-called business logic lives on the server host. This allows user feedback and validation to occur on the client, where turnaround is quick; in the process, precious network and server resources are preserved. Similarly, logic lives on the server, where it is secure, and can make use of server-side resources (though here we're approaching a three-tier application).
The prototypical two-tier application is a client-server program with a GUI front-end written in a high-level language like Java, C++, or Visual Basic. In the two-tier program, you can see the clear division between front and back tiers. The first tier, the client, needn't worry about data storage issues or about processing multiple requests; the second tier, the server, needn't worry about user feedback and tricky user interface (UI) issues. For example, a chat application contains a client that displays messages and accepts input from the user, and a server that relays messages from one client to another. Specialization is good: divide and conquer.
Note that the Web again complicates the picture. Let's say you have a CGI program that calculates a mortgage. (It may be implemented
as a Java servlet or a Perl script.) All of its input is provided by the HTTP get request, via an HTML form which the user fills out. Its output is one or more HTML files. All the calculation occurs on the
server. Is this a one-tier or a two-tier application?
The definition is tricky. I prefer to call it a one-and-a-half-tier application. Even though its function incorporates a Web browser to display the output and accept user input, all of the actual program execution occurs on the server. Since the programmer is only responsible for writing a single running program, and not code that must execute on the client, then it's not truly a two-tier application. However, this is highly debatable, and you could easily argue that the HTML form is actually a primitive form of program code. Note also that the addition of any JavaScript or other client-side code promotes it to a two-tier application.
The reason for haggling over whether standard CGI programming results in a one- or two-tier architecture is that it has implications for your application's design and performance. A one-tier application combines all functions into a single process; a two-tier application must separate different functions. On the bright side, this means that a one-tier application has the ability to mix different functions; however, the programmer must make sure that the program doesn't become a mass of spaghetti code. Many Perl and Python CGI scripts are total pasta.
In some cases, you can write a two-tier application without writing a server or designing a protocol. For example, you can write a Web browser that speaks to a Web server using the (already designed) HTTP protocol. However, if you have to write your own server, or design and implement your own protocol, you can spend more time writing your program than you would if you were writing a one-tier application. The tradeoff is usually worth it, unless time-to-market is a crucial factor.
Server-side Java: Read the whole series -archived on JavaWorld