We have built a web service that loads data from an external API. A standard page contains 6-8 modules, all loading data from different resources from the API. It looks like this(each block loads from a different url, e.g. /cars, /phones, /games...
One call to the external API can take like 10-15 second(not unusual at all)...
When loading the page each block will fire an Ajax call with jQuery(we are using backbone) that asks our own API(it's like a proxy, only routes the call forward to the external API) for data.
From the beginning we thought "Ah nice, ajax will solve all our problems"...and it does, on the client side...However, we are not using async or anything like that on the server side so I guess you can see what problems we are facing...that's right, blocking threads.
We cant have more than 2-3 concurrent users because of this. We are using c# MVC together with Web Api and on the frontend we are using Backbone.
My question is; will a async controllers solve our problems? Or should we implement this in another way? Some of you will say "just cache the data and you will be fine". And yes, we are caching the data but it will still block up all the threads(not as long as the first request, but still noticeable)
I see quite a few different solutions for this:
- Reverse ajax - like http://pokein.com/?
- SignalR? http://www.asp.net/signalr
- Asynchronous controllers(with async methods thats getting the data of course...)
So, what do you guys recommend?
Also, I found this: Why is my async ASP.NET Web API controller blocking the main thread? Where the answer suggesting that it's a problem with the browser itself, that it doesn't allow multiple concurrent calls before getting a response from the first request?