We have an API built using ASP.Net Core, and we would like to consolidate multiple requests into one HTTP requests for performance reasons.
In previous versions of asp.net you could allow for batch requests via the DefaultHttpBatchHandler.
Unfortunately, no such thing seems to exist in Asp.net Core.
Is anyone aware of any way to do HTTP batches in core?
ASP.NET Core apps should be designed to process many requests simultaneously. Asynchronous APIs allow a small pool of threads to handle thousands of concurrent requests by not waiting on blocking calls. Rather than waiting on a long-running synchronous task to complete, the thread can work on another request.
Format of a batch requestA batch request is a single standard HTTP request containing multiple Google Classroom API calls, using the multipart/mixed content type. Within that main HTTP request, each of the parts contains a nested HTTP request. Each part begins with its own Content-Type: application/http HTTP header.
Batch calls allow API applications to make multiple API calls within a single API call. In addition, each call can be tied to a different access_token meaning batch API calls work with multiple users. Batch calls allow your platform to accomplish more API interaction with less traffic, thus avoiding throttle limits.
Depending on hardware factors with the "weight" of response it may vary from 100 request to 50000 or even more.
After doing my research on the matter, this seems fairly simple to implement. However, I think it should be supported by the official asp.net core team.
To me it seems like it requires a middleware creating multiple RouteContext
according to the inputted text, and just invoking their Handlers - and modifying their response. it might be a little bit more difficult, because it would require support for multiple responses for an HttpContext
(as far as I know it seems like it will be shared across Controllers).
Anyway, There is an open issue in the official repository that I have risen from the dead, hoping it will move things along. I might work on an implementation in the future if there are no changes soon.
Seems like the asp.net team responded to the request, and created a new issue that is set to 2.0 milestone, so I am guessing this feature will be available during asp.net 2.0 release.
Not sure I understand? Do you mean 1 exposed endpoint that makes multiple calls?
Can you not have 1 API action that just creates multiple Tasks (that will run in parallel), waits for them all to complete then return all response data (combined or separated as required)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With