Troubleshooting Sitecore performance and optimization

Most of us might have faced issues with performance and slow Sitecore instance,I would like to share my experience with Sitecore troubleshooting which I have learned over the period of time, these are some of the things which I feel should be checked whenever we see the application has really some performance issues.

Trust Building:
This is one of the key factor of healthy business relation, we should make sure that application/business always meets users expectation, a non performing(from performance standpoint) site can’t guarantee a high ROI.

Here are few things i would like to mention to check the slow performing Sitecore site, and what can be done to fix it.

  1. Logs Reviews: 
    1. This is one of the wonderful feature which is shipped with Sitecore, and we should make use of it to check the performance of the application, regularly checking the logs can help us in fixing the issue well before in time before it becomes critical.
    2. Logs can give us most of the details which includes:
      1. Publishing details.
      2. Schedule task running.
      3. Any code error issue.
      4. Indexing or query issue.
      5. Issue with  MongoDB connectivity.
      6. Issue with SOLR server connectivity.
      7. Issue with SQL server connectivity
    3. Above are some of the details which we can review and proceed our investigation, it’s always better to have something in hand to troubleshoot, instead of randomly looking for something.
  2. Enable JS,CSS Compression:
    1. This helps in boosting the performance of application, by reducing page request to server or browsing the pages.
    2. We can make use of static and dynamic content compression in IIS.compression
  3. Sitecore Debugging:
    1. We should make use of Sitecore debugger tool which can be found in Page editor, this gives a very good understanding and statistics around different components being used in the page.
    2. Helps in understanding which specific component(sublayout/rendering) takes how much time to render on the page.
    3. One of the early troubleshooting which every developer should start doing right from the time we start experiencing performance issue in local development environment.
    4. This tools helps in narrowing down the problem with code,and thus helps in putting all our energy and time in right spot.sitecoredebugsitecoredebugprofile
  4. Sitecore Schedule tasks:
    1. Always try to review the Sitecore schedule tasks, and see if there is any task which is running and which is not expected?
    2. Make sure to review all the agents which is present under <agents> section, in web.config or using custom patch(if used).
    3. Another thing to note, we should also consider updating the frequency of that task execution by updating the time,if schedule task is not required we should disable it.
    4. See if the schedule task is triggering site full publish, this can be a serious issue in production environment,as this can clear all cache which can slow down the site.
    5. Keep close watch on the logs for anything related to schedules tasks.
  5. Indexing Strategy:
    1. Revisit the indexing strategy which is being used in the application, see if the full index rebuild is in place for any item publish event.
    2. Try to update the strategy if it’s not as per the requirement, or if it’s over killing.
    3. Please review this document for anything related to available indexing strategy-  https://doc.sitecore.net/sitecore_experience_platform/setting_up_and_maintaining/search_and_indexing/indexing/index_update_strategies
  6. Image optimization:
    1. I have seen this issue with several applications, just because the images are not properly optimized, they end up taking more resource bandwidth and resulting poor user experience.
    2. Remember, this is the time of mobile, and any poor performing mobile site can be a serious issue to client.
    3. We should always train and educate our client and content authors to make use of optimized images, and trust me they will listen to you.
  7. Indexes:
    1. This is one of the critical and important part of any Sitecore application, try to use indexes as much as possible when it comes to fetching details from the repository or searching of the items based on specific condition and filters.
    2. Try to perform all the operation directly in the query like:
      1. Pagination.
      2. Sorting
      3. Filters
    3. Avoid fetching all the results and then applying business rules to filter it based on specific condition, as I mentioned try to do most of the processing directly in query level.
    4. I had seen issues in application which was not performing well, just because of not making true use of indexes,review you index definition and configuration,and see if it has everything which is expected for it.
    5. Try to use create and use custom indexes for any custom feature, it’s always better to have one.
    6. Use of computed fields can be considered, this helps in executing any complex business logic while querying the results.
  8. Site publish:
    1. We should not trigger complete site publish in production environment,unless and until it’s very much required, this can be a costly operation, as this clears all the cache.
    2. Try to publish only areas which are required, we can trigger full site publish in development environment, but should be done carefully in production.
    3. Use Smart or Incremental Publish.
  9. Caching:
    1. Configure sublayout(s) and rendering(s) to use caching, this can give a real good browsing experience to site users.
    2. Clearing cache is something which should be considered in production environment, when trying to publish items this will clear the cache and can slow down the application performance.
  10. GetDescendants:
    1. Use of GetDescendants is one of the costliest operation we can think off, we should always try using indexes or fast queries if possible and required.
    2. Revisit your code and search if there is any reference to GetDescendants, and update it if required.
  11. No of Items under one node:
    1. Try not to have more items under single node/item, and break it down using several sub folders or items.
    2. This helps in giving good content editor experience.
    3. make use of item buckets wherever applicable.

Few important things to follow:

  1. Write good code.
  2. Proper unit testing.
  3. Get your code reviewed.
  4. Follow best practices.

This helps in fixing some of the issues before it goes to QA.

Please also refer Sitecore recommendation for performance optimization : https://sdn.sitecore.net/Articles/Administration/Sitecore%20Performance/Optimizing%20Sitecore%206%20and%20later/Optimizing%20Performance%20in%20Sitecore.aspx

I hope this helps someone in troubleshooting Sitecore performance issues, please let me know if you have any questions or comments, happy to discuss.

Happy learning 🙂