Copy link to clipboard
Copied
We're currently having a 'discussion' in the office about components.
Some people here swear up and down not to use cf components on high volume sites due to the initiation overhead. Instead they think that using CFHTTP is the way to go.
Others say that cf components are fine to use on high volume sites, if written correctly.
What is the best practice?
Thanks
Copy link to clipboard
Copied
The issue is a bit of a non-sequitur to me. It's like saying "which is better: a car or a washing machine?" They're both machines, but they do completely different things.
A component is an implementation of the OO concept of objects. CFHTTP is for making HTTP requests. Two different things.
If it's even possible to make a sensible performance comparison, CFHTTP is almost certainly going to be slower because it needs to make an HTTP request which has a bunch of network overhead, whereas instantiating a CFC is all done in memory (with an initial file system hit if it's the first time the CFC is used).
CFCs are not as performant as simple <cfinclude> calls, or probably even <cfmodule> calls / custom tag calls, which would be more sensible performance comparisons to make. However the performance consideration is trivial compared to more likely performance considerations like poorly written code, DB and other external system calls... and... err... stuff like <cfhttp> calls...
The application architecture benefits of using CFCs greatly outweigh any performance considerations they might have.
--
Adam
Copy link to clipboard
Copied
Theoretically speaking, if following strict OO concepts causes your server to crash on a regular basis, then those concepts should not be followed in the language you are using for that application. However, I have never had this issue with CF, so that is a mute point. I also agree with you in everything else you say.
If the common code resides on seperate machines, can CFCs be used across the network?
Thanks....
Copy link to clipboard
Copied
SpiderFromMars wrote:
If the common code resides on seperate machines, can CFCs be used across the network?
Thanks....
As long as the machine calling the CFC can access that network locations in some manner. This will involve changing the user permissions that ColdFusion runs under from the default "LocalSystem" that does not have network permissions, at least on Windows versions of ColdFusion.
Copy link to clipboard
Copied
Regarding:
If the common code resides on seperate machines, can CFCs be used across the network?
In addition to Ian's answer, you can always call them as webservices.
Copy link to clipboard
Copied
Theoretically speaking, if following strict OO concepts causes your server to crash on a regular basis, then those concepts should not be followed in the language you are using for that application.
Theoretically speaking, following strict OO concepts prevents your server from crashing on a regular basis.
Copy link to clipboard
Copied
Others say that cf components are fine to use on high volume sites, if written correctly.
What is the best practice?
The best practice is to write CFCs correctly and to use them, wherever possible, on every Coldfusion web site. Why every? It is best practice to use the commonest CFC of all, Application.cfc.
Copy link to clipboard
Copied
What is the best practice?
Of all? Read up on the subject.