Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

[This is a cross-post originally posted by me in SO. I think the question is more appropriate here.]

I was going through the adwords API and came across their rate sheet - .

They charge $0.25 per 1000 API units and under the 'Operation Costs' sections list the cost (in API units) of different API calls. I am curious - based on what factors do they (and others API developers) calculate the cost of an API call? Is there any simple formula or a standard way to determine this?

Note: When I say 'cost' of an API call, I don't mean the money but the API units. For example, how do you determine one API call costs 100 'units' and another 1000?

Expanding my original post: Each API call will consume a specific amount of CPU cycles, memory and bandwidth on the server (and perhaps some other metric I haven't thought of). I would specifically like to know what tools / methods are available to determine these metrics if the API is developed using (any of the below combination):

Perl, Python, PHP, .net, Ruby (or some other language).

Postgres, MySQL, MS SQL Server, Firebird, SQLite (or some other database).

Apache, IIS (or some other webserver).

Windows, Linux (or some other OS).

share|improve this question

closed as off-topic by durron597, ratchet freak, MichaelT, GlenH7, Snowman Jul 18 '15 at 14:51

  • This question does not appear to be about software development within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

I'm voting to close this question as off-topic because it is not about a conceptual programming problem within the scope defined in the help center. – durron597 Jul 17 '15 at 21:11
up vote 2 down vote accepted

Typically, you would do load-testing and come to the conclusion "we can comfortably service 50,000 requests per day per server", and then using "the average running costs of one server is $1 [a guess] per day, therefore it costs 2c per 1,000 requests". You could do similar load tests on each API call to determine the relative cost of each.

It doesn't really matter what platform or language you're using, the method of load-testing is basically the same.

Note that economies of scale play significantly into this as well. For a company like Google to add one more server to their data centre adds practically zero to their incremental costs. They don't charge you per API call to recover costs, but to prevent abuse. If everyone was hammering their servers all day with requests to update reports and so on, it's going to have an affect. So they charge a (nominal) fee which basically just forces you to think twice about your own requirements (do I really need to update this report every 30 seconds?)

share|improve this answer
Now why didn't I think of that!? Load testing each API call is an awesome (and much simpler) idea than trying to profile the code to determine cpu cycles, memory usage etc. (Ofcourse, there might be some areas where load testing alone won't help - for example, API's that return different amount of data from the db - nevertheless, a really good idea). Thanks! – Sam Jan 13 '11 at 0:57

The API units are just a currency conversion, because it's easier to talk about 1000 API units than it is to talk about fractions of a cent.

They know that one API call costs 100 units because they know it costs them $.00125 (assuming a 100% markup on what they charge the customer).

They know it costs them $.00125 for that API call, because they have performed some complex calculation that takes into account their cost per hour (equipment costs, electricity costs, support costs, everything), and they divide that by how long it takes for the API call to execute on average (or some similar metric).

They know that the other API call costs 1000 units because it takes ten times longer to execute than the first call (or uses ten times as many processor cycles, or whatever their metric happens to be).

share|improve this answer
Thanks, Robert. What I am particularly interested in is if there are any standard tools / methods by which these metrics - cpu cycle, memory, etc. - are calculated for each API call? – Sam Jan 12 '11 at 23:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.