cancel
Showing results for 
Search instead for 
Did you mean: 

Increase Pipeline Throughput By Parallelizing Service Calls

dwhite
Employee
Employee

Many times when designing a pipeline for a use case one may need to make a call to an external service (REST/SOAP). In SnapLogic REST and SOAP snaps operate serially, meaning they can only process one document at a time. Some service calls may take an extended period of time to come back, so this will essentially block one’s pipeline execution until a response is received. This may be an acceptable for a pipeline with little volume, but if one is processing thousands of documents or more and each call takes a few seconds to complete, it can rack up quite the runtime.

To get around this, one can distribute the incoming documents over a number of outputs and add more snaps to make service calls.

To evenly distribute incoming documents across multiple outputs, one can use the router snap in “autorouting” mode. What this will do is round-robin incoming documents over the number of given outputs. To setup, drag a router snap onto one’s pipeline, add the desired number of output views, and leave the expressions correlating to those output views blank.

3272be1819962ebf25201c0c1090ce930818769f.PNG

After that is setup, copy one’s snap making the service call and add one to each of the router outputs.

e63b3bd4aaf66a5621399534cab69d22ff6da1bd.PNG

Union the REST outputs to recombine the streams, and then reconnect the remaining pipeline logic.

6364fbedad1cc8b66e148d91615e68132cc7f1b5.PNG

Thats it!

If your service calls block even a few seconds and one is making a large number of calls, this should decrease the runtime a bit. The exact amount of parallelism to use will be a factor of the use case and the service endpoint. I’ve found that two calls has worked best most of the time, only on extreme volume was an advantage gained by going to 3 or more.

6 REPLIES 6

tstack
Former Employee

Another approach would be to put the parts of the pipeline you wish to parallelize in a child pipeline that is called with the Pipeline Execute snap. Using a child pipeline will save you the trouble of having to maintain copies of the snaps and make it easier to test different concurrency levels since it’s just a matter of changing the ‘Pool Size’ property.

walkerline117
Contributor

So is this the same as having a sub-pipeline and tune the pool size of the Pipeline execute?

This is in addition to this.

So if you have 100 documents, and only one pipeline execute with a pool size of 10, then 10 are distributed for each instantiation of execution.

In this case net instantiations are only 10.

Now with the same amount of documents, you have 2 routes each calling pipeline execute with a pool size of 10 then 50 are distributed in 2 routes and then 5 run across each instantiation of execution.

In this case net instantiations are now 20.

Hope that makes sense.

So then why I have such duplicate in terms of snap and why not just do one pipeline execute with pool size of 20?