SAMGORISOLUTIONS
← All field notes Field Notes · Standard

Integration capacity standard

How to size every NetSuite integration before it is built: how many records one call can safely handle, and how often the other system has to call to keep up.

Applies to
RESTlets, Suitelets, scheduled and map/reduce scripts
Required in
Every integration RFD
1

Why this exists

NetSuite gives every script call a fixed budget of governance units and a time limit. If a call runs out of either, NetSuite stops it and the caller gets no response. Any records the script already marked as sent are lost with it.

Integrations are often built with batch sizes picked by hand and a polling schedule that the other system chose on its own. No one works out what a call can afford or how often the caller has to call to keep up with the volume. The usual result is a call whose cost grows with the backlog and uses more than half its time limit, inbound calls with no size limit, and polling around the clock that mostly returns nothing while the same records are re-sent on every call.

This standard makes both numbers, batch size and call frequency, a required, calculated part of every integration design.

The rule in one line

Batch size comes from the unit and time budgets. Call frequency comes from volume and batch size. Both are written into the RFD before any code is written, and both are measured in UAT.

2

The limits

Per call or per invocation. These are the values in NetSuite Help at the time of writing. Confirm them against the current Help topics "SuiteScript Governance and Limits" and "Script Execution Time Limits" before a design is signed off.

Script typeUnits per callTime limitNotes
RESTlet5,0005 minutesThe usual entry point for an external system. The caller waits for the whole call.
Suitelet1,0005 minutesRarely right for system-to-system traffic.
User event1,0005 minutesRuns inside the user's save. Never do integration calls here.
Scheduled10,00060 minutesOne queue slot per run.
Map/reducegetInputData 10,000 · map 1,000 · reduce 5,000 · summarize 10,00060 · 5 · 15 · 60 minutesLimits apply per invocation and the framework yields for you. The right tool for large volumes.
Other limitValueWhy it matters
Rows per search page1,000 (getRange or one page)A batch can never be bigger than one page unless the script pages through results.
RESTlet payload10 MB request or responseBounds batch size for wide records with long text.
Concurrent web service callsAccount limit, shared by RESTlets, SOAP and REST web servicesRead it at Setup › Integration › Integration Management › Integration Governance. Calls over the limit are rejected.
3

Unit costs

SuiteScript 2.x costs for the calls integrations use most. Treat them as planning estimates. The only reliable number is the one you measure (chapter 4, step 3, or chapter 5).

CallTransactionCustom recordOther records (customer, contact, employee, item)
record.load / create / copy / transform1025
Record.save20410
record.submitFields1025
record.delete20410
CallUnitsNote
search.lookupFields1Cheapest way to read a few fields from one record.
search.load5
Search.runPaged / PagedData.fetch5Per call, not per row.
ResultSet.getRange / each10Per call, not per row. A search run inside a loop is the most common hidden cost.
query.runSuiteQL10Per call.
https.request10Plus the remote system's response time against the time limit.
email.send20
file.load / File.save10 / 20
task.submit20Hand-off to a scheduled or map/reduce script.
log.*, format.*, runtime.getRemainingUsage0Logging is free, so log the usage every time.
Watch for
  • A search inside a loop. 10 units per pass, so cost grows with the number of records, or worse, with the size of the backlog.
  • User events on the records you write. submitFields and save fire the target record's user events in the same call, and their usage and time count against it.
  • Load and save when you only need to set fields. load + save on a transaction costs 30; submitFields costs 10.
4

