Beginners guide to Scale

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.

Agenda

  • How do we define scale?
  • Data Model for Scale
  • Search and Query Performance at Scale
  • Integration at Scale
  • List Views and Reporting at Scale
  • Data Loading and Performance Testing at Scale
  • Other Techniques

How do we define scale?

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 SQL.

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

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

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.

Recording

Date     : Sat, Sept 12, 2020 10:00 AM EST ( 7:30 PM IST )
Speaker  : Karishma Lalwani (Certified Technical Architect )
Where : ApexHours YouTube

Further Learning

  • https://developer.salesforce.com/docs/atlas.en-us.salesforce_large_data_volumes_bp.meta/salesforce_large_data_volumes_bp/ldv_deployments_introduction.htm
  • https://developer.salesforce.com/blogs/2019/08/scaling-data-access-with-app-layer-cache.html
  • https://developer.salesforce.com/docs/atlas.en-us.draes.meta/draes/draes_group_membership.htm

1,881 total views, 6 views today

Leave a Comment