I need to send about 10,000 small Jason strings to a web service from a C # client application, which is then in a database Will be inserted.
My question: Is it good to send a small number of small requests or is there any way to send the whole item / multiple large shares?
I'm trying to avoid something like this:
list & lt; Thing & gt; Things_to_update = get_things_to_update (); // List now has 10,000 record foreach (Cheesy Things in things_to_update) {// Post http webbuster or similar post_to_web_service (th); }
If you control the server and can change the code, then send it Beta is definitely better for them.
Just encode your object in json object and put them in an array. Therefore instead of sending data such as
data = {id: 5, name: "John"}
make it an array
data = [{ID: 5, name: "John"}, {ID: 6, name: "Jane"}, ...]
then parse it in Put your controller action on the server and insert it You should create a new action that handles more than 1 request for cleaner and more connective code.
Instead of sending all the 10000s at one time, I suggest dividing it into smaller batches of 1000 or 2000. Made Easy with Linq:
int batchSize = 1000; For (int i = 0; i & lt; things _ to _update.Count; i + = batch size) {list & lt; Thing & gt; Batch = cheese_to_update Take (batch sys). Skip (I); Post_to_web_service (batch); }
Comments
Post a Comment