Why ColdFusion & Railo are not suited to shared hosting

ColdFusion , Railo Add comments

This is a topic I have found myself explain quite often of late and one thing I can say with absolutely certainly from dealing with hundreds of developers of all levels over the years, from newbs to gurus, is that most devs in general do not really understand how things work on the server (they know how to write code and upload it to the server) and most CF devs additionally don’t understand how ColdFusion really works and how/why it differs from other scripting languages like PHP or Perl or ASP.net, so I decided it was time to write a complete blog post on the subject and hopefully to try and enlighten some of those develoeprs a bit more.

Now I have heard many say "I am just a developer, it is my job to write code, not to understand the server stuff", but i'm afraid I disagree with this and consider it a bit of a cop out, because If you don't understand how things work on the server to at least some degree, how can you be sure you are writing code that is going to be scalable, reliable and is not going to cause problems? Sure no-one should expect you to know EVERYTHING to the same level as a sysadmin, but you certainly should know the basics that are relevant to your job, especially if you are going to be making any hosting recommendations to your clients.

The first thing to understand, is that ColdFusion and Railo are not technically application servers (which most people believe them to be), they are simply Java applications (that convert CFML into Java bytecode) that run inside a java servlet container (e.g. Apache tomcat, Jetty, Jboss) which runs as a service/daemon, and all requests for all pages coming into the server go through that same service/daemon. This means that any problems with that service affect ALL CFML (or JSP)  websites on the server.
This is also a bad thing for security because it means that all sites on the server run within the security context of the service and so cannot have their own permissions. So any java code in any site can access files in site2, site3 or any other site on the server or in fact any part of the system that the service itself has access to. The only way round this is to use security sandboxes, which is a feature of ColdFusion enterprise and Railo.
But BEWARE, CF sandboxes can provide a false sense of security, they are only applied to CFML code and do not sandbox Java, so if you drop any Java code in your CFML pages (using CreateOnject(java), then you bypass the sandbox completely, so they not stop any vaguely competent coder/hacker. There is no way round this on a shared server, you simply have to take the risk. On a dedicated VPS you can mitigate this by using multiple instances of CF/Tomcat and isolating each site using server side permissions.

Before you say “so hosts shouldn't allow Java”, this also is not even an option for any host as all moden frameworks and apps need createObject(java), so disabling this function would break almost every modern application, ergo it is a risk that has to be taken, because at the end of the day 99% of clients simply don't care about the security risks, all they see is that their app doesn't work and will just go elsewhere.

When we look at other common languages such as PHP, Perl, asp.net etc, these run as an ISAPI or CGI process, so every website on the server spawns its own process to handle the requests. So if there are 20 PHP sites then there are 20 x PHP processes running (think of this like 20 instances of ColdFusion). The process runs within the security context of the website that spawned it, so in the case of Windows it runs under the application pool identity. So this means that as long as you have every website/application pool  set to run under a different user account with access only to that website root, and so will php also have only this permissions, so it is more secure and also isolates each site in a separate process.
So if site1 crashes php or ASP, it will have no effect on any other site because they are running php/ASP in a separate process.

Here is a diagram to illustrate.

 

cf server diagram

 

This is the primary reason why CFML is not suited to shared hosting, no application isolation and no control over security.

Imagine the following (very common) scenario.

abc.com makes a cfhttp request to an external web service at xyz.com  to get syndicated content for its pages.
The web service at xyz.com goes down, which means all the pages on abc.com are now going to timeout. On a shared server this will very quickly result in all the ColdFusion max number of simultaneous requests to be consumed, and subsequent requests to then become queued. The result of this is that every other CFML site on the server now becomes slow as well as all their page requests have become queued behind the problematic site, and now are likely to also timeout as a result.

An even worse scenario is where native java requests are concerned, such as database queries as these cannot be killed automatically, not even with FusionReactor. If a page hangs in the middle of a database query because it is waiting for a response back from the db server, then this request will not ever timeout and will hang indefinitely, thus 1 cf thread is now no longer available. If this happens 10 times, now 10 cf threads are gone and no longer available, if your “max number of simultaneous  requests” is set to 10, then you now have 0 requests left and your server will stop serving up CFML and all websites will now hang/timeout untill the service is restarted.
If the original problem still exists then restarting CF also will not help, as the issue will simply continue until all the requests are again used up and all sites start to hang. The only solution at this point is to turn off the site causing the problem.

Then we have the security issues that I mentioned. Everyone by now is aware of the CFIDE hack which affected many cf servers. This was only possible because CF runs as service and because that service runs under the SYSTEM account by default, which has full file system access, which allowed the uploaded hack to access every part of the server. If CF worked like a CGI/ISAPI application, the effect of this hack would have been far less.

But my code has proper error trapping and caching and stuff, so this doesn’t affect me right ?

Wrong i’m afraid, on a shared server it doesn’t matter how brilliant your code is, or how well your have performance tested it, or how much error trapping you have, this does not stop the other sites on the server from causing you problems.
You could be lucky on a shared host for months or even years if you are on a server that doesn’t have many sites, or simple  sites that are not problematic (at the moment), but It only takes one poorly written app to bring CF to its knees.
It is also important to realise that almost nobody using shared hosting has ever done any kind of load testing or performance testing on their website and in most cases do not even know what this means or how to do it, the result of this is that web site owners have no idea how their site will perform under load nor did the developer who made it. This results in another very common scenario which usually begins with a statement like “Nothing has changed on my site and it has been running fine for years, so it must be your server”.
Again this is totally irrelevant in most cases, sure your site may well have been running fine for years with 20-50  visitors per day, but what happens when it suddenly gets 1000 visitors per day as a result of some marketing or media attention, or if it starts getting hit by search engine bots, suddenly this once stable site falls over horribly due to poorly written or legacy code.

But Railo is better right ?

Ultimately no i’m afraid, as Railo works the same way as CF so the primary issues mentioned above apply to Railo as well.

Railo is however an improvement in that the security sandboxing is automatically applied at website context root level (if you set this in your Railo server admin) and does not require admins to setup sandboxes for each site as with ColdFusion which is a sandboxing nightmare, which makes Railo better for shared hosting. However the sandboxes like ColdFusion's only sandbox CFML and can easily be overridden with Java code.
Railo also has its per site web admin allowing all users to admin their own site, which is again a bit improvement over ColdFusion which has a single Admin which must be administered by the host.
So by using Railo you don’t have to rely on your host, you can pretty much do everything yourself.

So what’s the solution ?

The only solution is to do some research, educate yourself and use a bit of common sense.
ColdFusion is intended to be an enterprise solution, and thus run on dedicated hosting solutions, it was never intended to be used for shared hosting and is not built to do this. So the simple answer is, use the right tool for the job.
If you just want to run a blog, personal website or simple brochure ware website and you don’t have your own server and only have the budget for shared hosting but do not want to be affected by the above problems, then use a technology more suited to this purpose, one that runs as a CGI/ISAPI process, the most popular of course being  PHP or ASP.net . Avoid any Java related choices as these will all suffer from the same issues.

If you love CFML and want to use it for everything you do, then do yourself a favour and get a VPS running Railo (or ColdFusion if you can afford it).
On your own VPS you then also have the option to use multiple CF instances, so each of your sites runs on a dedicated instance of Tomcat or whatever is your java servlet container of choice, so you can still run multiple sites but avoid the shared hosting scenario and also lock down the security.

I am going to use shared hosting anyway regardless, what do you suggest ?

If you really have no choice (or simply won’t take good advice), then here are some tips on choosing a host.

  • Choose a host that specialises in Railo or ColdFusion and actually knows what they are doing, do not choose a generic host that simply has Railo/CF installed and classes this as SUPPORTED.
  • Test your hosts knowledge, see how much they know about CF/Railo, ask to speak to a CF specialist.
  • Make sure your host is secure
    • For ColdFusion they should be using enterprise edition, otherwise no sandboxes, and no security. If they are running standard edition, avoid.
    • Ask them if they run a bog standard out of the box CF installation, if yes then it is not locked down and is not secure.
    • Ask them if they use FusionReactor or HackMyCF. Preferably go with someone who says yes.
    • Ask them if they use security sandboxes, if no then avoid.
  • Ask your host how many sites they run on each CF server. Too many = bad
  • If you regularly need to setup data sources, mappings or anything that requires access to the CF Admin, you would be better of with Railo
  • Ask if you can get RDS access, if they say yes avoid, as this should not be enabled in production
  • Check if you can access the cfadmin or adminapi from your site, is yes, change host now.

Unfortunately there are very few noteworthy CF hosts these days, the ones I see most commonly recommended are Viviotech, Hostek, HostMySite (although not so much since they got taken over by hosting.com), BlueThunder (my company)

11 responses to “Why ColdFusion & Railo are not suited to shared hosting”

  1. Jake Munson Says:
    Very informative post, thanks Russ.

    You mention that one poorly written app on a CF shared server will bring CF to it's knees and all the other sites with it. That's true, but couldn't the same thing happen with PHP, if a bad site chews up all of the server's resources? Yes, PHP should be safer in general because of the true isolation, but in your scenario (of a poorly written site) PHP sites could hose other sites on the server just as bad as on CF. Unless the server admins have the ability to throttle each individual PHP site...then you'd be safe, assuming they know what they're doing. ;)
  2. Russ Michaels Says:
    Jake, I can only really speak for Windows as I am a Windows admin.
    But no, PHP cannot hose the server and other sites like CF can.
    The application pool throttles how much memory each process can use, and will recycle if it exceeds this, and can be tuned on a per site basis. when an application pool is recycled it kills any running processes.
    So a runaway php process will usually only kill the site it is running on.
  3. Jake Munson Says:
    By Application Pools, you mean in IIS right? I'm assuming that most PHP sites are on Apache, not to mention Linux instead of Windows. But if IIS can do that, I'm sure Apache/Linux can do it 10 times better! ;)
  4. Russ Michaels Says:
    yes that is an IIS thing. I'm afraid your a bit out of date about regarding Apache, that hasn't been true since Windows 2000 (IIS 5). IIS 6 was about on par with Apache, since IIS 7 I would say it is far superior, there is also a plugin called Helicon APE that will emulate apache's .htaccess so that sites written for Apache will run on IIS.
  5. Brad Wood Says:
    Well-written article. Thanks for the info.
  6. Russ Michaels Says:
    Thanks Brad, and without any disagreement too :)
  7. Ben Nadel Says:
    Very interesting stuff. I'm definitely a "code" person that is trying to learn more about managing servers. It's slowly starting to sink in, to articles like this are very helpful.
  8. Matt Robertson Says:
    Excellent article. I moved away from shared hosting many years ago and took the plunge with respect to figuring out how to run dedicated servers myself. Just for starters when you are running your own servers, you keep all the hosting fees from your clients. Couple that to the fact that only your own code is running on the server and you wind up with a level of stability that cannot be matched by any shared host. I'd never go back to shared hosting, from a profit/loss standpoint and the very important standpoint of rock solid server stability.
  9. Gary Stanton Says:
    Great article Russ, nice to have it all laid out simply like this. These are lessons I've learned the hard way over the years!

    I'm still somewhere in the middle on the 'developer vs sysadmin' argument though. I accept that CF is intended as enterprise software, but I still think the level of understanding required to effectively administer a CF app is more of a barrier to entry than it could be.
    Installers have come a long way in recent years, especially for Railo, but perhaps if they were geared more toward the separate instance per site concept, inexperienced developers might be in a better position?

    Of course, there's no excuse for shared hosting these days, but administering a server instance is a daunting task for many. It's a shame the anti Windows lobby is so pervasive, as it's a much easier server to get to grips with and keep secure, in my opinion.
  10. Gary Rodwell Says:
    Thank god I found this article. Excellent write up.
    My webhost also recommended me to purchase a VPS instead of a shared account, but your article helped me to finally make a decision towards VPS.
    Great work.
  11. John Says:
    HostMySite wasn't taken over by Hosting, HostMySite bought out Hosting. They overload their servers at about 200-300+ websites with low-powered single core 2GB Windows 2008 boxes. Don't use them.

Leave a Reply

Leave this field empty

Powered by Mango Blog. Design and Icons by N.Design Studio