Saturday, November 16, 2013

Make Coldfusion 1000 Times Faster

Here is a well kept secret to make Coldfusion runs 1000 times faster: make your initial implementation 1000 time SLOWER.

Kidding aside, here are some performance tips:

  • Clean up debug code, especially CFDUMP. I have a production server that runs a query for 14 minutes, turns out a CFDUMP for debugging purpose is left behind. After it's removed, the query only took less than 5 seconds to finish;
  • JSON serialization is not as fast as you wished. I have a query that took 1 second to get result from SQL server, but then it took about 10 seconds to serialize the result to JSON string;
  • Similarly WDDX, SOAP could take significant amount of time to serialize large object;
  • Use AMF binary communication if possible (at least if you use Flex, or Coldfusion to Coldfusion communication, do give AMF some serious consideration). Moving from SOAP webservice call to AMF have make our response time order of magnitude faster;
  • Other usual suspects that are applicable to many other programming languages: loop, nested loop, multiply vs. divide, ...
  • Profiling: I was not able to find a good profiling tool for Coldfusion, so end up roll my own hand coded profiler. It's a little cumbersome, requires manually insert check points to collect performance statistics. Never the less, it helps in quickly identify bottlenecks;
  • Caching: turn on caching in Coldfusion is very easy. So, whenever it make sense, do turn on query caching, page caching, ... This often can be a 10 second job that improves performance by 100 times;
  • Coldfusion Admin: trusted cache, disable debugging
  • Always use fully qualified variable names to save scope lookup time;
  • Application.cfc: double check, triple check this file, because any performance issue here will affect ALL the pages of your website;
  • use cfqueryparam instead of text in cfquery;
  • Fine tune JVM parameters
  • Hardware: CPU, RAM, network, and Disk (again measure and identify bottleneck, before purchase any expensive upgrades)
  • Scale out: use load-balancer to distribute work load
  • Last but not least: make sure your SQL queries are all in good shape. Often times, Coldfusion server itself is not the bottleneck, your SQL server is;

No comments: