Hit Calculation Tutorial for Xignite Web Services

First Published Monday, 28th March 2011 06:59 am from Xand : Joel York

The opinions expressed by this blogger and those providing comments are theirs alone, this does not reflect the opinion of Automated Trader or any employee thereof. Automated Trader is not responsible for the accuracy of any of the information supplied by this article.


href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F">

/> src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F&source=xignite&style=normal&b=2"

height="61" width="50" />

One of the huge benefits of cloud computing is low risk

pay-as-you-go, usage-based pricing. Unfortunately, if you are

counting usage by anything other than users, then choosing the

best subscription plan for your needs can get a little

tricky.

At Xignite, we use a uniform usage

metric known as "hits" across all of our Web services to simplify

things. Estimating the number of hits you need for your

application is straightforward, once you get the basic idea.

However, for the first time customer it can be a little cryptic.

So, we're providing this short tutorial and some href="http://xignite.web-services-blog.com/media/xignite-hit-estimation-worksheet.xlsx"

target="_blank">handy tools to help you through the

hit calculation process. The short story is that if you can

convert inches to miles, ounces to liters, and Fahrenheit to

Celsius, then you'll have no trouble understanding how to

estimate your hits, because the math required is essentially the

same.

Before slugging through the general

approach for calculating hits, let's do a simple example to get

familiar with the concepts involved. Suppose you have a website

stock index widget that shows five common stock indices. And, the

pages that have the widget receive 10,000 pageviews per day. If

you use the href="http://www.xignite.com/xindices.asmx?op=GetDelayedValues"

target="_blank">GetDelayedValues operation of the

target="_blank">XigniteIndices Web service, then

each request to create the widget will cost 5 hits, one for each

index. Then your total monthly hits are calculated as

follows:

1.5 million hits/month =

5 hits/widget x 1 widget/pageview x 10,000 pageviews/day x 30

days/month

Not so hard. In particular, notice

how the units attached to each factor cancel out to the proper

units of the final answer (hits/month).

1.5

million hits/month =

5

hits/widget

x 1 widget/pageview

x 10,000

pageviews/day x

30

days/month

Checking the units is always a good QA method to test

the accuracy of your calculation. Just like converting inches to

miles!

The post that follows generalizes this

simple formula to provide a general method for calculating hits

for any application using any Xignite Web service.

src="http://xignite.web-services-blog.com/media/xignite-web-services-usage-hits.png"

alt="Xignite Web service hit calculation model" width="423px"

height="309px" />

Each data block

processed by a Web service operation entails a specific number of

hits. Total hits are determined by the total number of data

blocks processed in a given time window. Each time a trigger

event occurs (request frequency), the Web service operation

processes a certain number of data blocks (request population).

In most cases, there is a fixed ratio between input data blocks

and output data blocks and either can be used for hit

calculation.

Relationship between

Requests and Hits

Each time you call an

Xignite Web service operation, you rack up some hits. The number

of hits depends on the data returned by the service, so you only

pay for what you get. If you request a

stock quote for a single symbol using the href="http://www.xignite.com/xquotes.asmx?op=GetQuotes"

target="_blank">GetQuotes operation of the href="http://www.xignite.com/xquotes.asmx"

target="_blank">XigniteQuotes Web service, then a

successful return of the quote requested will cost exactly one

hit. If you request ten stock quotes using the GetQuotes

operation, then a successful return of the ten quotes will cost

ten hits. If only nine quotes are available, you are only charged

nine hits for the successfully returned quotes.

For every implementation, there is a "request data

block" that determines the number of hits for a single request to

an operation. In the examples above, the request data blocks are

single symbols and ten symbol sets with a hit cost per request of

one hit and ten hits, respectively. As in these two examples, the

request data block is the input data set for the operation in the

vast majority of cases.

However, there are

situations where the output data set must be used as the request

data block. In the simplest case, the operation has no inputs and

the request data block is the fixed output data set from the

operation, as with the href="http://www.xignite.com/xquotes.asmx?op=GetTopMovers"

target="_blank">GetTopMovers operation of

XigniteQuotes. For some of the more complex operations, such as

the href="http://www.xignite.com/xoptions.asmx?op=GetEquityOptionChain"

