I am developing a new app in React native and I need to make 20 fetches to my API in parallel. When I developed in phone gap, I could create 20 web workers for the AJAX calls to happen parallel. When I am executing 20 fetches in parallel in React native it looks like every fetch is taking longer than the one before. Like it has a queue of fetches and it won't run them together.
Is there any way to solve this? Now it takes like 1 minute to finish the fetches when in my Phonegap app it takes like 10 secs?
The number of connections per host is limited to four in iOS. You need to increase HTTPMaximumConnectionsPerHost in NSURLSession.
The ugly way to test this is to directly add the following line to node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.m: NSURLSessionConfiguration
[configuration setHTTPMaximumConnectionsPerHost:25];
Read more: https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/1407597-httpmaximumconnectionsperhost?language=objc
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