9

[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 - http://code.google.com/apis/adwords/docs/ratesheet.html .

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).

Sam
  • 231
  • 1
  • 2
  • 8
  • 4
    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/on-topic]. – durron597 Jul 17 '15 at 21:11
  • @Sam were you able to find any more relevant information to help you with pricing an api call? – Ted Taylor of Life Sep 29 '17 at 16:11
  • I have priced an API before. Apart from knowing your costs which are key to know how low you could go as well as give yourself some space for error and profit, you should try to "reverse engineer" the price from your client's budget. What is an acceptable portion of his/her expenses going to you? That is a question that you should ask yourself and your potential clients. – David Lopez Dec 02 '18 at 07:50

2 Answers2

4

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).

Robert Harvey
  • 198,589
  • 55
  • 464
  • 673
  • 1
    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
3

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?)

Dean Harding
  • 19,871
  • 3
  • 51
  • 70
  • 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 00:57