Open victormihaita opened 3 years ago
@victormihaita There's a couple things I see in your setup of the operation queue: I see you've got the max concurrent operation count at 64 for the networking queue - that's a lot of operations to keep track of from a networking perspective. I would try setting that to maybe 4 or 8 and see if that helps.
You've also got that operation queue set up as using .userIneractive
quality of service, which as those docs I linked say is for actual drawing to the screen, so it may be leveraging stuff from the main thread. I would at least recommend dropping that to .userInitiated
. More frequently for networking either .utility
or .background
is what gets used.
If neither of those changes help, either a) A sample app that reproduces the slow-downs you're seeing and/or b) info from Instruments about where the slow-downs are occurring, and how slow things get.
Thanks for replying. I've tried your suggestions, but I still have the same results.. Here is a print screen with the network requests that are performed when launching the app.. As you can see the duration is really slow..
So if you're seeing these numbers within ProxyMan (or any other network proxying software), that's going to be the duration from when a request leaves the device/sim to when the server responds.
I agree some of these numbers look pretty hideous (13 seconds...ouch), but because these numbers are from after the request leaves the device/sim, that indicates the issue is at the server level rather than an issue with Apollo or even URLSession
code.
I've improved the performance a bit by not triggering that many queries at the same time and by removing the duplicated queries. Is it a good approach to use the OperationQueue()
on the background thread to perform the network requests and is it the right direction the implementation I am doing above?
Bug report
The network performance of the app is very bad. All the queries are performed correctly, but it looks like there is a queue for the operations and they are performed one by one (in serial) while I expect them to be done in parallel.
First I've tried to use the default init for the ApolloClient and after I've started to use the background thread for the
operationQueue
hoping that I will achieve the parallel execution of the queries and an improvement in the performance. I've attached the main part of the code used for the NEtworking so maybe someone can find out if I miss something.. It looks correct to be as everything works... but is just slooooow :(Versions
apollo-ios
SDK version: 0.42.0Steps to reproduce
Here is the code I use to init the ApolloClient
Here is the reactive implementation for
fetch
Here is my NetworkInterceptor implementation
Here is the interceptor used for setting the authentication token
Further details
I also have a
TokenErrorInterceptor
which is used to catch errors and refresh the token but I didn't post the code as is not relevant for this issue...