Application Performance
When building a CommCare application, especially one that will manage large case loads, performance management is crucial. It’s important to think through how you design and build your application to ensure that you are building in a way that sets your application and users up for success.
Here’s a guide to help you optimize your application for efficient performance:
1. Understand Your Case Load
Estimate Case Volume: Determine the number of cases your application will handle over time. Consider factors such as the number of users, frequency of data collection, and expected case growth. Don’t just think about today-- think about how much you expect your project to scale. You want to ensure that your application can easily grow with you.
Identify High-Load Scenarios: Recognize scenarios where case load might spike, such as mass data imports, high-need areas or high population centers, and plan accordingly.
Understand Case Volume Per Users/ Groups: Application performance more specifically deals with how many cases are on each user’s device, with a goal of minimizing the amount of cases on every device. One project may have 10,000 cases with 10 users (each one averaging 1000 cases a device), and a second project might have only 6000 cases with only users (each one averaging 3000 cases a device). In this scenario, even though the first project is “larger” and has more overall cases, the number of cases per device is higher in the second scenario, meaning we could expect performance to be potentially slower in the second scenario.
2. Optimize Case Management
Use Case Sharing Judiciously: Limit the number of cases shared among users-- case sharing is an easy way to increase the number of cases per device. Excessive case sharing can slow down the app, especially if users are on low-bandwidth networks.
Quickly Close Old Cases: Implement a strategy to close cases that are no longer active. This ensures the data remains on the CommCare HQ servers, but doesn’t stay on the phone and impact the user’s application performance.
Reduce the Number of Case Properties Saved: Save only the necessary amount of case properties needed for your case exports, and to effectively have your users navigate throughout the application. Do not by default save the answer to every question as a case property.
3. Optimize Form Design
Minimize Form Complexity: Simplify forms by reducing the number of questions and logic conditions. Complex forms with many calculations or references to case data can slow down performance.
Optimize Expressions Querying the Casedb: For any questions or hidden values that query the case database, ensure that you are optimizing the filters and expressions by always putting indexed properties first in the list of your filters.
4. Regularly Monitor and Maintain the Application
Performance Testing: Conduct regular performance testing, especially when introducing new features or during peak usage periods. Simulate high case loads to see how the app handles them.
Use CommCare Reports: Utilize CommCare’s reporting tools to monitor case load distribution, sync times, and other performance metrics. Address any issues promptly.
Archiving and Pruning: Periodically archive old or inactive cases and prune unnecessary data to keep the database lean and improve sync times. Deprecate case properties and case types that are no longer used, and clear them out of the system.
Monitor User Activity: Keep track of user activity to identify any potential misuse or inefficiency that could affect performance, such as unnecessary case sharing or frequent syncs.
By following these guidelines, you can ensure that your CommCare application performs efficiently, even as case loads increase, leading to a smoother experience for users and more reliable data management.