target="_blank">GetEquityOptionChain operation of

the

target="_blank">XigniteOptions Web service, the hit

count is determined by the number of option contracts returned by

the operation, which is not a fixed number and cannot be

determined by the input data set. In this case, you must use the

output data set. In addition, since the number of contracts in

the output data set changes with each request, you must use the

average number of contracts in the output, e.g., the request data

block is an average of five contracts returned with an average

hit cost of five hits based on the particular set of symbols that

will be requested over time.

Request

Frequency and Request Population

All Xignite

Subscription plans are quoted in maximum hits per month. So, once

you've identified the request data block and its associated hits,

the next step is to estimate the number of times an operation

will handle a request of this data block in a given month.

Multiplying the number of requests per month by the hits for each

data block gives the total number of monthly hits.

Monthly Hits = Hits per Request Data Block x Monthly

Requests

The total number of monthly requests

can be broken down into two components: request frequency and

request population. Request frequency is the speed at which

requests are cycled and is usually determined by some external

trigger event that precipitates the request on a regular basis,

like a pageview or cache refresh. Request population is the

number of data blocks processed in each request cycle.

Monthly Requests = Request Population x Request

Frequency x 1 month

For example, a real-time

quote caching process that runs every 5 seconds has a request

frequency of 12 cache refreshes / minute. If this cache process

handles 2,000 of the most popular stocks in blocks of 50 symbols,

it will have a request population of 40 50 symbol blocks per

cache refresh. Thereby, it will process 480 cache requests per

minute or about 21M requests per month. Note that the unit for

the request frequency is trigger events per unit time (cache

refreshes per minute), whereas the unit for the request

population is data blocks / trigger event (50 symbol blocks per

cache refresh).

Substituting the Monthly

Requests formula into our formula for Monthly Hits gives the

following general formula:

Monthly Hits

=

Hits per Data Block x Request Population x Request

Frequency x 1 month

Which, upon closer

inspection mirrors the formula for the the simple Web widget

example given at the beginning of this post. The request data

block is a 5 indices set or a "widget" with a

cost of 5 hits per widget. The request population is 1 widget per

pageview. The request frequency is 10,000 pageviews per day. And,

there are 30 days in 1 month.

That's

all there is to it! To make life a little easier, we've also

created a handy href="http://xignite.web-services-blog.com/media/xignite-hit-estimation-worksheet.xlsx"

target="_blank">Xignite hit estimation Excel

worksheet based on this simple model. In the next few

posts in this series, we'll use the spreadsheet to provide

complete end-to-end hit calculation for common applications, such

as stock portfolios, currency converters, EOD updates to

historical databases, real-time price caching, etc. In the

meantime, you can always get help from your account manager at

sales@xigntie.com.

Share and Enjoy: rel="nofollow" target="_blank"

href="mailto:?subject=Hit%20Calculation%20Tutorial%20for%20Xignite%20Web%20Services&body=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F"

title="email"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/email_link.png"

title="email" alt="email" class="sociable-hovers" />

href="http://twitter.com/home?status=Hit%20Calculation%20Tutorial%20for%20Xignite%20Web%20Services%20-%20http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F"

title="Twitter"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/twitter.png"

title="Twitter" alt="Twitter" class="sociable-hovers"

/>

href="http://www.facebook.com/share.php?u=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F&t=Hit%20Calculation%20Tutorial%20for%20Xignite%20Web%20Services"

title="Facebook"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/facebook.png"

title="Facebook" alt="Facebook" class="sociable-hovers"

/>

href="http://www.linkedin.com/shareArticle?mini=true&url=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F&title=Hit%20Calculation%20Tutorial%20for%20Xignite%20Web%20Services&source=Financial+Market+Data+Web+Services+-+Xignite+Blog+It%26%23039%3Bs+not+the+data.++It%26%23039%3Bs+the+delivery.&summary=At%20Xignite%2C%20we%20use%20a%20uniform%20usage%20metric%20known%20as%20%E2%80%9Chits%E2%80%9D%20across%20all%20of%20our%20Web%20services%20to%20simplify%20things.%20%20To%20make%20life%20a%20little%20easier%2C%20we%E2%80%99ve%20also%20created%20a%20handy%20hit%20estimation%20Excel%20worksheet%20based%20on%20this%20simple%20model."

