SlideShare a Scribd company logo
How One Billion Salesforce records 
Can Be Replicated 
with Minimal API Usage 
Baruch Oxman 
R&D Manager, Implisit 
@implisithq, @baruchoxman
Safe Harbor 
Safe harbor statement under the Private Securities Litigation Reform Act of 1995: 
This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of 
the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking 
statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service 
availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future 
operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of 
our services. 
The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, 
new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or 
delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and 
acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and 
manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization 
and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our 
annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and 
others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. 
Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be 
delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. 
Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
Baruch Oxman 
R&D Manager
In this session… 
• Implisit - Intro & Motivation 
• Salesforce APIs Usage & Limits - Overview 
• Efficient use of Salesforce APIs 
• Scale and limitations 
• Other pitfalls and tips
Implisit – The End of CRM Data Entry 
• Using Data-Mining and Machine Learning techniques: 
– Automatic entry of emails and calendar events to Salesforce 
– Matching to relevant Accounts, Opportunities, Contacts, Leads 
– Automatic creation of missing Contacts & Leads 
• Using text analysis: 
– Creating meaningful business insights 
– Improving sales pipeline and forecasting 
• Requires Salesforce data replication for offline processing
Data Replication Goals 
• Minimize your API usage 
– Don’t reach the API limit 
– API limits are shared between all API-connected apps – other apps can become blocked 
• Minimize sync cycle time 
– Don’t make our customers wait for too long
Salesforce API Limits 
• Daily API limits for Salesforce Editions: 
– Unlimited/Performance: # of users x 5,000, up to 1,000,000 
– Enterprise/Professional: # of users x 1,000 
– Developer: 15,000 
– Sandbox: 5,000,000 
• In-parallel API calls limit (25 – production, 5 – dev) 
Source & more info: https://help.salesforce.com/HTViewHelpDoc?id=integrate_api_rate_limiting.htm
Performance Stats 
• Keeping over 1 billion Salesforce records replicated in-sync 
– 27 Salesforce object types are replicated 
• Initial sync 
– 600-1000 API calls in total 
• Updates sync 
– 200-400 API calls in total 
– Performed every few hours
Replicating One Billion Records with Minimal API Usage
Salesforce API Types 
• REST API 
– Fast, synchronous queries 
– Up to 2,000 records per request 
– Simple usage 
• SOAP API 
– describeSObjects 
– getDeleted 
– Other metadata queries 
• Bulk (Async) API 
– Large amounts of records in a 
single request 
– Slow, requires polling for results 
– Implements internal retries
So how do I replicate ?
Replication method – Initial fetching 
• Fetch all records for each relevant object type 
– Lots of data 
– Only non-deleted records 
• Break queried data into chunks, to limit size 
• Order by CreatedDate 
• On subsequent queries, use latest CreatedDate from previous result 
• Example: 
– 1st query: “…ORDER BY CreatedDate LIMIT 100000” 
– Subsequent: “…WHERE CreatedDate > 2014-08-31T02:29:29Z ORDER BY CreatedDate LIMIT 100000”
Replication method – Changes fetching 
• Fetch only records that changed since the previous fetch time 
– Less data – only changes 
– Take care of updates and deletions 
• Using SystemModstamp as indicator for changes in record 
• Chunking logic – same as in initial fetching 
• Example: 
– 1st query: “…WHERE SystemModstamp > 2014-07-31T02:29:29Z AND ORDER BY CreatedDate LIMIT 100000” 
– Subsequent: “…WHERE SystemModstamp > 2014-07-31T02:29:29Z AND CreatedDate > 2014-08-31T02:29:29Z ORDER BY CreatedDate LIMIT 100000” 
• Bulk changes fetching VS getUpdated()
Deleted items 
• Motivation: 
– Required to maintain consistent sync 
• Two implementation options 
– Use getDeleted() call in SOAP API (our choice) 
– Use queryAll() query option 
• Supported only in REST API queries 
• Tip: some objects can become “undeleted”
Getting all fields 
• No “SELECT *” support 
• Get all fields for table using “describe” 
– Optionally, filter the fields (skip custom fields, etc…) 
• Use the field names in the query 
• Limitation: query length cannot exceed 20,000 characters* 
* http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select.htm
User Access Restrictions 
• Full access rights are strongly encouraged 
– Full view of all objects 
– Limited access rights -> slower queries 
• Reference Fields – special case 
– Tasks / Events - WhoId, WhatId 
– Attachment - ParentId 
– Relations make access checks in Salesforce even slower 
– Limited to 100,000 different values per query* 
– Solution: query in smaller chunks
Error handling 
• Nothing is fail-safe 
• Different APIs produce different errors 
• Examples: 
– Query too long (too many fields) 
– Scale limitations 
– Communication errors 
– Salesforce maintenance windows 
• Add support for anything you encounter 
– “Rare” becomes “frequent” once you scale 
• ABR (Always Be Retrying) 
• Make sure to clean up upon errors 
– Close open bulk jobs
Non-supported Salesforce objects 
• Some orgs do not support some of the objects 
– For example, Lead or Opportunity 
• Check using describeSObjects for each object, before fetching 
• Safely skip when not supported
Summary 
• Implisit - Intro & Motivation 
• Salesforce APIs Overview 
• Efficient use of API 
• Scale and limitations 
• Other pitfalls and tips
Additional Resources: 
• API Call Basics 
• Salesforce App Limits Cheat Sheet 
• Understanding Execution Governors and Limits 
• Query & Search Optimization Cheat Sheet 
• Bulk Query Details 
• Or ask me: baruch@implisit.com
Replicating One Billion Records with Minimal API Usage
Replicating One Billion Records with Minimal API Usage

