Question

Long time spent issuing the network request on file upload

I am doing an AJAX HTTP post request to upload an image blob to my droplet. The file uploads fine, but the time spend issuing the network request is incredibly long.

The time spent issuing the network request for a 3.9MB image is anywhere from 20 to 30+ seconds while the time spent processing the image on the server is only about 3-4 seconds.

If I repeat the same process, but point my request to a locally hosted server, the time spent issuing the network request for the same 3.9MB image is 84ms while the time spent processing the image on the local server is only 2.4 seconds.

Why does it take so much longer to issue the network request to the remote droplet?

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

When you issue the POST request you are transmitting the data of the object that you are uploading.

Sounds like the 3.9MB file is taking about 20 seconds to upload from your laptop to the server, which is why that request is sitting there for 20 seconds.

If you do it from a server, to the droplet, the network connectivity is most likely much faster due to larger bandwidth capacity and also latency between the two hosts is an important factor in determining the amount of time that data transfer will take.