Long time spent issuing the network request on file upload

February 14, 2018 84 views
JavaScript PHP Ubuntu 16.04

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?

Be the first one to answer this question.