Micro-Batch Processing

Micro-batch processing is a technique where you include more than one record in a single service request. By including multiple records in a request instead of issuing separate requests for each record, you can significantly improve performance when processing a large collection of records through a service. Spectrum™ Technology Platform supports micro-batch processing for REST and SOAP web services as well for the Client SDK.

Micro-Batch Size

There is no limit to the number of records you can include in a request, but in general you will see the best performance when sending between 50 and 100 records in a micro-batch. We recommend that you test micro-batches of various sizes to determine the optimal micro-batch size for your environment. Keep in mind that in some cases you may get multiple records in the response for each input record. For example, if you are performing address validation and include 10 addresses in the micro-batch, and each address matches to two possible validated addresses, you would get 20 records in the response, not just 10.

Use caution when using both micro-batches and multiple threads for requests to Spectrum™ Technology Platform. Multiple threads can overwhelm the system if each thread's micro-batch size is too large.

The maximum number of records allowed in a request depends on the service's category.

Service Category Maximum Input Entities
Addressing 25
Analytic 10
Data Quality 10
Geocoding 25
Identity Insight 10
PSAP 25
Routing 1
Spatial 1
Tax Jurisdiction 25
Telco 1

Each micro-batch call must be synchronous. Send the request and wait for the response before sending another request. Asynchronous micro-batch calls can flood Spectrum™ Technology Platform which may result in decreased performance. If you use asynchronous calls or micro-batches that are too large, your account may be disabled.

Using a Record ID

You may find it helpful to assign an ID to each record in a micro-batch so that you can correlate the records in the request with the records returned in the response. Use user fields to do this. For information about user fields, see The REST Interface. For information about user fields, see The SOAP Interface.

Micro-Batch Processing in REST

To perform micro-batch processing with a REST web service, include two or more records as XML or JSON in the body of the request and send the request using the POST method. For more information about sending a POST request to a Spectrum™ Technology Platform web service, see JSON POST Request and XML POST Request.

For example, this request includes two records as XML in the body of the request:

POST http://spectrum.example.com:8080/rest/ValidateAddressPOST/results.xml HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/xml
Authorization: Basic YWRtaW46YWRtaW4=
Content-Length: 533
Host: config813vm0:8080
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<ValidateAddressPOSTRequest xmlns:svc="http://www.pb.com/spectrum/services/ValidateAddressPOST">
    <svc:Input>
       <svc:Row>
          <svc:AddressLine1>3001 Summer</svc:AddressLine1>
          <svc:City>Stamford</svc:City>
          <svc:StateProvince>CT</svc:StateProvince>
       </svc:Row>
       <svc:Row>
          <svc:AddressLine1>33 west monroe</svc:AddressLine1>
          <svc:City>Chicago</svc:City>
          <svc:StateProvince>IL</svc:StateProvince>
       </svc:Row>
    </svc:Input>
</ValidateAddressPOSTRequest>
Note: Services do not have POST support enabled by default. To perform micro-batch processing with these services you must enable POST support. For more information, see Adding POST Support to a REST Web Service.

Micro-Batch Processing in SOAP

To perform micro-batch processing in a SOAP web service, include two or more records in the SOAP request. For example, this request contains two records:

POST http://spectrum.example.com:8080/soap/ValidateAddress HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: ""
Authorization: Basic YWRtaW46YWRtaW4=
Content-Length: 782
Host: config813vm0:8080
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:val="http://www.pb.com/spectrum/services/ValidateAddress">
   <soapenv:Header/>
   <soapenv:Body>
      <val:ValidateAddressRequest>
         <val:input_port>
            <val:Address>
               <val:AddressLine1>1 N. State St.</val:AddressLine1>
               <val:City>Chicago</val:City>
               <val:StateProvince>IL</val:StateProvince>
            </val:Address>
            <val:Address>
               <val:AddressLine1>3001 summer</val:AddressLine1>
               <val:City>stamford</val:City>
               <val:StateProvince>ct</val:StateProvince>
            </val:Address>
         </val:input_port>
      </val:ValidateAddressRequest>
   </soapenv:Body>
</soapenv:Envelope>

Micro-Batch Processing in the Client API

To perform micro-batch processing in an API request to a service, send multiple data rows in the request. For example, this .NET class sends two rows in the request:

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Text;
using ConsoleApplication1.ValidateAddress_Reference;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var validateClient = new ValidateAddress {Credentials = new NetworkCredential("admin", "admin")};

            var address1 = new input_portAddress
            {
                AddressLine1 = "1825B Kramer Lane",
                AddressLine2 = "Suite 100",
                PostalCode = "78758",
                City = "Austin",
                StateProvince = "Texas"
            };

            var address2 = new input_portAddress
            {
                AddressLine1 = "100 Congress", 
                PostalCode = "78701", 
                City = "Austin", 
                StateProvince = "Texas"
            };

            var addresses = new input_portAddress[2];
            addresses[0] = address1;
            addresses[1] = address2;

            var options = new options {OutputCasing = OutputCasing.M};
            output_portAddress[] results = validateClient.CallValidateAddress(options, addresses);

            for (int i = 0; i < results.Length; i++)
            {
                System.Console.WriteLine("Record " + (i+1) + ":");
                System.Console.WriteLine("AddressLine1=" + results[i].AddressLine1);
                System.Console.WriteLine("City=" + results[i].City);
                System.Console.WriteLine("StateProvince=" + results[i].StateProvince);
                System.Console.WriteLine("PostalCode=" + results[i].PostalCode + "\n");
            }
            
            System.Console.Write("Press any key to continue...");
            System.Console.ReadKey();
        }
    }
}
Tip: Do not disconnect between requests. Disconnecting and connecting can reduce performance.