Hey guys hopefully the title wasn't too bad, hard to describe succinctly.
So I have an ASP.net core 2.0 server running (via Kestrel) on a VPS hosted in Australia (I'm in New Zealand, ~50ms latency to server). An HTTP Get action causes the following code on the ASP.net server to run, where I query an SQL server (also running on the vps) and return the result:
public async Task<string> GetTopContactPhoto(int contactUID)
{
// Open connection if not already open
if (conn.State != System.Data.ConnectionState.Open) { conn.Open(); }
// Get number of rows
string sqlRequest = string.Format("select top 1 imageData from IMAGES where contactUID=@contactID;");
// Return value
using (SqlCommand cmd = new SqlCommand(sqlRequest, conn))
{
cmd.Parameters.AddWithValue("@contactID", contactUID);
return Convert.ToBase64String((byte[])await cmd.ExecuteScalarAsync());
}
}
Now this whole process takes pretty consistently ~5-6 seconds from the time the HTTP Get request is made, to the time the result is given, image sizes ~2MB.
But here's the thing, when I compile and run the ASP.Net core server on my development PC, on a separate continent altogether to the VPS (still running the SQL server), the whole process takes only ~2 seconds, less if I resize the image before responding to Get request.
Any ideas what could be going wrong? This problem has vexed me for months, with no amount of googling doing the trick.