3

Currently in the process of building an API, and I was wondering if the length of the URL has any impact on the performance of the API?

For example

Having k= instead of api_key= in the query string, or limiting the actual api_key to X characters instead of 32 characters (md5 hash for example).

Bear in mind, that this API will be used for 4-5 medium-large scale websites

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
Stoosh
  • 2,408
  • 2
  • 18
  • 24
  • 1
    Could you explain what you mean by "performance" please? Are you talking about the length of time it takes to parse a URL? – Charles May 04 '11 at 23:34
  • Load on the server, speed of the actual request but on a fairly large scale – Stoosh May 04 '11 at 23:35
  • Your performance will be affected by the work done by the api, the url will not have any effect on it – Ibu May 04 '11 at 23:39

3 Answers3

2

Having k= instead of api_key= in the query string, or limiting the actual api_key to X characters instead of 32 characters (md5 hash for example).

The speed difference would be so incredibly tiny -- six characters versus one character read -- that it is entirely inconsequential.

Keep in mind that while URLs don't have an RFC-spec length limit, keeping them under 2000 characters is general practice due to IE issues. Turning two thousand characters worth of query string into workable parameters is trivial, no matter what programming language you're using.

If you are seriously worrying about the performance characteristics of URL parsing, I'm going to wager that you probably need to sit down with a code profiler and find out your performance metrics actually are, because you're totally looking in the wrong place.

Community
  • 1
  • 1
Charles
  • 50,943
  • 13
  • 104
  • 142
  • That is great information, thanks very much. What about from the perspective of bandwidth? – Stoosh May 04 '11 at 23:54
  • 1
    @Stoosh, bandwidth could be a minor concern, but I expect the actual API arguments -- not the API key boilerplate, etc -- to be a larger concern... and the full HTTP headers to be a much, much larger concern. It'll add up. (This argument is usually made about cookies with large values as well.) – Charles May 05 '11 at 00:08
2

It won't count much on server load or speed, but probably on bandwidth. URLs are part of the HTTP messages that get send around to and from your API and if there are many, well every byte counts as the difference get's multiplied by each HTTP message.

But the size of the queryinfo part is only a very little aspect of it - but well, it may play a role in what you're doing - I can not really tell :) E.g. if bandwidth is the bottleneck, then your optimization idea might help (a little bit).

hakre
  • 193,403
  • 52
  • 435
  • 836
1

This will never be your bottleneck.

Don't worry about it at all.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055