Sizing method

  1. Pick the script type

    It sets the unit budget and time limit (chapter 2). An external system calling in means a RESTlet. If a single run needs more than one RESTlet call can afford, accept the request in the RESTlet and hand the work to a map/reduce script with task.submit.

  2. Write down the cost model

    Split the call into a fixed part that runs once (searches, lookups, loading config) and a part that runs once per record. List each SuiteScript call with its cost from chapter 3.

    units(call) = fixed + per_record × records
  3. Measure it

    If the script, or one like it, already runs in production, read the cost from its execution log (chapter 5). The log has real records, real volumes and the real calling pattern. For a new script, log runtime.getCurrentScript().getRemainingUsage() at the end of the call and run it in sandbox once with 10 records and once with 50, using the largest realistic records. Time both runs too.

    per_record = (used_50 − used_10) / 40 fixed = used_10 − 10 × per_record
  4. Set the batch size

    Take the smallest of four ceilings. Keep a reserve of 10% of the unit budget (500 for a RESTlet) and use only half the time limit, because record size varies and the target record's user events add cost.

    B_units = floor((budget − fixed − reserve) / per_record) B_time = floor((time_limit × 0.5 − fixed_seconds) / seconds_per_record) B_rows = 1,000 per search page (more only if the script pages) B_payload = floor(5 MB / bytes_per_record) batch = min(B_units, B_time, B_rows, B_payload)
  5. Set the call frequency

    Size for the busiest hour, not the daily average. The interval has to clear peak volume and still meet the freshness the business needs.

    calls_per_peak_hour = ceil(peak_hour_volume / batch) max_interval = min(60 min / calls_per_peak_hour, latency_target) calls_per_day ≈ 24 h / interval
  6. Check the backlog

    After an outage, a bulk load or a mass update, the queue fills. Work out how long it takes to clear at the chosen batch and interval. If records arrive faster than one batch per interval, the backlog never clears.

    drain_capacity_per_call = batch − arrivals_per_interval drain_time = ceil(backlog / drain_capacity_per_call) × interval
  7. Check concurrency

    Calls in flight at once must stay under the account limit, together with every other integration. A queue that marks records as sent is only safe with one caller at a time. Say so in the contract.

  8. Write it into the RFD and enforce it in code

    Record every number in the RFD's capacity section (chapter 8). The script checks remaining units as it goes (chapter 7), and inbound messages carry a maximum batch size that NetSuite enforces.

5

Production history

A script that already runs in production has measured itself. If it logs what it handled and how many units it had left, a SuiteQL query against the execution log (scriptnote) gives the cost model, the call interval and the real batch sizes without a sandbox run.

What the script must log

One AUDIT line per call, written last. Scripts built to this standard already do this (chapter 7).

log.audit('usage', JSON.stringify({ records: records.length, unitsUsed: 5000 - script.getRemainingUsage(), ms: Date.now() - started }));

Query: scripts that log the summary line

SELECT TO_CHAR(date, 'YYYY-MM-DD HH24:MI:SS') AS ended, detail
FROM scriptnote
WHERE scripttype = 12345        -- the script's internal ID
  AND title = 'usage'
ORDER BY date

Query: older scripts with a per-record line and a remaining-units line

Pair each remaining-units entry with the per-record lines written in the 90 seconds before it. Group by time, not by log row ID, because row IDs are not in strict time order.

SELECT TO_CHAR(r.date, 'HH24:MI:SS') AS ended,
       TO_NUMBER(r.detail)           AS remaining,
       (SELECT COUNT(*) FROM scriptnote h
         WHERE h.scripttype = r.scripttype
           AND h.title LIKE 'Record sent%'   -- the per-record line
           AND h.date BETWEEN r.date - (90/86400) AND r.date)    AS records
FROM scriptnote r
WHERE r.scripttype = 12345
  AND r.title LIKE 'Remaining governance%'
ORDER BY r.date

Query: real demand, not log lines

SELECT COUNT(*) AS sends, COUNT(DISTINCT SUBSTR(title, 13)) AS distinct_records
FROM scriptnote
WHERE scripttype = 12345 AND title LIKE 'Record sent%'

Reading the result

  • Fixed cost = units used by a call that handled 0 records.
  • Per-record cost = (units used − fixed) ÷ records, from a full call. Check it holds across several call sizes.
  • Seconds per record = (call duration − empty-call duration) ÷ records.
  • Interval = the gap between call start times. Volume = distinct record IDs per hour, so re-sends do not count as demand.