More Related Content

What's hot (20)

PDF
How to create a User Defined Policy with IBM APIc (v10)
Shiu-Fun Poon
 
PPTX
Microservices Security
Aditi Anand
 
PDF
Authentification Forte 1
Sylvain Maret
 
PDF
Cours java avance débutant facile l'essentiel swing ,events
Houssem Hamrouni
 
PDF
前端工程師一定要知道的 Docker 虛擬化容器技巧
Chu-Siang Lai
 
PDF
Big Data with KNIME.pdf
James Vp
 
PPTX
Introduction à spring boot
Antoine Rey
 
PDF
Introduction to Spring Cloud
VMware Tanzu
 
PDF
[OpenInfra Days Korea 2018] Day 2 - E6 - 마이크로서비스를 위한 Istio & Kubernetes [다운로드...
OpenStack Korea Community
 
PPTX
Tester unitairement une application java
Antoine Rey
 
PDF
Share point 2019 installation guide
Rudresh Tiwari
 
PPTX
Spring framework in depth
Vinay Kumar
 
PDF
Lazy vs. Eager Loading Strategies in JPA 2.1
Patrycja Wegrzynowicz
 
PPTX
Building APIs with Mule and Spring Boot
Guilherme Pereira Silva
 
PDF
Zabbix para iniciantes
Werneck Costa
 
PPTX
CH1. 簡介 Web 應用程式
Justin Lin
 
PDF
L'API Collector dans tous ses états
José Paumard
 
PPTX
Introduction to DevOps on AWS
Shiva Narayanaswamy
 
PDF
Cloud Native Application Development
Siva Rama Krishna Chunduru
 
How to create a User Defined Policy with IBM APIc (v10)
Shiu-Fun Poon
 
Microservices Security
Aditi Anand
 
Authentification Forte 1
Sylvain Maret
 
Cours java avance débutant facile l'essentiel swing ,events
Houssem Hamrouni
 
前端工程師一定要知道的 Docker 虛擬化容器技巧
Chu-Siang Lai
 
Big Data with KNIME.pdf
James Vp
 
Introduction à spring boot
Antoine Rey
 
Introduction to Spring Cloud
VMware Tanzu
 
[OpenInfra Days Korea 2018] Day 2 - E6 - 마이크로서비스를 위한 Istio & Kubernetes [다운로드...
OpenStack Korea Community
 
Tester unitairement une application java
Antoine Rey
 
Share point 2019 installation guide
Rudresh Tiwari
 
Spring framework in depth
Vinay Kumar
 
Lazy vs. Eager Loading Strategies in JPA 2.1
Patrycja Wegrzynowicz
 
Building APIs with Mule and Spring Boot
Guilherme Pereira Silva
 
Zabbix para iniciantes
Werneck Costa
 
CH1. 簡介 Web 應用程式
Justin Lin
 
L'API Collector dans tous ses états
José Paumard
 
Introduction to DevOps on AWS
Shiva Narayanaswamy
 
Cloud Native Application Development
Siva Rama Krishna Chunduru
 

Viewers also liked (7)

PPTX
Apex REST
Boris Bachovski
 
PPTX
Salesforce APIs
Samuel De Rycke
 
PPTX
Solving Complex Data Load Challenges
Sunand P
 
PPTX
Using Apex for REST Integration
Salesforce Developers
 
PDF
Salesforce API Series: Fast Parallel Data Loading with the Bulk API Webinar
Salesforce Developers
 
PPTX
Exploring the Salesforce REST API
Salesforce Developers
 
PPT
Salesforce REST API
Bohdan Dovhań
 
Apex REST
Boris Bachovski
 
Salesforce APIs
Samuel De Rycke
 
Solving Complex Data Load Challenges
Sunand P
 
Using Apex for REST Integration
Salesforce Developers
 
Salesforce API Series: Fast Parallel Data Loading with the Bulk API Webinar
Salesforce Developers
 
Exploring the Salesforce REST API
Salesforce Developers
 
Salesforce REST API
Bohdan Dovhań
 
Ad

Similar to Replicating One Billion Records with Minimal API Usage (20)

PDF
How One Billion Salesforce records Can Be Replicated with Minimal API Usage
Baruch Oxman
 
PDF
Building towards a Composite API Framework in Salesforce
Salesforce Developers
 
PPTX
February 2020 Salesforce API Review
Lydon Bergin
 
PPTX
Integrating with salesforce
Mark Adcock
 
PPT
Salesforce Integration
Joshua Hoskins
 
PPTX
Navi Mumbai Salesforce DUG meetup on integration
Rakesh Gupta
 
PDF
Designing Custom REST and SOAP Interfaces on Force.com
Salesforce Developers
 
PDF
Enterprise API New Features and Roadmap
Salesforce Developers
 
PDF
Our API Evolution: From Metadata to Tooling API for Building Incredible Apps
Dreamforce
 
PPT
Intro to AppExchange - Building Composite Apps
dreamforce2006
 
PPTX
The Power of Salesforce APIs World Tour Edition
Peter Chittum
 
PDF
Handling of Large Data by Salesforce
Thinqloud
 
PDF
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...
Codemotion
 
PPTX
All Aboard the Boxcar! Going Beyond the Basics of REST
Pat Patterson
 
PPTX
Salesforce Bilbao Elevate '15 - 1st developer workshop
northspainsalesforcedevelopergroup
 
PDF
An Inside Look at a Large-scale Writer-driven REST API Doc Solution at Salesf...
Pronovix
 
PDF
Easy No-Code Integrations with External Services and Visual Flow
Salesforce Developers
 
PDF
Introduction to Data.com APIs
Salesforce Developers
 
PPTX
[MBF2] Plate-forme Salesforce par Peter Chittum
BeMyApp
 
PDF
Data Design Tips for Developing Robust Apps on Force.com
Salesforce Developers
 
How One Billion Salesforce records Can Be Replicated with Minimal API Usage
Baruch Oxman
 
Building towards a Composite API Framework in Salesforce
Salesforce Developers
 
February 2020 Salesforce API Review
Lydon Bergin
 
Integrating with salesforce
Mark Adcock
 
Salesforce Integration
Joshua Hoskins
 
Navi Mumbai Salesforce DUG meetup on integration
Rakesh Gupta
 
Designing Custom REST and SOAP Interfaces on Force.com
Salesforce Developers
 
Enterprise API New Features and Roadmap
Salesforce Developers
 
Our API Evolution: From Metadata to Tooling API for Building Incredible Apps
Dreamforce
 
Intro to AppExchange - Building Composite Apps
dreamforce2006
 
The Power of Salesforce APIs World Tour Edition
Peter Chittum
 
Handling of Large Data by Salesforce
Thinqloud
 
Boxcars and Cabooses: When one more XHR is too much - Peter Chittum - Codemot...
Codemotion
 
All Aboard the Boxcar! Going Beyond the Basics of REST
Pat Patterson
 
Salesforce Bilbao Elevate '15 - 1st developer workshop
northspainsalesforcedevelopergroup
 
An Inside Look at a Large-scale Writer-driven REST API Doc Solution at Salesf...
Pronovix
 
Easy No-Code Integrations with External Services and Visual Flow
Salesforce Developers
 
Introduction to Data.com APIs
Salesforce Developers
 
[MBF2] Plate-forme Salesforce par Peter Chittum
BeMyApp
 
Data Design Tips for Developing Robust Apps on Force.com
Salesforce Developers
 
Ad

More from Salesforce Developers (20)

PDF
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Salesforce Developers
 
PDF
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Salesforce Developers
 
PDF
Local development with Open Source Base Components
Salesforce Developers
 
PPTX
TrailheaDX India : Developer Highlights
Salesforce Developers
 
PDF
Why developers shouldn’t miss TrailheaDX India
Salesforce Developers
 
PPTX
CodeLive: Build Lightning Web Components faster with Local Development
Salesforce Developers
 
PPTX
CodeLive: Converting Aura Components to Lightning Web Components
Salesforce Developers
 
PPTX
Enterprise-grade UI with open source Lightning Web Components
Salesforce Developers
 
PPTX
TrailheaDX and Summer '19: Developer Highlights
Salesforce Developers
 
PDF
Live coding with LWC
Salesforce Developers
 
PDF
Lightning web components - Episode 4 : Security and Testing
Salesforce Developers
 
PDF
LWC Episode 3- Component Communication and Aura Interoperability
Salesforce Developers
 
PDF
Lightning web components episode 2- work with salesforce data
Salesforce Developers
 
PDF
Lightning web components - Episode 1 - An Introduction
Salesforce Developers
 
PDF
Migrating CPQ to Advanced Calculator and JSQCP
Salesforce Developers
 
PDF
Scale with Large Data Volumes and Big Objects in Salesforce
Salesforce Developers
 
PDF
Replicate Salesforce Data in Real Time with Change Data Capture
Salesforce Developers
 
PDF
Modern Development with Salesforce DX
Salesforce Developers
 
PDF
Get Into Lightning Flow Development
Salesforce Developers
 
PDF
Integrate CMS Content Into Lightning Communities with CMS Connect
Salesforce Developers
 
Sample Gallery: Reference Code and Best Practices for Salesforce Developers
Salesforce Developers
 
Maximizing Salesforce Lightning Experience and Lightning Component Performance
Salesforce Developers
 
Local development with Open Source Base Components
Salesforce Developers
 
TrailheaDX India : Developer Highlights
Salesforce Developers
 
Why developers shouldn’t miss TrailheaDX India
Salesforce Developers
 
CodeLive: Build Lightning Web Components faster with Local Development
Salesforce Developers
 
CodeLive: Converting Aura Components to Lightning Web Components
Salesforce Developers
 
Enterprise-grade UI with open source Lightning Web Components
Salesforce Developers
 
TrailheaDX and Summer '19: Developer Highlights
Salesforce Developers
 
Live coding with LWC
Salesforce Developers
 
Lightning web components - Episode 4 : Security and Testing
Salesforce Developers
 
LWC Episode 3- Component Communication and Aura Interoperability
Salesforce Developers
 
Lightning web components episode 2- work with salesforce data
Salesforce Developers
 
Lightning web components - Episode 1 - An Introduction
Salesforce Developers
 
Migrating CPQ to Advanced Calculator and JSQCP
Salesforce Developers
 
Scale with Large Data Volumes and Big Objects in Salesforce
Salesforce Developers
 
Replicate Salesforce Data in Real Time with Change Data Capture
Salesforce Developers
 
Modern Development with Salesforce DX
Salesforce Developers
 
Get Into Lightning Flow Development
Salesforce Developers
 
Integrate CMS Content Into Lightning Communities with CMS Connect
Salesforce Developers
 

Recently uploaded (20)

PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
UiPath DevConnect 2025: Agentic Automation Community User Group Meeting
DianaGray10
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
SIZING YOUR AIR CONDITIONER---A PRACTICAL GUIDE.pdf
Muhammad Rizwan Akram
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 

Replicating One Billion Records with Minimal API Usage

  • 1. How One Billion Salesforce records Can Be Replicated with Minimal API Usage Baruch Oxman R&D Manager, Implisit @implisithq, @baruchoxman
  • 2. Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of any litigation, risks associated with completed and any possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  • 4. In this session… • Implisit - Intro & Motivation • Salesforce APIs Usage & Limits - Overview • Efficient use of Salesforce APIs • Scale and limitations • Other pitfalls and tips
  • 5. Implisit – The End of CRM Data Entry • Using Data-Mining and Machine Learning techniques: – Automatic entry of emails and calendar events to Salesforce – Matching to relevant Accounts, Opportunities, Contacts, Leads – Automatic creation of missing Contacts & Leads • Using text analysis: – Creating meaningful business insights – Improving sales pipeline and forecasting • Requires Salesforce data replication for offline processing
  • 6. Data Replication Goals • Minimize your API usage – Don’t reach the API limit – API limits are shared between all API-connected apps – other apps can become blocked • Minimize sync cycle time – Don’t make our customers wait for too long
  • 7. Salesforce API Limits • Daily API limits for Salesforce Editions: – Unlimited/Performance: # of users x 5,000, up to 1,000,000 – Enterprise/Professional: # of users x 1,000 – Developer: 15,000 – Sandbox: 5,000,000 • In-parallel API calls limit (25 – production, 5 – dev) Source & more info: https://help.salesforce.com/HTViewHelpDoc?id=integrate_api_rate_limiting.htm
  • 8. Performance Stats • Keeping over 1 billion Salesforce records replicated in-sync – 27 Salesforce object types are replicated • Initial sync – 600-1000 API calls in total • Updates sync – 200-400 API calls in total – Performed every few hours
  • 10. Salesforce API Types • REST API – Fast, synchronous queries – Up to 2,000 records per request – Simple usage • SOAP API – describeSObjects – getDeleted – Other metadata queries • Bulk (Async) API – Large amounts of records in a single request – Slow, requires polling for results – Implements internal retries
  • 11. So how do I replicate ?
  • 12. Replication method – Initial fetching • Fetch all records for each relevant object type – Lots of data – Only non-deleted records • Break queried data into chunks, to limit size • Order by CreatedDate • On subsequent queries, use latest CreatedDate from previous result • Example: – 1st query: “…ORDER BY CreatedDate LIMIT 100000” – Subsequent: “…WHERE CreatedDate > 2014-08-31T02:29:29Z ORDER BY CreatedDate LIMIT 100000”
  • 13. Replication method – Changes fetching • Fetch only records that changed since the previous fetch time – Less data – only changes – Take care of updates and deletions • Using SystemModstamp as indicator for changes in record • Chunking logic – same as in initial fetching • Example: – 1st query: “…WHERE SystemModstamp > 2014-07-31T02:29:29Z AND ORDER BY CreatedDate LIMIT 100000” – Subsequent: “…WHERE SystemModstamp > 2014-07-31T02:29:29Z AND CreatedDate > 2014-08-31T02:29:29Z ORDER BY CreatedDate LIMIT 100000” • Bulk changes fetching VS getUpdated()
  • 14. Deleted items • Motivation: – Required to maintain consistent sync • Two implementation options – Use getDeleted() call in SOAP API (our choice) – Use queryAll() query option • Supported only in REST API queries • Tip: some objects can become “undeleted”
  • 15. Getting all fields • No “SELECT *” support • Get all fields for table using “describe” – Optionally, filter the fields (skip custom fields, etc…) • Use the field names in the query • Limitation: query length cannot exceed 20,000 characters* * http://www.salesforce.com/us/developer/docs/soql_sosl/Content/sforce_api_calls_soql_select.htm
  • 16. User Access Restrictions • Full access rights are strongly encouraged – Full view of all objects – Limited access rights -> slower queries • Reference Fields – special case – Tasks / Events - WhoId, WhatId – Attachment - ParentId – Relations make access checks in Salesforce even slower – Limited to 100,000 different values per query* – Solution: query in smaller chunks
  • 17. Error handling • Nothing is fail-safe • Different APIs produce different errors • Examples: – Query too long (too many fields) – Scale limitations – Communication errors – Salesforce maintenance windows • Add support for anything you encounter – “Rare” becomes “frequent” once you scale • ABR (Always Be Retrying) • Make sure to clean up upon errors – Close open bulk jobs
  • 18. Non-supported Salesforce objects • Some orgs do not support some of the objects – For example, Lead or Opportunity • Check using describeSObjects for each object, before fetching • Safely skip when not supported
  • 19. Summary • Implisit - Intro & Motivation • Salesforce APIs Overview • Efficient use of API • Scale and limitations • Other pitfalls and tips
  • 20. Additional Resources: • API Call Basics • Salesforce App Limits Cheat Sheet • Understanding Execution Governors and Limits • Query & Search Optimization Cheat Sheet • Bulk Query Details • Or ask me: [email protected]

Editor's Notes

  • #3: Key Takeaway: We are a publicly traded company. Please make your buying decisions only on the products commercially available from Salesforce.com. Talk Track: Before I begin, just a quick note that when considering future developments, whether by us or with any other solution provider, you should always base your purchasing decisions on what is currently available.
  • #7: If you use too much API, other apps can become blocked, as not enough will be left for them
  • #8: All connected apps that use the API, share the limit and their API calls are counted towards these limits
  • #9: Example objects: Opp, Account, Contact, Lead, Case, Task, Event, OppHistory, ContactRole, etc… Initial sync (600-1000 API calls in total) A few minutes – for small orgs * Up to 12 hours – for large orgs ** Updates sync – every few hours (200-400 API calls in total) A few minutes – for small orgs * Up to a few hours – for large orgs ** * Small org: Several 1,000s of accounts, opportunities, contacts, leads, tasks. ** Large org: 500K+ accounts/opportunities, 1-2M contacts, 5M+ leads, 10M+ tasks.
  • #11: Bulk API: Used for most of our data fetching Certain size Limits How does it work: Create an async job in Salesforce Run a query task within the job Poll till the task is complete Fetch task result (CSV format) – size not limited Close the async job REST API: - Used for Tables not supported by Bulk API (e.g. OpportunityHistory)
  • #13: Use CreatedDate for chunking, since it will be different between different records Modification date can be similar for many different records, due to some bulk-update procedure Other approaches: - query
  • #14: Use CreatedDate for chunking, since it will be different between different records Modification date can be similar for many different records, due to some bulk-update procedure Other approaches: - query
  • #17: How much slower ? Inconclusive but could have been x2 – x4
  • #18: Examples: Communication errors Different errors from different SF instances Salesforce maintenance windows Robustness approach