Building Scalable Solutions on Salesforce

Join us and learn about how to build scalable solution in Salesforce. In this session we will talk about Data Model, large data volumes, Search and Query performance, Integration, List View, Report and Data Loading and Performance Testing at Scale. This will be your beginners guide to Scale. Let see how to Building Scalable Solutions on Salesforce.

How do we define scale?

build scalable solution in Salesforce

Data Model for Scale

A key for managing large data volumes for peak performance is carefully architecting record ownership to avoid data skew. Data skew happens when more than 10,000 child records are associated with the same parent record within an org.

Plan your data model with enough accounts to keep the number of child records per parent below this threshold, and distribute new child records across these accounts as they’re created.

Another strategy for LDV is using external objects—which means there’s no need to bring data into Salesforce. With a data-tiering strategy that spreads data across multiple objects and brings it in on demand from another object or external store, you avoid both storing large amounts of data in your org, and the performance issues associated with LDV.

Search and Query Performance at Scale

What is SOSL What is SOQL
Salesforce Object Search Language (SOSL) is a Salesforce search language that is used to perform text searches in records. Use SOSL to search fields across multiple standard and custom object records in Salesforce. Salesforce Object Query Language (SOQL) is similar to the SELECT statement in the widely used Structured Query Language (SQL) but is designed specifically for Salesforce data.
Best Practices
Use targeted, specific search terms
Best Practices
1) Use Selective Filters
2) Index fields
3) Work with Salesforce to see if skinny tables would work for your use case
4) Avoid != in filters
5) Consider using Bulk API with bulk query.

Use: Query Optimizer in Dev Console. Check out this post to see to do proper joins like SOQL.

Learn more about SOQL Best Practices.

Integration at Scale

Test the integration with a reasonable mix of data volume and transactions.

Bulkify Sharing and Row Locks Governor Limits
Use appropriate API (Bulk v/s Soap) Multiple disparate integrations that modify the same records cause issues Design keeping Limits in mind
Best Practices
1) Bulkify in Apex code, especially triggers and web services
2) API – consolidate multiple API calls if possible
3) Bulk – Optimize batch size to avoid time-outs and limit retries
Best Practices
1) Do not use an active user for data integration
2) Use System.runAs() in Apex to ensure the correct user is used
3) Defer Sharing Calculations when appropriate
Best Practices
1) Choose the right integration pattern (sync v/s async)
2) Consider business SLA and business needs while designing integration pattern
3) Decide if data needs to reside inside or outside the platform

Learn more about Salesforce Integration.

List Views and Reporting at Scale

Filters & Scope Number of Records Reporting Governance
Efficient filters and operators help faster access and less data returned Number of Records a user may have access to, consider the effects of Sharing Ensure repeatable process around maintenance of list views and reports
Best Practices
1) Try using relative date values, e.g. THIS WEEK, NEXT MONTH, etc.
2) “Not-contains” and != prevent indexes from being used
3) “equal” is better than “contains” , which uses implicit wildcard
Best Practices
1) If the user has “View All” perm such as admin, try to add more selective indexed filters. 
2) For certain mid-level users, it would be more useful to use “My Team” instead of “All” in the filter so that only records that can be seen through the role hierarchy will be fetched.
Best Practices
1) Segment users into groups per specific analytics requirements and use cases
2) Canned reports per user group with good filters
3) Review and cleanup unused dashboards and reports

Data Loading and Performance Testing

Data Load Performance Test Strategy
When dealing with large volumes of data,always use Bulk API Define the use cases and the strategy early in the process
Best Practices
1) Sequence of Load is important
2) Sort the data by parent ID to reduce locking
3) Clean the data outside Salesforce before Loading (ETL Tools)
4) Disable unnecessary triggers, validation rules, workflows
5) Use efficient batch sizes
Best Practices
1) Full Copy Sandbox Recommended
2) Keep the data volume and data profile similar to Production
3) Consider UI, Integration and Data Loading Use cases for performance. 
4) For integration, mimic the number of virtual users to be at least 50% of production.

Learn more about Salesforce Data Migration – Tips & Tricks.

Other Strategies

Salesforce Big Objects

Salesforce provides big data technology called Big Objects. A big object stores and manages massive amounts of data on the Salesforce platform. You can archive data from other objects or bring massive datasets from outside systems into a big object to get a full view of your customers. A big object provides consistent performance, whether you have 1 million records, 100 million, or even 1 billion. This scale gives a big object its power and defines its features.

Scaling Data Access With App Layer Cache

Platform Cache is a memory layer that stores Salesforce session and org data for later access. When you use Platform Cache, your applications can run faster because they store reusable data in memory. Applications can quickly access this data; they don’t need to duplicate calculations and requests to the database on subsequent transactions. In short, think of Platform Cache as RAM for your cloud application.

With Platform Cache, you can also allocate cache space so that some apps or operations don’t steal capacity from others. You use partitions to distribute space. We’ll get to partitions later.

Building Scalable Solutions on Salesforce Video

YouTube video

Further Learning


Amit Chaudhary
Amit Chaudhary

Amit Chaudhary is Salesforce Application & System Architect and working on Salesforce Platform since 2010. He is Salesforce MVP since 2017 and have 17 Salesforce Certificates.

He is a active blogger and founder of Apex Hours.

Articles: 466


Leave a Reply

Your email address will not be published. Required fields are marked *