Comments (2)
Your arguments are convincing enough for me!
from themoviedbwrapper.
From what I can gather, the general recommendation is to have a single instance of HttpClient
shared per endpoint. However, most of the recommendations are when dealing with high-load clients; for example, an MVC Controller or Web API endpoint with hundreds (thousands) of concurrent users resulting in hundreds/thousands of requests per second.
In this case, the HttpClient
is specifically targeting themoviedb.org's API which is throttled at 40 requests per 10 seconds; this value seems to be hit and miss where sometimes it allows more, sometimes less. Given that the maximum number of allowed requests to themoviedb.org's API is extremely low, creating an HttpClient
per request is the least resistant path forward.
I believe a better long-term approach would be to create a single shared HttpClient
wrapped in some type of throttling queue to prevent receiving the error of "request count is over the allowed limit".
I have done performance profiling against TheMovieDbWrapper and the CreateClient()
call is barely a blip on the timeline. The bottlenecks are on Newtonsoft's side for DeserializeObject
. Here's a high-level breakdown when performing 40 calls to IApiMovieRequest.SearchByTitleAsync()
and excludes all time allotted for waiting, i.e., async/await wating:
Percentage | Root Method |
---|---|
24.8% | Newtonsoft.Json.JsonConvert.DeserializeObject(String, JsonSerializerSettings) |
13.9% | System.ComponentModel.Composition.Hosting.ExportProvider.GetExportCore(String) |
2.5% | DM.MovieApi.MovieDb.Movies.ApiMovieRequest.SearchByTitleAsync(String, Int32, String) |
0.62% | DM.MovieApi.ApiRequest.ApiRequestBase.CreateClient() |
Unless you are seeing a specific bottleneck, I'd like to keep the base class as-is for now.
from themoviedbwrapper.
Related Issues (20)
- Full trust level HOT 3
- Xamarin.iOS HOT 8
- JsonReaderException HOT 5
- Port to PCL broke support for IMovieDbApi HOT 1
- Not installing into PCL(i.e. Portable Class Library project) on Cross platform app HOT 6
- Runtime error in a Xamarin.UWP project HOT 2
- IMDB ID HOT 2
- Exception in compiled release HOT 3
- Exception thrown when requesting certain TVShow details HOT 4
- Exception thrown when call API HOT 1
- Integration Tests Broken
- Upgrade Solution to VS 2019
- Upgrade Nuget Package
- [question] Episode Information Per Tv Show HOT 2
- Question : Namespace HOT 1
- Adding Support for TV Episodes and Seasons HOT 5
- ApiTvShowRequestTests Fails with Game of Thrones Search
- API Request parameters to TheMovieDb.org should be URL Encoded
- Integration tests failing on Lucasfilm values.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from themoviedbwrapper.