title="LinkedIn"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/linkedin.png"

title="LinkedIn" alt="LinkedIn" class="sociable-hovers"

/>

href="http://digg.com/submit?phase=2&url=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F&title=Hit%20Calculation%20Tutorial%20for%20Xignite%20Web%20Services&bodytext=At%20Xignite%2C%20we%20use%20a%20uniform%20usage%20metric%20known%20as%20%E2%80%9Chits%E2%80%9D%20across%20all%20of%20our%20Web%20services%20to%20simplify%20things.%20%20To%20make%20life%20a%20little%20easier%2C%20we%E2%80%99ve%20also%20created%20a%20handy%20hit%20estimation%20Excel%20worksheet%20based%20on%20this%20simple%20model."

title="Digg"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/digg.png"

title="Digg" alt="Digg" class="sociable-hovers" />

href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F&title=Hit%20Calculation%20Tutorial%20for%20Xignite%20Web%20Services"

title="StumbleUpon"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/stumbleupon.png"

title="StumbleUpon" alt="StumbleUpon" class="sociable-hovers"

/>

href="http://technorati.com/faves?add=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F"

title="Technorati"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/technorati.png"

title="Technorati" alt="Technorati" class="sociable-hovers"

/>

href="http://twitter.com/home/?status=tip%20@Techmeme%20http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F%20Hit%20Calculation%20Tutorial%20for%20Xignite%20Web%20Services"

title="Suggest to Techmeme via Twitter"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/techmeme.png"

title="Suggest to Techmeme via Twitter" alt="Suggest to Techmeme

via Twitter" class="sociable-hovers" /> rel="nofollow" target="_blank"

href="http://delicious.com/post?url=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F&title=Hit%20Calculation%20Tutorial%20for%20Xignite%20Web%20Services&notes=At%20Xignite%2C%20we%20use%20a%20uniform%20usage%20metric%20known%20as%20%E2%80%9Chits%E2%80%9D%20across%20all%20of%20our%20Web%20services%20to%20simplify%20things.%20%20To%20make%20life%20a%20little%20easier%2C%20we%E2%80%99ve%20also%20created%20a%20handy%20hit%20estimation%20Excel%20worksheet%20based%20on%20this%20simple%20model."

title="del.icio.us"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/delicious.png"

title="del.icio.us" alt="del.icio.us" class="sociable-hovers"

/>

href="http://www.google.com/bookmarks/mark?op=edit&bkmk=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F&title=Hit%20Calculation%20Tutorial%20for%20Xignite%20Web%20Services&annotation=At%20Xignite%2C%20we%20use%20a%20uniform%20usage%20metric%20known%20as%20%E2%80%9Chits%E2%80%9D%20across%20all%20of%20our%20Web%20services%20to%20simplify%20things.%20%20To%20make%20life%20a%20little%20easier%2C%20we%E2%80%99ve%20also%20created%20a%20handy%20hit%20estimation%20Excel%20worksheet%20based%20on%20this%20simple%20model."

title="Google Bookmarks"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/googlebookmark.png"

title="Google Bookmarks" alt="Google Bookmarks"

class="sociable-hovers" />

target="_blank"

href="https://favorites.live.com/quickadd.aspx?marklet=1&url=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F&title=Hit%20Calculation%20Tutorial%20for%20Xignite%20Web%20Services"

title="Live"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/live.png"

title="Live" alt="Live" class="sociable-hovers" />

href="http://www.friendfeed.com/share?title=Hit%20Calculation%20Tutorial%20for%20Xignite%20Web%20Services&link=http%3A%2F%2Fxignite.web-services-blog.com%2F2011%2F02%2Fhit-calculation-tutorial-for-xignite-web-services%2F"

title="FriendFeed"> src="http://xignite.web-services-blog.com/wp-content/plugins/sociable/images/friendfeed.png"

title="FriendFeed" alt="FriendFeed" class="sociable-hovers"

/>

  • Copyright © Automated Trader Ltd 2013 - The Gateway to Algorithmic and Automated Trading

click here to return to the top of the page