Scripted API Multiple Calls

puneetgoels1
Tera Guru

I have created a scripted web service, which has put and post methods. Put method itself calls an import set API.

This scripted web service is being used by a third party application asynchronously.  Issue is if they send multiple API calls it goes into deadlock for some calls and time out after max time and cancel the transactions. I checked with ServiceNow and they said that at once 8 threads can open for the API, which is too less as we can receive around 25 of them at a particular moment.

 

How can we handle this?

 

 

 

1 ACCEPTED SOLUTION

puneetgoels1
Tera Guru

So found solution for it

 

We have 2 application nodes. Each nodes can run 4 concurrent threads and their queue depth is 50 each. Having 2 nodes for the demo instance, at given time 8 threads can run and 100 can be on queue.

In this case , when we trigger 8 more import APIs from 8 Rest APIs at the same time, we are locking all these threads.

 

Then the problem starts. Each rest API will trigger another Import API transaction towards the instance and will wait for it to complete, as all the 8 spots are already taken they will never complete and eventually the transactions will be cancelled.

To resolve this i moved the second transaction under a script include instead of calling import API, this means that all the logic will be run under the first thread, avoiding triggering a second API and will not lock the semaphores. The problem described above happens when at least 8 transactions run in parallel.


 

View solution in original post

9 REPLIES 9

Chuck Tomasi
Tera Patron

Is there a way to batch the payload so you aren't getting 25 individual requests, but 1 request with 25 updates/inserts in it?

No. as third party application won't change their code that includes the JSON string they send

Though we can change our code for a better approach.

Also if they say 8 api calls allowed, so they are total 8 scripted webservice calls + import APIs or just 8 scripted webservice calls

puneetgoels1
Tera Guru

So found solution for it

 

We have 2 application nodes. Each nodes can run 4 concurrent threads and their queue depth is 50 each. Having 2 nodes for the demo instance, at given time 8 threads can run and 100 can be on queue.

In this case , when we trigger 8 more import APIs from 8 Rest APIs at the same time, we are locking all these threads.

 

Then the problem starts. Each rest API will trigger another Import API transaction towards the instance and will wait for it to complete, as all the 8 spots are already taken they will never complete and eventually the transactions will be cancelled.

To resolve this i moved the second transaction under a script include instead of calling import API, this means that all the logic will be run under the first thread, avoiding triggering a second API and will not lock the semaphores. The problem described above happens when at least 8 transactions run in parallel.


 

Can you please show in depth how you moved the second transaction to script include.