Hit Calculation Tutorial for Xignite Web Services

from Xand : Joel York - 31st December 1969

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.

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 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 GetDelayedValues operation of the 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.

Xignite Web service hit calculation model

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 GetQuotes operation of the 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 GetTopMovers operation of XigniteQuotes. For some of the more complex operations, such as the GetEquityOptionChain operation of the 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 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: email Twitter Facebook LinkedIn Digg StumbleUpon Technorati Suggest to Techmeme via Twitter del.icio.us Google Bookmarks Live FriendFeed

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

advert
click here to return to the top of the page