sf-agent-framework
Version:
AI Agent Orchestration Framework for Salesforce Development - Two-phase architecture with 70% context reduction
495 lines (394 loc) • 14.2 kB
Markdown
# Salesforce Performance Benchmarks
## Overview
This document provides comprehensive performance benchmarks and optimization
targets for Salesforce implementations. These benchmarks help teams set
realistic performance goals and identify optimization opportunities.
## Page Load Time Benchmarks
### Lightning Experience Standards
| Page Type | Excellent | Good | Acceptable | Poor |
| ------------- | --------- | -------- | ---------- | ---- |
| Home Page | <1s | 1-2s | 2-3s | >3s |
| Record Detail | <1.5s | 1.5-2.5s | 2.5-4s | >4s |
| List View | <2s | 2-3s | 3-5s | >5s |
| Dashboard | <3s | 3-5s | 5-8s | >8s |
| Report | <2s | 2-4s | 4-6s | >6s |
### Classic Experience Standards
| Page Type | Excellent | Good | Acceptable | Poor |
| ------------- | --------- | -------- | ---------- | ---- |
| Home Page | <0.5s | 0.5-1s | 1-2s | >2s |
| Record Detail | <1s | 1-1.5s | 1.5-3s | >3s |
| List View | <1.5s | 1.5-2.5s | 2.5-4s | >4s |
## API Performance Benchmarks
### REST API Response Times
```javascript
// Benchmark targets
const apiTargets = {
singleRecord: {
excellent: 100, // ms
good: 200,
acceptable: 500,
poor: 1000,
},
bulkQuery: {
excellent: 500,
good: 1000,
acceptable: 2000,
poor: 5000,
},
complexQuery: {
excellent: 1000,
good: 2000,
acceptable: 5000,
poor: 10000,
},
};
```
### Bulk API Processing Rates
| Operation | Records/Second | Daily Volume |
| --------- | -------------- | -------------- |
| Insert | 2,000-10,000 | 10-50 million |
| Update | 1,500-8,000 | 8-40 million |
| Upsert | 1,000-5,000 | 5-25 million |
| Delete | 2,000-10,000 | 10-50 million |
| Query | 5,000-20,000 | 25-100 million |
## SOQL Query Performance
### Query Execution Benchmarks
```sql
-- Simple query benchmark
-- Target: <100ms
SELECT Id, Name FROM Account WHERE Id = :accountId
-- Moderate complexity
-- Target: <500ms
SELECT Id, Name,
(SELECT Id, Name FROM Contacts)
FROM Account
WHERE CreatedDate = THIS_MONTH
-- Complex query
-- Target: <2000ms
SELECT Id, Name, Owner.Name,
(SELECT Id, Amount FROM Opportunities WHERE Stage = 'Closed Won'),
(SELECT Id, CaseNumber FROM Cases WHERE Status = 'Open')
FROM Account
WHERE Type IN ('Customer', 'Partner')
AND LastActivityDate > LAST_N_DAYS:30
```
### Query Optimization Metrics
```apex
// Measure query performance
Long startTime = System.currentTimeMillis();
List<Account> accounts = [SELECT Id, Name FROM Account LIMIT 1000];
Long queryTime = System.currentTimeMillis() - startTime;
System.debug('Query Time: ' + queryTime + 'ms');
System.debug('Records per ms: ' + (1000.0 / queryTime));
```
## Apex Performance Benchmarks
### CPU Time Guidelines
| Operation Type | Target Time | Maximum |
| --------------- | ----------- | ------- |
| Simple Trigger | <50ms | 100ms |
| Complex Trigger | <200ms | 500ms |
| Batch Execute | <5000ms | 10000ms |
| Web Service | <1000ms | 2000ms |
| VF Controller | <500ms | 1000ms |
### Code Performance Patterns
```apex
// Benchmark: Loop performance
// Bad: Nested loops O(n²) - 10,000ms for 1000 records
for (Account a : accounts) {
for (Contact c : contacts) {
if (c.AccountId == a.Id) {
// Process
}
}
}
// Good: Map-based O(n) - 50ms for 1000 records
Map<Id, Account> accountMap = new Map<Id, Account>(accounts);
for (Contact c : contacts) {
Account a = accountMap.get(c.AccountId);
// Process
}
// Benchmark results:
// 1,000 records: 50ms vs 10,000ms (200x improvement)
// 10,000 records: 500ms vs 1,000,000ms (2000x improvement)
```
## Data Volume Impact
### Performance Degradation Curves
```javascript
// Performance impact by data volume
const performanceImpact = {
accounts: {
'<100K': 'No impact',
'100K-1M': '5-10% slower',
'1M-5M': '10-25% slower',
'5M-10M': '25-50% slower',
'>10M': 'Requires optimization',
},
customObjects: {
'<500K': 'No impact',
'500K-2M': '10-20% slower',
'2M-10M': '20-40% slower',
'>10M': 'Significant impact',
},
};
```
### Large Data Volume (LDV) Thresholds
| Object Type | Standard Threshold | LDV Threshold | Extreme LDV |
| -------------- | ------------------ | ------------- | ----------- |
| Accounts | 1 million | 5 million | 10+ million |
| Contacts | 2 million | 10 million | 20+ million |
| Opportunities | 1 million | 5 million | 10+ million |
| Cases | 2 million | 10 million | 20+ million |
| Custom Objects | 1 million | 5 million | 10+ million |
| Activities | 5 million | 20 million | 50+ million |
## Integration Performance
### Callout Response Times
```apex
// HTTP callout benchmarks
public class CalloutBenchmarks {
// Target response times
public static final Integer EXCELLENT = 200; // ms
public static final Integer GOOD = 500; // ms
public static final Integer ACCEPTABLE = 1000; // ms
public static final Integer POOR = 2000; // ms
public static void measureCallout(String endpoint) {
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint(endpoint);
request.setMethod('GET');
request.setTimeout(120000);
Long startTime = System.currentTimeMillis();
HttpResponse response = http.send(request);
Long responseTime = System.currentTimeMillis() - startTime;
String performance = getPerformanceRating(responseTime);
System.debug('Response Time: ' + responseTime + 'ms - ' + performance);
}
}
```
### Streaming API Performance
| Metric | Target | Maximum |
| --------------- | ------ | ------- |
| Connection Time | <1s | 5s |
| Message Latency | <100ms | 500ms |
| Messages/Second | 1000 | 5000 |
| Reconnect Time | <2s | 10s |
## Batch Processing Benchmarks
### Batch Apex Performance
```apex
// Optimal batch sizes by operation type
public class BatchSizeBenchmarks {
// Simple operations (field updates)
public static final Integer SIMPLE_BATCH_SIZE = 2000;
// Moderate complexity (some calculations)
public static final Integer MODERATE_BATCH_SIZE = 1000;
// Complex operations (callouts, heavy processing)
public static final Integer COMPLEX_BATCH_SIZE = 200;
// With callouts
public static final Integer CALLOUT_BATCH_SIZE = 100;
}
// Performance metrics
// 1M records, simple update: 15-20 minutes
// 1M records, complex logic: 45-60 minutes
// 1M records, with callouts: 2-4 hours
```
## Visualforce Performance
### Page Metrics
```xml
<!-- View state benchmarks -->
<!-- Excellent: <50KB -->
<!-- Good: 50-80KB -->
<!-- Acceptable: 80-135KB -->
<!-- Poor: >135KB (approaching limit) -->
<apex:page controller="MyController">
<!-- Measure render time -->
<apex:outputText value="{!renderTime}ms" />
<!-- Target times:
Simple page: <500ms
Complex form: <1000ms
Data table: <2000ms
-->
</apex:page>
```
### Controller Performance
```apex
public class PerformanceController {
private Long startTime;
public PerformanceController() {
startTime = System.currentTimeMillis();
}
public Long getRenderTime() {
return System.currentTimeMillis() - startTime;
}
// Benchmark: Constructor should complete in <100ms
// Action methods should complete in <500ms
// Complex operations should use async processing
}
```
## Lightning Component Performance
### Component Lifecycle Benchmarks
```javascript
// Lightning component performance targets
({
// Initialization: <50ms
init: function (component, event, helper) {
console.time('init');
helper.initialize(component);
console.timeEnd('init');
},
// Render: <100ms
afterRender: function (component, helper) {
console.time('render');
helper.setupUI(component);
console.timeEnd('render');
},
// Server calls: <500ms
loadData: function (component, event, helper) {
const startTime = performance.now();
const action = component.get('c.getData');
action.setCallback(this, function (response) {
const duration = performance.now() - startTime;
console.log(`Server call: ${duration}ms`);
// Target: <500ms for standard queries
// <1000ms for complex operations
});
$A.enqueueAction(action);
},
});
```
### Lightning Data Service (LDS) Performance
| Operation | Target Time | Cache Hit |
| ------------- | ----------- | --------- |
| Load Record | <200ms | <10ms |
| Save Record | <500ms | N/A |
| Create Record | <300ms | N/A |
| Delete Record | <300ms | N/A |
## Report and Dashboard Performance
### Report Execution Times
| Report Type | Row Count | Target Time |
| ----------- | --------- | ----------- |
| Tabular | <2,000 | <2s |
| Summary | <2,000 | <3s |
| Matrix | <2,000 | <4s |
| Joined | <2,000 | <5s |
| Tabular | <20,000 | <10s |
| Summary | <20,000 | <15s |
| Matrix | <20,000 | <20s |
### Dashboard Refresh Rates
```javascript
// Dashboard component benchmarks
const dashboardTargets = {
components: {
1-5: "<3s total",
6-10: "<5s total",
11-20: "<10s total"
},
individualComponent: {
simple: "<500ms",
moderate: "<1000ms",
complex: "<2000ms"
}
};
```
## Search Performance
### SOSL Benchmarks
```apex
// Search performance targets
List<List<SObject>> searchResults = [FIND :searchTerm
IN ALL FIELDS
RETURNING
Account(Id, Name),
Contact(Id, Name),
Opportunity(Id, Name)
LIMIT 200];
// Benchmarks:
// Simple term: <500ms
// Wildcard search: <1000ms
// Multiple objects: <1500ms
// Complex filters: <2000ms
```
### Global Search Performance
| Search Type | Target Response | Max Results |
| ------------- | --------------- | ----------- |
| Exact Match | <200ms | 200 |
| Partial Match | <500ms | 200 |
| Wildcard | <1000ms | 200 |
| Fuzzy Search | <1500ms | 200 |
## Mobile Performance
### Salesforce Mobile App
| Metric | WiFi/4G | 3G | Offline |
| ----------- | ------- | ---- | ------- |
| App Launch | <3s | <5s | <1s |
| Record Load | <2s | <4s | <500ms |
| List Load | <3s | <6s | <1s |
| Sync Time | <10s | <30s | N/A |
## Performance Testing Tools
### Built-in Monitoring
```apex
// Developer Console metrics
System.debug('CPU Time: ' + Limits.getCpuTime() + '/' + Limits.getLimitCpuTime());
System.debug('Queries: ' + Limits.getQueries() + '/' + Limits.getLimitQueries());
System.debug('Query Rows: ' + Limits.getQueryRows() + '/' + Limits.getLimitQueryRows());
System.debug('DML Rows: ' + Limits.getDmlRows() + '/' + Limits.getLimitDmlRows());
System.debug('Heap Size: ' + Limits.getHeapSize() + '/' + Limits.getLimitHeapSize());
```
### Performance Test Framework
```apex
@IsTest
public class PerformanceTest {
@IsTest
static void testQueryPerformance() {
// Setup test data
List<Account> testAccounts = TestDataFactory.createAccounts(10000);
Test.startTest();
Long startTime = System.currentTimeMillis();
// Test query
List<Account> results = [
SELECT Id, Name, Type, Industry
FROM Account
WHERE CreatedDate = TODAY
];
Long executionTime = System.currentTimeMillis() - startTime;
Test.stopTest();
// Assert performance
System.assert(executionTime < 2000,
'Query took ' + executionTime + 'ms, expected <2000ms');
}
}
```
## Optimization Thresholds
### When to Optimize
| Metric | Consider Optimization | Requires Optimization |
| ---------------- | --------------------- | --------------------- |
| Page Load | >3s | >5s |
| API Response | >1s | >2s |
| Batch Processing | >1hr per million | >2hr per million |
| Report Execution | >10s | >30s |
| CPU Time | >5000ms | >8000ms |
| SOQL Queries | >50 | >80 |
| View State | >80KB | >120KB |
## Performance Improvement Targets
### Optimization Goals
```javascript
// Expected improvements from optimization
const optimizationTargets = {
indexing: '50-90% query improvement',
skinnyTables: '30-60% query improvement',
caching: '80-95% response improvement',
bulkification: '90-99% processing improvement',
asyncProcessing: '60-80% user experience improvement',
archiving: '40-70% overall improvement',
};
```
## Industry Benchmarks
### Comparative Performance
| Platform Aspect | Salesforce Target | Industry Average |
| ---------------- | ----------------- | ---------------- |
| Page Load | <2s | 3-5s |
| API Latency | <200ms | 300-500ms |
| Mobile Response | <3s | 4-6s |
| Search Results | <1s | 2-3s |
| Batch Processing | 10K/min | 5K/min |
## Additional Resources
- [Salesforce Performance Best Practices](https://developer.salesforce.com/docs/atlas.en-us.salesforce_ppo_guide.meta/salesforce_ppo_guide/)
- [Large Data Volumes Best Practices](https://developer.salesforce.com/docs/atlas.en-us.salesforce_large_data_volumes_bp.meta/salesforce_large_data_volumes_bp/)
- [Performance Profiling Tools](https://help.salesforce.com/s/articleView?id=sf.code_dev_console_performance.htm)
- [Optimizer Reports](https://help.salesforce.com/s/articleView?id=sf.optimizer_kick_off.htm)