locked
Should you make multiple calls on a single web service connection? RRS feed

  • Question

  • User-1959374973 posted

    I'm consuming web services from a 3rd party vendor.  I currently have my code where I create the connection to the web service and then make all the necessary calls on that single connection.

    I was recently told that it was better to create a connection for each individual call.

    Can someone tell what the best practice is regarding multiple web service calls?  Single connection for all calls or a connection for each and every call?

    Thanks.

    Friday, August 31, 2018 7:49 PM

All replies

  • User475983607 posted

    A persistent connection is part of the HTTP spec.  Best practice is driven by the 3rd party service specs.  See the service support docs. 

    Friday, August 31, 2018 8:15 PM
  • User1120430333 posted

    I was recently told that it was better to create a connection for each individual call.

    Why would a single connection with everything being done in one shot be an issue? I kind of doubt that. If doing a multiple connection solution, it  would seem to add additional overhead of cycling through the logic.  

    Friday, August 31, 2018 8:42 PM
  • User-1959374973 posted

    That was my thought also.

    Friday, August 31, 2018 8:45 PM
  • User-1959374973 posted

    The 3rd party vendor is less than stellar when it comes to documentation and providing support.

    We were actually told to not use some of their web service calls if we knew they would return large number of records.

    undecided

    Friday, August 31, 2018 8:47 PM
  • User-474980206 posted

    It all depends. If you are using keep allow alive, the other server will close the connection after 2 minutes of no use anyway. All you are probably saving is the .net setup, not the connection.

    Also with only one connection you can only make one request at a time.
    Friday, August 31, 2018 10:13 PM
  • User753101303 posted

    Hi,

    If a service returns a large number of records you can usually use "paging'". Could it be what they tried to tell ?

    Else technically speaking the best practice for HttpClient is reusing it: https://blogs.msdn.microsoft.com/shacorn/2016/10/21/best-practices-for-using-httpclient-on-services/

    Monday, September 3, 2018 7:42 AM