Limits of the log
  • History is short. NetSuite purges execution logs. Scripts that log every step at DEBUG level fill the space and can leave only a few hours of history. Keep production deployments at AUDIT and log one summary line per call so history lasts.
  • A script that never logs remaining units gives time and record counts only.
  • Overlapping calls blur the time windows. Check start times before trusting a window.
  • The MCP SuiteQL connection reads production, so these queries run against real history.
6

Calculator

Two steps. First describe what the script does for each record, including every lookup on a related record, and the calculator adds up the units and seconds from the chapter 3 costs. Then it sizes the batch and call interval from your volumes. The unit costs are NetSuite's; the seconds are planning estimates you can overtype. Replace any of the results with measured values when you have them.

Step 1 · Build the cost per record

The loop
Lookups and other work for each record

One line per call the script makes on a related record, such as the customer on an opportunity, the contacts on that customer, and the billing contact among them. Choose Once per call when one query can fetch them for the whole batch and the script looks results up in memory.

StepRunsUnitsSecondsShare of per-record units

The totals below fill the three cost fields in step 2. Overtype them with measured values from the production log or a sandbox run when you have them (chapter 5).

Step 2 · Size the batch and interval

Budget
Cost per call
Volume
Records per call——
Unit ceiling(budget − fixed − reserve) ÷ units per record—
Time ceiling(half the time limit − fixed seconds) ÷ seconds per record—
Search page ceiling1,000
Payload ceiling5 MB ÷ KB per record—
Units used by a full call—
Calls needed in the busiest hour—
Longest safe intervalthe shorter of peak capacity and the freshness target—
Calls per day at that interval—
Backlog clears inat the longest safe interval—
Daily capacity at today's interval—
—
7

Build patterns

Outbound pull: stop on budget, not on a fixed count

The batch size from chapter 4 is a maximum. The script also checks its remaining units and time before each record, and tells the caller when more is waiting.

/** @NApiVersion 2.1  @NScriptType Restlet */
define(['N/runtime', 'N/search'], (runtime, search) => {
  const MAX_BATCH = 200;          // from the RFD capacity table
  const RESERVE = 500;            // 10% of 5,000
  const PER_RECORD = 20;          // measured in sandbox
  const TIME_BUDGET_MS = 150000;  // half of the 5-minute limit

  const get = () => {
    const script = runtime.getCurrentScript();
    const started = Date.now();
    const records = [];
    const paged = search.load({ id: 'customsearch_outbound_queue' }).runPaged({ pageSize: 1000 });
    let stopped = false;
    for (const range of paged.pageRanges) {
      for (const result of paged.fetch({ index: range.index }).data) {
        const outOfUnits = script.getRemainingUsage() < RESERVE + PER_RECORD;
        const outOfTime = Date.now() - started > TIME_BUDGET_MS;
        if (records.length >= MAX_BATCH || outOfUnits || outOfTime) { stopped = true; break; }
        records.push(buildRecord(result));
      }
      if (stopped) break;
    }
    log.audit('usage', { sent: records.length, remaining: script.getRemainingUsage(), ms: Date.now() - started });
    return { TotalResults: paged.count, CurrentResults: records.length, HasMore: paged.count > records.length, Records: records };
  };
  return { get };
});

Inbound push: publish a maximum and enforce it

const MAX_INBOUND = 50;   // from the RFD capacity table; the contract states it
const post = (body) => {
  if (body.Records.length > MAX_INBOUND) {
    return { Status: 'Rejected', MaxBatch: MAX_INBOUND, Received: body.Records.length };
  }
  // ...process, checking getRemainingUsage() as above
};
Do
  • Run every search once per call and look results up in memory.
  • Prefer submitFields and lookupFields over load and save.
  • Count records, not search rows. A record with lines is one record.
  • Return HasMore so the caller can call again at once while a backlog exists.
  • Log units used and elapsed time on every call, success or failure, in one AUDIT line.
  • Keep production deployments at AUDIT so the log keeps more than a few hours.
  • Move volumes that a RESTlet cannot carry to map/reduce.
