Performance - The affect of reducing remote calls

time to read 1 min | 120 words

I just got 3000% performance improvement. I got if by turning this:

public int GetLatestVersion()
{
	return SourceControlService.GetLatestChangeset(serverUrl, credentials);
}

To this:

public int GetLatestVersion()
{
	const string latestVersion = "Repository.Latest.Version";
	if (PerRequest.Items[latestVersion] != null)
		return (int) PerRequest.Items[latestVersion];
	int changeset = SourceControlService.GetLatestChangeset(serverUrl, credentials);
	PerRequest.Items[latestVersion] = changeset;
	return changeset;
}

PerRequest.Items maps to HttpContext.Current.Items (it is a bit more complicated than that, we have non IIS hosted version to consider, but that is the same thing).

If you are wondering what it the most critical thing that you can do to get good performance, look at remote calls in the application.