In order to insert/update large volumes of contacts you have to take care of some issues:
- XML/SOAP introduces some overhead;
- You should let the system optimize transactions;
- You should think about the purpose of your import: are you creating a target for a communication delivery? Or are you keeping sync your database with a contact's database ?.
Dealing with XML/SOAP overhead
In order to deal with XML/SOAP overhead you should:
- Use a client technology which supports MTOM/XOP (SOAP Message Transmission Optimization Mechanism/XML-binary Optimized Packaging);
- Find a trade-off between the number of http requests and the size of them;
- Use asynchronous operations to update your contacts (that is startBatchContactsUpdate).
Use system built-in functions to optimize transactions
When dealing with large volumes of data you should let the system take control of transaction, that is "load data" and trigger the system to work on it.
Usually you will follow these steps:
- Prepare your data (for example in CSV files, create files from 5 MB to 10 MB in size);
- Create a rowset using createContactRowSet;
- Add your data to the rowset using addDataToContactsRowsSet or addDataToContactsRowsSetFromFile if you are using a CSV file;
- Start the operation, using startBatchContactsUpdate and save the result, which is the ID of a batch operation execution, you will use this ID to get the status and report of your operation;
- Pool the status of your batch update using getBatchStatusInfo and waiting for the operation to be finished;
- Download the detailed report of your operation using fetchBatchContactsUpdateReport.
Creating a static audience of contacts in order to send a communication
If you are going to send a communication to the contacts that you have inserted/updated you have to create an audience and use it as target for the new delivery.
The best way is to create a static audience, which is essentially a static list of contacts which contains the ids of the updated contacts.
In order to create a static audience you have to use the createSimpleStaticGroup function.
You should set the autoexpire option to true in order to preserve the performances of your account, this option informs the system that you are going to use that audience for a limited time, and that the system will eventually delete the audience in order to free up resources.
When you send a communication to an audience with "autoexpire" option, its lifetime will be increased automatically in order to keep the audience existing for recall operations.
In order to add your contacts to that audience you have to your fill the addContactsToSimpleStaticGroup and idGroup in the MNBatchStartOptions parameter of startBatchContactsUpdate.
In order to send a communication that you will use the sendNewsletter function.