C
C#12mo ago
Shiv

❔ Optimizing Homescreen API

Hi Team, I need few inputs on optimising Homescreen API(developed using .net6) consumed by mobile client. Right now when a user login, we are running few background calculations and calling 3rd party services which is taking upto 25 seconds for the Home screen API to return. can I split it into two parts 1) Return basic info from API ( which will take around 2 seconds) 2) Return all other responses using SignalR .( can we use SignalR for this kind of usecases) Will this approach work?
8 Replies
Denis
Denis12mo ago
Can't answer without any extra details. And I suppose.even with those details this cannot be answered - it depends on your situation Create a proof of concept using approach A and another using approach B Do some bench marks and you'll have your answer No idea what a home screen api is Is each API call billed? Why are those calculations taking so long? Can.are they essential for this stage of the application? Can these.calculations be cached?
Shiv
Shiv12mo ago
Yes it can be cached to some extent but it is a reward based application so user need to see their score and rewards in the homescreen ... I got your points , but my doubt is how will the data driven applications handle the large loads in case if there is no room for optimization ? If I dont want the user to see the loading screen for long time, can I send basic data first .... Are real time communication libraries like signalR built for handling large data? So that I can push the data when it is ready rather than client making one more api call
Pobiega
Pobiega12mo ago
2 seconds is itself a really long wait for an API call. 25 is an eternity. You could indeed use SignalR here, assuming you control both client and API
Shiv
Shiv12mo ago
@pobiega Yes we are developing both the mobile app and api so we are open to any approaches which will improve the performance .....
Pobiega
Pobiega12mo ago
well, if fetching all the data takes 25 seconds, it will still take 25 seconds even with SignalR.. you'll just get a slightly better experience as your client wont be "loading" for 25 seconds straight It sorta sounds like you are attacking this at the wrong end thou, the 25 second wait time is what should be improved ie, why are the APIs your BE service calls taking so long to respond?
Shiv
Shiv12mo ago
Yes there are few 3rd party services which i doubt we can optimize but we have db related stuffs where we need to optimize i think..
Pobiega
Pobiega12mo ago
for the third party stuff, could you perhaps poll it ahead of time, or must it be a live call? also, is it the slowest call blocking everything, you are you doing them sequentially= doing as much work as possible async could reduce the time, ie 25 calls that each take 1 second can be made a 1.00x second operation
Accord
Accord12mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.