When the solution matters

Tips...

Registration Documentation Knowledgebase Seminars / Training Technical Support Partner Central

Choose Your Architecture

The 4D Web Platform is a very flexible one. There are numerous ways you could architect your application. This document will explore what some of those options are, and help you decide which is best for you.

Contextual or Non-Contextual Mode?

The first fundamental question to ask is: should I use contextual or non-contextual mode for my application? Contextual mode is the fastest and easiest way to get web applications onto the Internet. It is designed to emulate the traditional 4D Client/Server interaction, but through a web browser. This approach has some limitations that may make it unsuitable for many public web sites.

Serious web applications are built using non-contextual mode. This uses 4D, operating as a classic, stateless web server. The developer has complete control of the entire HTTP request-response cycle. Non-contextual mode will work with any of the architectures outlined here, whereas contextual mode works best when using 4D all by itself. Consequently, this document will assume that you will be building a non-contextual web application.

Three Cheers for Three Tiers

In any web application, there are (conceptually, at least) three tiers: the presentation, middleware, and database. The presentation tier is the one that provides the interface to the application; in other words, the web server. The middleware tier is what sits between the web server and the database. It receives requests for data from the web server, and queries the database. It takes the data from the database and turns it into HTML pages. These pages are then sent back to the web server, which in turn serves them out to the web browser. The third tier is the database, which holds the information you want to make accessible via the Web.

screenshot

It is the goal of this document to help you decide what technologies to use in each of these tiers.

You have a very low volume web site, or you have a private Intranet site with a known amount of traffic.

If this is your situation, then you will be pleased to learn that 4th Dimension contains all three of these tiers in one application program (either 4D "Stand-Alone" or 4D Server). 4D has a built-in web server that can serve static HTML pages, images, PDF documents, etc. 4D also has built-in middleware. That is, it can parse HTML template files, replacing the embedded tags with data from the database. And, of course, 4D has its own built-in relational database engine, capable of storing and serving millions of records. Simply place a copy of 4th Dimension on a single computer and one application will handle all three tiers. However, this is a lot of work for any one application to perform. Therefore, this architecture is best suited for low-volume web sites or private Intranets.

You have a public internet site with moderate volume, or a private Intranet site that experiences unusually heavy traffic.

If you are designing an application that will have a moderate amount of traffic, you should consider splitting up the workload.

screenshot

In the above diagram, you now have two different computers. One computer sits outside the firewall and runs a web server. The other computer runs a copy of 4D or 4D Server, behind the firewall, safe from hacker attacks. The web server services requests for documents from the general public. It does the "grunt" work of serving static HTML pages, image files, PDF documents, and the like. The web server can also handle SSL encryption, securing sensitive data from prying eyes. This frees up 4D from the "brainless" jobs like sending out GIF files, allowing it to concentrate on servicing requests for dynamic data.

What web server should you use? On the Macintosh, the best choice is 4D WebSTAR, the #1 HTTP server for the Mac. Its popularity stems from its ease of use, and also from the large number of plug-ins that use the WebSTAR API. 4DConnect and 4DLink are plug-ins for WebSTAR that make connecting to 4D easy.

On Windows, the most popular web server is IIS (Internet Information Server), which is included with Windows NT/2000 Server. This is arguably the best web server for the Windows platform, owing to the high degree of integration with the Operating System. 4D supplies an ISAPI (Internet Server API) DLL (dynamically linked library) that allows IIS to communicate with 4D. The 4DISAPI.DLL will work with any Windows web server that supports ISAPI. 4D also supplies NPH-4DCGI.EXE, a CGI that can be used with Apache on Windows NT.

You have a high volume web site, or one that makes extensive use of dynamic pages.

If you have a really busy web site, or one that makes particularly heavy use of dynamically generated pages, you will probably want to go to a full-blown three-tier architecture.

screenshot

Here you see the middleware has been separated from the database. What is the middleware in this case? There are several options for middleware. The best option to use is 4D, since it provides the tightest integration with the 4D database while also providing excellent performance. Other options for middleware include Lasso (from BlueWorld Communications), ColdFusion (from Macromedia), and 4D JSP (Java Server Pages, requires a JSP engine such as Tomcat).

In the above diagram, you have three separate machines. Again, the machine running the web server sits outside the firewall, open to the public. The machine running your Middleware solution sits behind the firewall, receiving requests from the web server, and issuing requests to the database. The database sits on another computer, also behind the firewall, and is relegated to serving data.

I have an incredibly busy web site, and my three tier architecture is overloaded.

If you are fortunate enough to have a web site that is so busy you have swamped three separate computers, you can go from a three-tier architecture to an n-Tier architecture.

screenshot

In the diagram above, there are only two web servers, two middleware servers, and two database servers. Because this is an n-Tier architecture, though, you can actually have as many web, middleware, and database servers as you need to. You can also mix and match: you can use WebSTAR servers with Microsoft IIS Servers. You can use 4D as the middleware, but you can also use 4D and Lasso in the same site. If you have other databases such as Oracle, Microsoft SQL Server, or Sybase, they can all interoperate in this architecture. As you can see, the 4D Web Platform is very flexible and extensible.

There are so many choices! What do most people do?

Many people use 4D’s web capabilities only within their companies, on an Intranet or possibly on a password-protected public web site so employees outside the LAN can access the server. Many people who use 4D on the web fall into this category, and for them, a single machine running 4D or 4D Server may do the job nicely.

However, if you are going to be building a public web site, it is a very good idea to at least split off the web serving functions. This way, your web server can sit outside your firewall, serving out the static assets, doing encryption, etc.



Web Tutorials

» Web Server Scalability

International | Company | Contact 4D | Site Map | Privacy Policy | © 4D UK 1995-2008 | Change font size: [A] [A] [A] | Print this page