<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by sdksb on Medium]]></title>
        <description><![CDATA[Stories by sdksb on Medium]]></description>
        <link>https://medium.com/@sdksb?source=rss-7eca4e22a873------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*k0H_vt9VbNgzfxGmJcUC_g.jpeg</url>
            <title>Stories by sdksb on Medium</title>
            <link>https://medium.com/@sdksb?source=rss-7eca4e22a873------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 04:27:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sdksb/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Data Science of AWS Spot Pricing]]></title>
            <link>https://medium.com/cloud-uprising/the-data-science-of-aws-spot-pricing-8bed655caed2?source=rss-7eca4e22a873------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bed655caed2</guid>
            <category><![CDATA[ipython]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[spot]]></category>
            <dc:creator><![CDATA[sdksb]]></dc:creator>
            <pubDate>Mon, 14 Sep 2015 15:08:56 GMT</pubDate>
            <atom:updated>2015-09-15T04:22:36.719Z</atom:updated>
            <content:encoded><![CDATA[<p>Amazon Web Services is the 800-lb gorrilla in Cloud Computing and provides a number of different pricing models ranging from pay-per-use (<em>on-demand</em>), fixed (<em>reserved</em>), and auction-based (s<em>pot</em>). This spot model is on the order of 8–10x cheaper as compared with on-demand, but with a twist: since instances in the spot market are auctioned, you may or may not “win” the auction. Even if you win and get the instances you asked for, you may subsequently loose them with little notice depending on the next auction and how others are bidding. Despite this added complexity, with almost an order of magnitude cost savings, it is worth exploring how to use Spot in at least part of your workloads.</p><p>AWS provides data on spot market prices for each instance type in each availability zone (AZ) for the trailing 90 days. For example, Figure 1 shows the market price for a <em>c3.8xlarge</em> in the <em>us-east-1a</em> AZ for the past week. On average, its 2x below the on-demand price of $1.68/hr, but <strong>there are spikes in the pricing that push the price up 10x (!) over the on-demand price</strong>. When the market price exceeds your bid price, then your resources will be lost with very little notice. So you have to set a bid price balancing volatility and cost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*BqfOurRgq3viOzqVoh0-YA.png" /><figcaption>Figure 1: Spot Market Price fluxuations for c3.8xlarge instance in us-east-1e.</figcaption></figure><p>Therefore, it’s worthwhile to build algorithms to manage your spot requests dynamically based on current market forces — similar to algorithmic trading where software decides when and what stocks to trade. Using some common open-source data science tools, I’ll show you how to access the spot market price data, manipulate and graph the data. I’ll leave it up to you to develop your own algorithms, but with the available tool set, it is accessible even to non-expert programmers.</p><p>All the code used here is accessible in a github repository (see <a href="https://github.com/lila/spot_price_history">here</a>). The toolset uses <a href="http://ipython.org/">iPython</a>, a web-based interactive programming environment similar to Mathematica or Matlab; <a href="http://pandas.pydata.org/">Pandas</a> for data manipulation; and <a href="http://matplotlib.org/">Mathplotlib</a> for graphing. You can add <a href="http://scikit-learn.org/stable/">Scikit</a> for machine learning and <a href="http://deeplearning.net/software/theano/">theano</a> for deep learning neural networks if you wish to do more analysis of the data or build your own predictive models. To run the code you will need an AWS account. Lets get started …</p><h3>Getting Started</h3><p>Assuming you have setup your AWS account, downloaded iPython and started the interactive notebook session, we can get started. We first create a new notebook and set the parameters for our analysis, including the instance types we will examine and the time frame.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f2b09f9e6758c9c57d1054916f99f102/href">https://medium.com/media/f2b09f9e6758c9c57d1054916f99f102/href</a></iframe><p>We use the Boto python library to access AWS api’s, but if you followed the link to the source code and the instructions for installing iPython, then you have boto installed. It will pull your credentials from environment variables, so make sure that AWS_ACCESS_KEY and AWS_SECRET_KEY are setup.</p><pre>% export AWS_ACCESS_KEY_ID=&lt;your access key&gt;<br>% export AWS_SECRET_ACCESS_KEY=&lt;your secret key&gt;</pre><p>Then we create a new code cell in your notebook and initialize boto using:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97a9e26892d28944efe9e3dc37accecb/href">https://medium.com/media/97a9e26892d28944efe9e3dc37accecb/href</a></iframe><p>Now, we can download the pricing data and store it into a Pandas dataframe:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/394bcda5c033bf05595cad6cc51b4d70/href">https://medium.com/media/394bcda5c033bf05595cad6cc51b4d70/href</a></iframe><p>This might look complicated, its not really. The script uses the <em>ec2.get_spot_price_history</em> api call to download the data for each instance type, and since the data may come in batches, it downloads each batch until it has all the data you are asking for. In the end, it converts the data into a dataframe so you can easily manipulate and graph it.</p><h3>Data Overview</h3><p>The data has a timestamp, instance type, availability zone, and the market price at that timestamp. The first thing we can do is plot the price over time to see the volatility of the <em>c3.8xlarge</em> market for each availability zone:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZAknM9VxqK-4VhStAcMlFQ.png" /><figcaption>Figure 2: time series graph of Spot Market Price for c3.8xlarge for different AZs.</figcaption></figure><p>This shows that pricing in different availability zones have different characteristics: initially (to the left on the graph), the price in <em>us-east-1a</em> is spiking to $6/hr quite often while the other AZs are more stable; and more recently (to the right of the graph) we see <em>us-east-1e</em> to have significant volatility.</p><p>We can also easily generate a price histogram, this time looking at a single AZ and partitioning out the data for the 4 instance types in the family:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4jwYnwFaFc9v-sVRdhTdBw.png" /><figcaption><em>Figure 3: Histogram of prices for c3 family in a single AZ, us-east-1a.</em></figcaption></figure><p>This histogram shows you that (at least for <em>us-east-1a</em> AZ) in general as you go from smaller to larger instance types the hourly price also increases: the <em>c3.xlarge</em> in green on the left is the least expensive, the <em>c3.2xlarge</em> the next expensive, and so on. The <em>c3.8xlarge, </em>in contrast, is often half as expensive as a <em>c3.4xlarge</em> which is 1/2 as powerful. When making spot requests, it is beneficial to consider multiple instance types to get the lowest price.</p><p>It is also interesting to note that each instance type has a minimum price, and the <em>c3.2xlarge</em> minimum price is almost exactly 2 times the minimum price of the <em>c3.xlarge</em>, and the <em>c3.4xlarge</em> minimum prices is 2x the <em>c3.2xlarge</em>, and so on. You can also easily generate numerical averages and variances to produce exact values in addition to visual analysis via graphs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_yo-wxRC3DH-pHcgua6QEg.png" /><figcaption>Figure 4: numeric calculation of statistical properties of market price.</figcaption></figure><h3>Price Trends</h3><p>Another hypothesis is that the market prices vary by time of day or day of the week. We can extract the hour or day of each recorded price data and determine the average/stdev for each hour of the day. Figure 5 shows both the average and standard deviation of the values by hour for the c3.xlarge instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HrgyQVkIfMf86Fq9OV7IMw.png" /><figcaption>Figure 5: average price for c3.large aggregated by hour of the day. Plot shows both median and stdev.</figcaption></figure><p>It seems the best time to use this instance is 11am UTC (which is 7am EST) when the price is 30% less than the overall average. With a low standard deviation, that indicates that this pattern is recurring.</p><p>You can similarly look at day of week patterns or other time frequencies. Pandas is an essential tool for time series data, providing filtering and resampling that are both powerful and easy to use.</p><h3>Summary</h3><p>The examples shown here show that accessing and analyzing the historical spot pricing is easy using modern data science toolsets and very simple calculations and aggregations can lead to insight that can save you significant money.</p><p>But be warned: the pricing changes week to week and even day to day. If Netflix decides they need to re-encode all their movies for the new AppleTV, then the price and availability statistics of the instances will change dramatically. Your mileage will vary and that’s why it is important to build algorithms that can adapt to market fluxuations.</p><p>With this as your basis, you can go in a number of interesting directions, for example:</p><ul><li>determine the lower bound on the probability that the market price will exceed your bid price, and hence, the probability that your resources will complete their computation,</li><li>analyze the volatility of each AZ and instance type in order to determine where to request instances,</li><li>use more advanced techniques to find recurring patterns in the data that you can then take advantage of.</li></ul><p>If you have any thoughts or comments, feel free to post here or contact me at: karan.bhatia@gmail.com</p><p>External links:</p><ul><li><a href="https://github.com/lila/spot_price_history">code repository [Github]</a></li><li><a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html">official aws spot guide [aws]</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bed655caed2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cloud-uprising/the-data-science-of-aws-spot-pricing-8bed655caed2">The Data Science of AWS Spot Pricing</a> was originally published in <a href="https://medium.com/cloud-uprising">Cloud Uprising</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[xxxyyy]]></title>
            <link>https://medium.com/@sdksb/xxxyyy-8d9d59e107d4?source=rss-7eca4e22a873------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d9d59e107d4</guid>
            <dc:creator><![CDATA[sdksb]]></dc:creator>
            <pubDate>Mon, 18 May 2015 19:46:36 GMT</pubDate>
            <atom:updated>2015-05-18T19:46:36.838Z</atom:updated>
            <content:encoded><![CDATA[<p>testing</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d9d59e107d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>