React Native API Request slow on production but fast on development

894 Views Asked by At

I'm having a huge problem where my requests take long on the production server but are quick on the development server.

I'm using apisauce to make my requests.

Slow request example: The login screen uses a simple username and password with redux to store the logged-in user data. This can take up to 30 seconds but on development, it takes about 2 secs.

One of the improvements I made was setting the headers only once instead of on all the requests which were not clever but are better now. There was only a slight speed improvement but not enough. I was also using the AsyncStorage to store the user data but that is now changed to redux, again a slight improvement but not enough.

I did try and debug with react native debugger but it wouldn't connect so I did it manually with timing the requests.

Does anyone know why the requests are slower and how to fix them?

So I've done some more testing and found that the posting of an image was one of the causes to the slow request speed, not sure why it's only on the live server.

I also found on the first login when I ran the network inspection, the Waiting (TTFB) took about 18seconds then after that it's fine. I'm not sure why that is though. enter image description here

0

There are 0 best solutions below