- Shopping Bag ( 0 items )
Written by some of the most respected ColdFusion developers around, this book is the only source for advanced the information needed by serious ColdFusion developers. From security issues and solutions to scripting the development environment, from fault-tolerance and load-balancing to distributed processing, from server sandbox deployment to intelligent agents, from writing language extensions to COM DCOM and CORBA integration, this book ...
Ships from: LIVERPOOL, United Kingdom
Usually ships in 1-2 business days
Ships from: acton, MA
Usually ships in 1-2 business days
Written by some of the most respected ColdFusion developers around, this book is the only source for advanced the information needed by serious ColdFusion developers. From security issues and solutions to scripting the development environment, from fault-tolerance and load-balancing to distributed processing, from server sandbox deployment to intelligent agents, from writing language extensions to COM DCOM and CORBA integration, this book contains a wealth of hard earned knowledge gained by years of real-world experience.
ww1.fatbrain.com/shop/quicksearch.cl?SearchFunction=key&qtext=078971809x">The ColdFusion 4.0 Web Application Construction Kit, Third Edition, this advanced reference to ColdFusion 4.0 takes the experienced ColdFusion programmer to new levels. Author Ben Forta begins this roller-coaster ride by teaching you to scale your server and set your security services. He expands on ColdFusion's extensibility by teaching you how to extend ColdFusion with Jscript, VBScript, CFML and Delphi APIs. Not for the weak or the merely proficient, this advanced version will make a master out of an expert.
Don't panic. The trick to solving your performance problem is to systematically analyze your site. Identify the individual components that make up your site, and examine them closely until you find the trouble spot-the bottleneck. After you find the bottleneck, you can either make that part of your site work better under load, or you can scale it-that is, add more server capacity to handle the extra stress caused by the traffic. This chapter will help you analyze your site for bottlenecks. The three chapters that follow will describe several ways you can scale your site, how ColdFusion can help you scale, and how to handle some of the challenges you'll face in building a ColdFusion site that has been scaled across multiple Web servers.
The terms I'm about to use and the model I'm going to present of Web server performance are not gospel. The model I'm using reflects my experience solving performance problems on many different Web sites, some with ColdFusion and some without and I'm confident that using this model will help you solve your own problems more quickly.
Your site's traffic is really just a series of requests. Answering a request uses some of your Web server's resources. Ibis is true for even the simplest Web hit-say, for a plain, old GIF file. When a user's browser requests that GIF, it takes server resources to listen for the request, acknowledge the request, allocate a HyperText Transfer Protocol (HTTP) server thread to handle the request, find the GIF file on disk, read the file, and pass the contents of the GIF back to the user's browser. As it happens, none of the steps required for handling a request for a GIF file take many resources, so well-written Web servers can handle very high numbers of requests for plain files. A request for a ColdFusion page is very different though, because it involves running ColdFusion Markup Language (CFML) code to produce a dynamic result If your CFML is complex, or if you're using all the other capabilities that make ColdFusion great - database calls, CFX tags, COM and CORBA objects, even additional HTTP requests with CFHTTP - a single ColdFusion page can become extremely resource-intensive.
When traffic is low, your site might receive only one request for a resource-intensive ColdFusion page at a time. If your server can devote its full attention to that one request, the response to the request is usually pretty fast, even if a lot of resources were consumed in generating the response. You see a performance problem only when traffic increases; because each request takes a lot of resources, your server can handle fewer resource-intensive requests at one time. As a result, your server takes more time to handle each request, and your site seems slower. And it gets worse. If a few resource-intensive requests are hogging your Web server's processing power, even simpler ColdFusion pages are slower to process. Resource-intensive pages can drag down your overall site performance even if they are only a small percentage of your total requests. When you have a situation like this, the piece of your system that is holding back overall performance is called a bottleneck.
Resource bottlenecks are not the only kinds of bottlenecks, but they are the type of bottleneck that you'll encounter most often with a ColdFusion Web site. They also are the type of bottleneck that scaling to multiple Web servers helps most directly.
N0TE: Another major source of bottlenecks is system limitations. If you are using a slow hard drive, the time that your server takes to read files could become a big bottleneck. Moving to faster SCSI drives, or even a RAID array, can help solve this bottleneck. If your Web server has to read large amounts of data from another machine on your network, you might need to move from 10BaseT to 100BaseT Ethernet connections. Because these bottlenecks are not Cold Fusion-specific, they're not addressed in this book, but you should examine all aspects of your site when analyzing a performance problem. If you don't, you could come to a very wrong conclusion. Jonathan once worked on a site that had a problem-users were constantly complaining that the site was too slow. After several weeks of poring over the source code to several dynamic parts of the site, the tech staff was at a loss. They hired a senior systems consultant to analyze the installation. The consultant quickly discovered that the system administrator hadn't installed several OS hotfixes related to networking. Installing the hotfixes increased the Web server's throughput by about 25 percent without changing any of the tech staffs code.
The Middleware Problem
I want to share a slightly uncomfortable truth with you: Middleware, defined as the application layer that sits behind a Web server and communicates with back-end services such as file systems, databases, and so on, has some built-in performance limitations that frequently require you to add more hardware than you might expect.
This problem is the result of a few different factors. First, most middleware (such as ColdFusion and ASP) is interpreted: To run your code, you just have to put it up on the site. You don't have a compilation step, such as for CFX tags programmed in C++ or Java servlets. An interpreted language is always slower than a compiled language; the interpreter (in this case, the ColdFusion service) is more resource-intensive because it has to keep the script interpreter in memory and use it frequently. With a compiled language, the interpretation happens at compile time, so the resulting DLL or executable doesn't have to devote resources to converting the code to machine language. The advantage of using interpreted languages is rapid development; writing C/C++ or Java code is much more time-consuming and is more difficult to change because you have to go back to the source code and recompile every time you want to make a change.
Middleware is also slow because it has to bridge the gaps between so many disparate systems. Web servers, file servers, and even database servers are much more "single-function" systems: They can focus on solving one problem very well and don't have to worry about the other pieces of the puzzle. These systems have been optimized to perform their single task extremely well. Middleware tools such as ColdFusion have to know how to speak with a multitude of different servers and protocols. It's a great advantage, but it carries a lot of overhead with it.
Finally, middleware is a very new segment of the software market. Commercial database servers such as Oracle, Sybase, and Microsoft SQL Server have been in development for years, constantly being tuned and tweaked for efficiency and speed. Middleware didn't really exist until early Web developers took a UNIX report-generating language (Perl) and started to use it to write CGI programs. ColdFusion's performance has improved with almost every release, and moving from ColdFusion 3. 1.1 to ColdFusion 4.0 will give you as much as a 30 to 40 percent performance enhancement. As the middleware market matures, products such as ColdFusion should improve until their performance characteristics are closer to that of database servers and other established server products.
Why does this matter? You need to attack your scalability problem with an understanding that your solution for a middleware product such as ColdFusion might seem less than elegant-buying more servers, changing functionality, even rewriting pieces of the site in CFX tags. If your boss gives you a problem, explain the middleware trade-offs reviewed here. If that approach doesn't work, sit with him or her for a few minutes and work out how much it would have cost if you wrote your entire ColdFusion application in raw C/C- code. I'm sure the exorbitant cost of such an effort will help your boss understand that a few thousand dollars for another ColdFusion server is a small price to pay in the grand scheme of things.
The best two places to find information about possible ColdFusion bottlenecks are the APPLICATION.LOG file and the Windows NT Performance Monitor. III talk briefly about the APPLICATION.LOG file and then focus on using the Performance Monitor (perfmon.exe) to watch your server's performance in real-time.
N0TE: Cold Fusion 4.0 uses different log files than ColdFusion 3.1.1 does. If you're using ColdFusion 3.1.1, look in the CFSERVER.LOG file instead of the APPLICATION.LOG file.
The first performance-problem error is a Request timed out message. This error is written if a ColdFusion page takes longer to process than the timeout value you set in the ColdFusion Administrator. If your server is experiencing performance problems, some pages take so long to process that they trigger this error. It's a pretty crude filter; if you set your timeout value to 20 seconds, you have no way to know if the pages that aren't timing out are taking 5 seconds or 15 seconds to process. If you're getting Request timed out errors for only a few specific ColdFusion pages, odds are that those pages are at least one cause for your performance problems. If your Request timed out errors are spread evenly across most or all of the pages on your site, you might have a single bottleneck that is affecting everything. Does every page on your site query the same database? If this isn't the case, then you're already a strong candidate for scaling.
You can set ColdFusion 4.0 to log information about requests that take longer than a certain time to run. This capability is a big step forward over ColdFusion 3.1.1 because you don't have to wait for a page to actually time out to see that it's running slow.
Another performance-problem error reports that your ColdFusion page is a "deadlock victim." This means that a collision occurred while trying to read data from your database. Because this error is very specific to the database you are running, I won't talk about it here other than to point out what it means.
You can analyze your APPLICATION.LOG files Manually, just by reading them. I also recommend Ben Forta's handy <CFX_VIEWCFLOG> tag, which parses an APPLICATION.LOG file and writes the results into a ColdFusion query result set, suitable for further processing in a ColdFusion template. At SmartMoney Interactive, the staff used Ben's tag as the foundation for an automatic APPLICATION.LOG parser that lets developers request reports with the full text or summaries of ColdFusion errors matching specific text patterns.
perfmon is located under Administrative Tools in your Start menu. When you open perfmon, you see an empty workspace, as shown in Figure 1.1.
(FIGURE 1.1: This Windows NT Performance Monitor is not currently monitoring anything.)...
|1||Monitoring Server Performance||9|
|2||Different Ways to Scale||25|
|3||Server Clustering Using Bright Tiger||41|
|4||Managing Client State||51|
|6||The User Authentication Framework||75|
|7||Securing Specific Features and Components||91|
|8||Integration with NOS Security||103|
|9||Creating Custom Tags||113|
|10||Writing CFX Tags in Visual C++||149|
|11||Writing CFX Tags in Delphi||197|
|12||Extending ColdFusion with COM/DCOM||219|
|13||Extending ColdFusion with CORBA||235|
|14||Customizing ColdFusion Studio||243|
|15||Scripting ColdFusion Studio||259|
|IV||Advanced Application Development|
|16||Using WDDX to Create Distributed Applications||277|
|17||Advanced WDDX Integration||355|
|19||Structured Error and Retry Handling||457|
|21||Intelligent Agents and Distributed Processing||483|
|22||Interacting with the System Registry||507|
|A||ColdFusion Tag Reference||519|
|B||ColdFusion Function Reference||603|
|C||VTML and WIZML Language Reference||673|
|D||The WDDX.DTD File||697|
In this chapter
What Is Cluster Cats for ColdFusion Application Server 4?
Included with the Enterprise version of ColdFusion is Cluster Cats by Bright Tiger Software. A software-based load-balancing solution, Cluster Cats monitors your ColdFusion Application Server (CFAS) and can redirect requests away from a server that is beginning to enter a "busy" state. Note that Cluster Cats does not work on the network layer. When Cluster Cats redirects requests to another server, it does so by redirecting to the URL of another machine in the cluster. This means that if your server is completely out of commission (that is, not turned on), Cluster Cats cannot communicate with it and therefore cannot redirect requests away from it.
Perhaps the most attractive thing about using Cluster Cats for your load-balancing solution is its integration with the CFAS. Because Cluster Cats responds to elements of the CFAS, you get load balancing that is specific to your ColdFusion-based application. You get this benefit in addition to general failover and machine alerts.
An important point to note about Cluster Cats is that the version shipping with CFAS 4 does not include support for replication; however, the full version of Cluster Cats, available from Bright Tiger, does have replication built in. Replication is the ability to put your ColdFusion scripts on one machine in your cluster and have those scripts update on all machines in the cluster. Many administrators overlook replication when planning their load-balancing strategy. However, as code bases grow, and server architectures get more complex, replication plays a crucial role in content synchronization. Later this chapter outlines some simple strategies to include replication from the onset, and thus keep your job as server administrator manageable as your server cluster grows.
Understanding Cluster Cats
As you have learned in the preceding two chapters, many different methods for clustering servers are available. In particular, the methodologies employed in software-based clustering differ greatly. This fact will most definitely have an impact on how your server cluster serves your application. This section will give you a broad overview of the methodologies employed in Cluster Cats.
To begin, you need to note that Cluster Cats uses HTTP redirection to balance load across a cluster. Although, in general, this is a protocol-based redirection, it lacks certain network-level controls; therefore, I place it in the application layer of the networking hierarchy. In contrast, another popular software-based clustering strategy, Convoy Cluster (acquired by Microsoft in August 1998), attempts to use the network layer by advertising multicast MAC addresses to routing equipment. Because this discussion is about Cluster Cats, I will not go into the details of multicast MAC addressing. However, suffice it to say that Convoy makes your cluster look like one big IP address (see Figure 3.1), whereas Cluster Cats makes your cluster look like a lot of HTTP servers grouped together (see Figure 3.2). Depending on your situation, one approach may be better than the other, but they both do the same job.
Now, take a look at the components of Cluster Cats. The software works with two primary components: the Server component and the Explorer component. Each plays a critical role in the configuration and support of your Cluster Cats clusters. Note that although you can have a cluster consisting of a mix of Sun Solaris and Windows NT-based servers running Cluster Cats, you must have at least one Windows NT server to run the Cluster Cats Explorer. You cannot configure your cluster without the Explorer component.
Cluster Cats Server
The Cluster Cats Server component runs on Windows NT 4.0 and Sun Solaris. This Server component is the heart of the cluster. It controls configuration of a machine's role in a particular cluster, handles redirection from the server in the event that load thresholds are breached, and controls access to the server based on restriction rules. The Server component must reside on all machines you are using for your cluster operations.
Cluster Cats Explorer
The Cluster Cats Explorer component runs only on Windows NT 4.0. It controls configuration of Cluster Cats clusters. I found that it was best to configure the server that the Explorer sits on as the primary server for all your incoming HTTP requests. I like to call it the "Controller Server." Its purpose is to handle all the incoming HTTP requests first and then redirect to other machines in the cluster as needed.
Tasks handled by the Cluster Cats Explorer include the following:How Cluster Cats Works
As mentioned previously, Cluster Cats uses HTTP redirection as its principal methodology for distributing load across a cluster. This means that the user's request is sent to another machine in the cluster and stays there until that machine needs to redirect the request to yet another machine.
For example, if a request comes to www.yourcompany.com, and www is too busy to handle new requests, it sends that request to www2 (or another machine based on availability of all machines in the cluster). The URL in the browser location box now reads www2.yourcompany.com (refer to Figure 3.1). Therefore, subsequent requests will go to www2 until that machine cannot accept more requests. At that point, www2 will attempt to redirect the request to another machine based on the information it has about other machine availability.
Let me contrast this shortcoming of Cluster Cats in the CFAS 4 implementation: If your server is up and running, and you just want to take it out of the cluster for a while for maintenance, you can restrict that server. Restricting a server in a Cluster Cats cluster causes all requests to that server to be sent to other machines automatically.
Say that you have a ColdFusion application that needs to be clustered across two ColdFusion application servers. This application does not use session variables but instead employs a "cluster neutral" method of saving state: client cookies. The name of the Web site you are clustering is www.mycompany.com, and you will be using machines www1.mycompany.com and www2.mycompany.com in the configuration.
To provide two layers of load balancing, you can employ round-robin DNS in addition to Cluster Cats. By doing so, you can distribute general requests to both servers in the cluster. In this configuration, you can keep all load from initially being directed at one machine and better use resources. Although this result may seem inconsequential in the context of what's being described, it will have an impact on what you set in the load threshold level section of each cluster member.
Creating Your Application Cluster
Begin by installing the integrated Cluster Cats software included with ColdFusion 4 on both machines. If you are using Windows NT on both machines, the setup routine installs the Cluster Cats Explorer. In this example, you will use the Cluster Cats Explorer only on www1.mycompany.com.
After you install the software, you will see a new service (in addition to the ColdFusion 4 services) named Bright Tiger Server service in the Service Control Manager. It must be set to Automatic and should be running so that Cluster Cats can work properly. You should always check the Service Control Panel after a significant installation. Doing so helps you understand the components of your server application.
From the www1.mycompany.com console, open the Cluster Cats Explorer. Your screen should look like Figure 3.1.
Right-click the Cluster Manager icon in the left pane of the Cluster Cats Explorer. You then see a dialog box that looks like the one in Figure 3.3.
You need to enter the Cluster Name (see the following sidebar), the Server Name, which is the name of the primary server in your cluster, and the License Key included in your ColdFusion 4 Administrator Guide. Be sure to enter the Fully Qualified Host Name of the first machine in your cluster in the Server Name box. In the example, you would enter www1.mycompany.com.
Creating Cluster Members
Naming, and Why It Is Important
After you create your initial cluster member from the Create New Cluster dialog box, you can add other cluster members by right-clicking on your cluster name, choosing New, and then selecting Cluster Member. In the resulting dialog box (see Figure 3.4), enter the Fully Qualified Host Name. In the example, you would enter www2.mycompany.com.
At this point, you should have two servers listed in the Cluster Cats for ColdFusion Explorer. Cluster Cats might take a few seconds to connect to the servers in your cluster, depending on the size of your cluster or network load. I found this process to be uneventful, and after the cluster is synchronized, it does not have an impact on performance at all. Figure 3.5 shows an example of a cluster in use at my company.Setting Load Threshold Levels
You can set each server in your cluster to respond to two load thresholds:
Load Threshold is the top level you allow your server to accept before it enters a busy state. When this situation occurs, Cluster Cats begins redirecting requests to other servers in the cluster based on their availability. Cluster Cats continues redirecting requests until the actual machine load dips beneath this line.
Gradual Redirection Threshold defines a secondary threshold at which user requests start being redirected. As the name implies, if the Gradual Redirection Threshold is reached, Cluster Cats redirects a portion of the load--but not all of the load--to available machines in the cluster. The Gradual Redirection Threshold and the Load Threshold work together to provide a smooth transition of load (see Figure 3.6).
Replication: Keeping Your Content in Sync
Unfortunately, the replication features built into the Bright Tiger implementation of Cluster Cats are not included in the version shipping with CFAS 4. Replication is a mechanism employed to keep content on all your servers in sync with a central source. Anyone who runs multiple Web servers, grouped in a cluster, needs to be able to replicate content. Fortunately, many shareware and freeware utilities are available to help you synchronize your content. I like to use a utility named Robocopy from the Windows NT Resource Kit.
Sample Replication Strategy Using Robocopy
Robocopy and AT (the Windows NT Scheduler service) can combine to be a very effective replication strategy. Robocopy copies only changed files from a central source to target sources. It has an extremely large number of switches that allow you to customize your synchronization rules. Because Robocopy is a command-line utility, you can script fairly elaborate interactions with file systems using UNC names and the program's switches. To use Robocopy, you must have the Windows NT Resource Kit. The following is an example of a Robocopy script I use to replicate content to another Web server and backup RAID drive. Note that I also use the command-line utility called blat to send an email of the Robocopy log back to a central administration desk. If you are writing scripts like these, you would be wise to include some contact information at the top; this way, if your script fails, systems staff know whom they should contact.cls echo off echo ********************************************************** echo *****This is a G. Triad Automated Maintenance Script ***** echo *****Report Problems to email@example.com ***** echo *****or 908-497-0510 ***** echo ********************************************************** del C:\temp\latest2Repl.txt del C:\temp\latest3Repl.txt echo Replication to Server 2 Initiated.....working.... robocopy D:\Inetpub\wwwroot\ \\Server2\90195 /E /PURGE >> C:\Temp\latest2Repl.txt echo Replication to Server2 completed. echo Replication to Server3 Initiated.... (BackingUp).... robocopy D:\Inetpub\wwwroot\ \\Server3\90195 /E /PURGE >> C:\Temp\latest3Repl.txt echo Replication to Server3 completed. echo Notifying central administration........ blat C:\temp\latest2Repl.txt -s "[MAINT] Server2 Replication Completed" -t firstname.lastname@example.org blat C:\temp\latest3Repl.txt -s "[MAINT] Server3 Replication Completed" -t email@example.com echo Notification Completed. Strategies for Clustering with Cluster Cats
Because Cluster Cats works on the HTTP level, you can easily layer load-balancing strategies on top of the system. Combining hardware-based load balancing or round-robin DNS with Cluster Cats creates a two-tiered solution that can be configured in numerous detailed ways. Cluster Cats also provides a means for dealing with Web applications that require use of ColdFusion's session variables.
Dealing with Client State in Cluster Cats
CFAS 4 uses certain types of client state variables that are written into the memory of a Web server. They are known as session and application variables. These variables apply to a user's session or globally to an application defined with the CFAPPLICATION tag.
Obviously, if a user's session is reliant on persistent variables stored on a particular server in your cluster, you have to keep the user on the same server. If the ColdFusion application you are clustering requires that you not redirect users after they initially access a Web server, you can enable session-aware clustering. Do so by right-clicking the cluster you want to enable it for, selecting Configure, and selecting Administration (see Figure 3.7).
Selecting this option simply keeps users confined to the same server after they initially hit the server. No redirections are performed.
Using Round-Robin DNS
Round-robin DNS (RRDNS), as you learned in Chapter 1, "Monitoring Server Performance," alternates requests from Web server to Web server based on entries found in your DNS server. In the example here, if you want to set up your cluster for RRDNS, you would enter two entries for the www machine: one pointing to www1.mycompany.com and another pointing to www2.mycompany.com. Thus, resolution requests for www.mycompany.com would alternate between the two servers in the cluster.
The big problem with RRDNS has been that if you have to take a server offline, every other new request to www.mycompany.com will hit a dead machine. With Cluster Cats, you can simply put that machine into a busy state and redirect requests. This type of general failover is included in the version of Cluster Cats shipping with CFAS 4.
Layering RRDNS on top of Cluster Cats provides a wider spread of load to your cluster. Whereas RRDNS never truly provides a true balance, Cluster Cats can help make that balance a little smoother by redirecting requests based on machine load. This load can then be controlled by the Load and Gradual Redirection Thresholds.
Posted November 25, 2000
It taught me everything I know about cold fusion in just a few days. A complete reference for all the basic and a few of the advanced features of cold fusion. By far the best documentation on the subject.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted April 6, 2000
This book covers many advanced topics. WDDX is one of them as writer went deep into this technology. You will also find some good information on custom tags. You will really get disappointed if you try to find information on COM and CORBA. I think write should either include more information or should not present these topics just to fill some pages. Overall this book has worth and a must to buy.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.