I’ve been working on fine tuning Pepper performance for quite some time and the biggest bottleneck always seems to be the underlying Alfresco repository. From time to time, my associates and I have dug under the covers of Alfresco to analyze, optimize and work-around in order to squeeze every reasonable ounce of performance out of the system. We have found that there are two areas that have really caused a drag on user experience. One of these is workflow on Alfresco’s WCM/AVM repository, and the second is search operations. Workflow will not be covered in this article. Instead, I will focus on optimizing search, or more precisely, any operations that return a moderately large set of results.
Breaking it down
Pepper communicates with an Alfresco repository via web service calls (either Alfresco Web Scripts or the new CMIS API). We found that some searches were taking particularly long. We tested to see whether it was the complexity of the search that caused the slowness, but it turned out that search complexity has almost no affect on performance with Alfresco. What we did find to make the biggest difference is the number of results returned. In fact, the time it takes to perform a search is linearly proportional to the number of results. This is universally true for both AVM and DM repositories.
Digging deeper, we discovered that after Alfresco determines what nodes should be returned in the result set, it fetches each node with it’s properties one by one from the database. Not only is this a lot of database calls, but these turn out to be somewhat expensive calls in order to join the correct tables and get all the property values. To make matters worse, an additional call is made for each result in order to check for read permission. This call is similarly expensive.
What can be done?
In AVM land…
For AVM, we found the biggest improvements by simply turning off the security system for Alfresco. This eliminated half the database calls and made the searches almost twice as fast. Of course, disabling security is not an option for many of our clients. Some other small gains were achieved by rewriting our Alfresco Web Scripts for search to use Java instead of JavaScript backing and streamlining it to hit lower APIs, but this only helped by 10 to 25%.