Don't
  • Pick a batch size without the cost model behind it.
  • Put a search, lookupFields or load inside a loop over the queue.
  • Let the cost of one call grow with the size of the backlog.
  • Accept an inbound batch of any size.
  • Let the other system choose the polling interval without the volume numbers.
  • Mark a record as sent before the other system confirms it received it.
8

What every RFD states

Add a Capacity and frequency section to the RFD (in Processing rules, or as its own chapter) with one row per message and these columns:

MsgScript type · budgetFixed unitsUnits per recordSeconds per recordBatch size and binding ceilingPeak records / hourIntervalBacklog drain time
1bRESTlet · 5,00015200.2224 · units12015 min1,000 in 1 h 30 m

The example row is illustrative.

Sign-off checklist

  • Every message has a script type, budget, cost model and batch size.
  • Costs were measured from production history, or from a sandbox run with the largest realistic records. Not only estimated.
  • The batch size is the smallest of the unit, time, page and payload ceilings, with the reserve kept.
  • The interval clears peak-hour volume and meets the freshness target.
  • Backlog drain time is stated for a realistic worst case (a day's outage or a bulk load).
  • No call's cost grows with the size of the backlog.
  • Inbound messages state a maximum batch size, and NetSuite enforces it.
  • Concurrent calls stay under the account limit together with other integrations, and the caller knows whether parallel calls are allowed.
  • Every call logs units used and elapsed time.
  • The interval is agreed with the other system's team and written into the contract.
9

Worked example

An outbound pull of changed customer records (RESTlet), sized from its production log. The figures are illustrative.

StepValueSource
Budget, reserve, time budget5,000 units, 500, 150 sRESTlet limits, 10% reserve, half the time limit
Fixed cost10 units, ≈ 5 sEmpty calls left 4,990 and took ≈ 5 s
Per record5 units, ≈ 0.55 sA call with 150 records left 4,240 and took ≈ 85 s; a call with 79 left 4,595 and took ≈ 45 s
Unit ceiling898(5,000 − 10 − 500) ÷ 5
Time ceiling≈ 260(150 − 5) ÷ 0.55
Batch size≈ 260Time binds, not units. The code in production uses 150.
Interval10 minGap between call start times in the log
Capacity at 150 every 10 min21,600 a day150 × 144 calls
Real demand≈ 1,000 customers in 9 hAbout 3,900 sends but only 1,000 distinct customers
What this shows

Capacity is not the problem here; waste is. A group of about 80 customers was sent on most calls, roughly 2,700 of the 3,900 sends. Only the integration writes their sync date, yet their last-modified time keeps moving without a system note, so they look changed on every call. Counting distinct records instead of log lines exposed it. Without the production history it would have read as high demand.

10

Common failure patterns

What goes wrong
What the standard requires
Batch sizes are typed in by hand, and log labels still show an older choice.
Batch size is derived from the cost model and recorded in the RFD.
A pull limits search rows rather than records, so one record with many lines fills the batch and can be cut off midway.
Count records, not rows.
A pull re-runs a saved search once per eligible record, so its cost grows with the backlog and the call eventually fails.
No call's cost grows with the backlog. One search per call.
Scripts never check remaining units, and some log nothing at all.
Check before each record and log every call.
Inbound write-backs accept batches of any size.
Publish and enforce a maximum inbound batch.
The other system polls every few minutes around the clock, chosen without volume figures, and most calls return nothing.
The interval is calculated from peak volume and freshness, and agreed in the contract.
A group of records is re-sent on most calls because something keeps moving their last-modified time.
Measure demand as distinct records, and make the “changed since” test immune to the script’s own writes.
The logs hold only a few hours, because the scripts log at DEBUG level.
Production runs at AUDIT with one summary line per call, so history survives.
Records are marked sent before the other system confirms it received them.
Mark sent only after the other system confirms receipt.