asynchronous - Async calls using HTTPClient vs Direct calling methods asynchronously using Tasks for a synchronous service -
i have scenario in existing application on click of save button javascript function called. javascript function internally makes 4-5 asynchronous calls webservices.for reasons have big javascript files lot of business logic. facing performance issues in application. reduce number of xhr calls making server, thought of consolidating these calls on server side , make single call our javascript. on server side using async await make calls asynchronous.so have created wrapper service 1 method calls different service methods using sendasync method exposed httpclient. our underlying services synchronous , achieve asynchronous functionality used httpclient. measured performance , shows considerable gain. but, 1 of our colleague pointed out have overhead of serialization , deserialization originating other webservice calls server run synchronously.so why not directly call methods instead of new http calls. ow our methods synchronous , make them asynchronous have use tasks again overhead. both approaches overhead see making new http requests using async await more inline microservices concept. there debate , know other thoughts.
my two-cents:
the approach of aggregating information on server side good. point of view use of httpclient internally on server side solution if want connect legacy service , not have ability integrate directly. httpclient simple use , robust, it's technically lot more overhead using task (think of error handling, serialisation, testing, network/socket-resources).
a task nice, since allows proper cancelation, httpclient cannot achieve (httpclient can close socket, other end still block resources).
on top of general resource aspect, use of futures makes task perfect match: https://msdn.microsoft.com/en-us/library/ff963556.aspx
Comments
Post a Comment