1 A METHOD FOR MINIMIZING COMPUTING CORE COSTS IN CLOUD INFRASTRUCTURES THAT HOST LOCATION-BASED ADVERTISING SERVICES A Thesis Presented to the Faculty of San Diego State University In Partial Fulfillment of the Requirements for the Degree Master of Science in Computer Science by Vikram Kumar Ramanna Spring 2013
3 iii Copyright 2013 by Vikram Kumar Ramanna All Rights Reserved
4 iv DEDICATION I dedicate this book to my family, who have always been there for me, and have never doubted my dreams.
5 v ABSTRACT OF THE THESIS A Method for Minimizing Computing Core Costs in Cloud Infrastructures that Host Location-Based Advertising Services by Vikram Kumar Ramanna Master of Science in Computer Science San Diego State University, 2013 Cloud computing provides services to a large number of remote users with diverse requirements, an increasingly popular paradigm for accessing computing resources over the Internet. A popular cloud-service model is Infrastructure as a Service (IaaS), exemplified by Amazon s Elastic Computing Cloud (EC2). In this model, users are given access to virtual machines on which they can install and run arbitrary applications, including relational database systems and geographic information systems (GIS). Location-based services (LBS) for offering targeted, real-time advertising is an emerging retail practice wherein a mobile user receives offers for goods and services through a smart phone application. These advertisements can be targeted to individual potential customers by correlating a smart phone user s interests to goods and services being offered within close proximity of the user. In this work, we examine the problem of establishing a Service Level Agreement (SLA) to determine the appropriate number of microprocessor cores required to constrain the query response time for a targeted advertisement to reach a mobile customer, within approachable distance to a Point of Sale (POS). We assume the optimum number of cores required to maintain a SLA is one which minimizes microprocessor core expenses, charged by infrastructure providers, while maximizing application service provider revenues derived from POS transaction fees. This problem is challenging because changes in the number of microprocessor cores assigned to database resources can result in changes in the time taken to transmit, receive, and interpret a targeted advertisement sent to a potential customer in motion. We develop a methodology to establish an equilibrium state between the utility gained from POS transaction revenues and costs incurred from purchasing microprocessor cores from infrastructure providers. We present different approaches based on an exponential, linear, and Huff method to model customer purchase decisions. From these models, the marginal cost and marginal revenue is calculated to determine the optimal number of microprocessor cores to purchase and assign to database resources.
6 vi TABLE OF CONTENTS PAGE ABSTRACT...v LIST OF TABLES... viii LIST OF FIGURES... ix ACKNOWLEDGEMENTS... xiii CHAPTER 1 INTRODUCTION Motivation Background REVIEW OF THE LITERATURE CLOUD COMPUTING Virtualization vs. Cloud Computing The Eucalyptus Cloud Architecture Eucalyptus Cloud Overview BUILD PRIVATE CLOUD USING EUCALYPTUS Eucalyptus Networking Modes Securing Eucalyptus Configuring Secure Sockets Layer (SSL) Add a NC Eucalyptus and AWS AWS Compatibility S3 Tools EC2 Tools Bundle and Image for Amazon EC Eucalyptus Dashboard POSTGRESQL Brief History of PostgreSQL Architectural Fundamentals of PostgreSQL...29
7 vii 5.3 Why Use PostgreSQL POSTGIS Postgres Spatial Capabilities Tools that Support PostGIS Spatial Data Types Haversine Formula Vincenty s Formula Spatial Relationships and Measurements ST_Distance ST_Distance_Sphere ST_Distance_Spheroid SYSTEM IMPLEMENTAITON AND OVERVIEW Data Mining and Simulation Setup Data Analytics and Model Assumptions Linear Model Exponential Model Huff Model Equilibrium Point EXPERIMENT RESULT AND ANALYSIS Probability Models Marginal Revenue Marginal Revenue vs. Marginal Cost CONCLUSION AND FUTURE IMPLEMENTATIONS Conclusion Future Work...89 BIBLIOGRAPHY...90
8 viii LIST OF TABLES PAGE Table 6.1. Percentage Error between the Haversine and Vincenty Methods, for Two Points on Earth that are Exactly 10, 20, 30, 40, and 50m Apart...41 Table 7.1. Amazon EC2 Pricing per Instance-Hour Consumed for Each Instance...58 Table 8.1. Nomenclature...60
9 ix LIST OF FIGURES PAGE Figure 1.1. The cycle shows different stages for a cloud consumer to determine the optimal number of microprocessor cores to invest to drive a database, based on revenue generated through point of sale transaction fees....2 Figure 1.2. Marginal revenue vs. marginal cost (MR=MC curve)....8 Figure 3.1. Eucalyptus based cloud architecture Figure 4.1. Components of Eucalyptus architecture Figure 4.2. Network architecture decision flow chart to determine the network configuration for Eucalyptus setup...23 Figure 4.3. Eucalyptus compatibility with Amazon EC2 cloud...25 Figure 4.4. Dashboard for Eucalyptus services Figure 6.1. Hierarchy of geometry and geography data types...35 Figure 6.2. Triangle in Euclidean plane transformed onto a spherical plane Figure 6.3. Law of Haversines for a spherical triangle Figure 7.1. Setup of the private Eucalyptus cloud used in this thesis Figure 7.2. Cloud microprocessor core load as a function of the number of records inserted Figure 7.3. UML diagram of database storage for a user s geospatial data Figure 7.4. Flow chart for parallel insertion of geospatial records into our Eucalyptus hosted PostgreSQL database for measuring cloud infrastructure load Figure 7.5. PostGIS API example for computing a great circle distance using the Haversine formulae and Vincenty s formulae, respectively Figure 7.6. An offer for goods and/or services sold at a point of sale are sent to users once they enter a purchase frontier, based on an interest correlation...50 Figure 7.7. A mobile application transmits geospatial information to a cloud infrastructure when a user crosses into a purchase frontier Figure 7.8. Dbacktrack is the distance a customer must backtrack to reach the point of sale upon receiving an offer Figure 7.9. Upon receiving an offer, the probability of a customer back tracking to a POS to make a purchase based on the offer received is determined by a particular probability distribution Figure Probability as a function of Dbacktrack, linear model....54
10 Figure Probability as a function of Dbacktrack, exponential model Figure Profit maximization curve with equilibrium point shown Figure Screenshot of Amazon EC2 online marginal cost calculator...57 Figure 8.1. Different stages of a smartphone user receiving an offer, once the user enters the purchase frontier Figure 8.2.Total processing time ttotal for 1,000,000, 0.5Mb geo-location records on a 10 Mbps network as a function of cloud microprocessor core count Figure 8.3. Per user processing time tuser based on geo-location data exchange on a 4G mobile network (8 Mbps download, 4 Mbps upload) for 1E6 0.5Mb geolocation records, as a function of cloud microprocessor core count Figure 8.4. Two different customer purchase scenarios, considering a POS in Fashion Valley Mall located in San Diego, California...64 Figure 8.5. Marginal per user processing time saved, based on geo-location data exchange on a 4G mobile network (8 Mbps download, 4 Mbps upload) for 1E6, 0.5Mb geo-location records, as a function of incremental cloud microprocessor core addition Figure 8.6. The distance traveled in meters by a user upon entering a purchase frontier until receiving a geo-location proximity list with one or more offers, assuming a walking speed of 5Km/h...66 Figure 8.7. Distance customer must backtrack to reach a point of sale upon receiving an offer on 4G mobile smart phone, as a function of microprocessor core count Figure 8.8. A single user at different distances D1, D2, D3, and D4 away from different POS s having different attractiveness and size, probability of the user going to a particular POS as described by Huff model Figure 8.9. A single user at different distances D1, D2, D3, and D4 away from a single POS, probability of the user going to the POS as described by proximity Huff model Figure Probability user backtracks to point of sale upon receiving offer on 4G mobile smart phone, as a function of microprocessor core count...68 Figure Probability user backtracks to point of sale upon receiving offer on 4G mobile smart phone, as a function of microprocessor core count, assuming a scaled exponential probability distribution Figure Different Dbacktrack distances travelled by a smartphone user varying the number of cores on cloud infrastructure, walking at an average rate of 5km/h Figure Probability a user backtracks to a point of sale upon receiving an offer on a 4G mobile smart phone, as a function of microprocessor core count...71 x
11 Figure Marginal revenue based on the probability of a customer backtracking to POS and making a purchase, assuming a linear model for purchase probability, and a $0.1 transaction fee on each purchase Figure Marginal revenue based on the probability of a customer backtracking to a POS and making a purchase, assuming an exponential model for purchase probability, and a $0.1 transaction fee on each purchase Figure Marginal revenue based on the probability of a customer backtracking to a POS and making a purchase, assuming a linear model for purchase probability and a $0.25 transaction fee on each purchase Figure Marginal revenue based on the probability of a customer backtracking to a POS and making a purchase, assuming an exponential model for purchase probability, and a $0.25 transaction fee on each purchase Figure Marginal revenue based on the probability of a customer backtracking to a POS and making a purchase, assuming a linear model for purchase probability, and a $0.50 transaction fee on each purchase Figure Marginal revenue based on the probability of a customer backtracking to POS and making a purchase, assuming an exponential model for purchase probability, and a $0.50 transaction fee on each purchase Figure Marginal revenue based on the probability of a customer backtracking to a POS and making a purchase, assuming a linear model for purchase probability, and a $1.00 transaction fee on each purchase Figure Marginal revenue based on the probability of a customer backtracking to a POS and making a purchase, assuming an exponential model for purchase probability, and a $1.00 transaction fee on each purchase Figure Marginal cost vs. marginal revenue: Marginal revenue based on the probability of moving to a POS using a linear Model, as on an 8 Mb/s (4G mobile network), for two sets of PostGIS APIs, for a total of 1,000,000 records of each 0.5 Mb size and T=$0.10. Marginal cost based on the Amazon t1.micro instance Figure Marginal cost vs. marginal revenue: Marginal revenue based on the probability of moving to a POS using a linear model as on an 8 Mb/s (4G mobile network), for two sets of PostGIS APIs, for a total of 1,000,000 record of each 0.5 Mb size and T=$0.5 Marginal Cost based on the Amazon t1.micro instance Figure Marginal cost vs. marginal revenue: Marginal revenue based on the probability of moving to a POS using an exponential model as on an 8 Mb/s (4G mobile network), for two sets of PostGIS APIs, for a total of 1,000,000 record of each 0.5 Mb size and T=$ Figure Marginal cost vs. marginal revenue: Marginal revenue based on the probability of moving to a POS using a linear model on an 8 Mb/s (4G mobile xi
12 network), for two sets of PostGIS APIs, for a total of 1,000,000 records of each 0.5 Mb size and T=$ Figure Marginal cost vs. marginal revenue: Marginal revenue based on the probability of moving to a POS using an exponential model on an 8 Mb/s (4G mobile network), for two sets of PostGIS APIs, for a total of 1,000,000 records of each 0.5 Mb size and T=$ Figure Marginal cost vs. marginal revenue: Marginal revenue based on the probability of the user moving to a POS using a linear model as on an 8 Mb/s (4G mobile network), for two sets of PostGIS APIs, for a total of 1,000,000 records of each 0.5 Mb size and T=$ Figure Marginal cost vs. marginal revenue: Marginal revenue based on the probability of the user moving to a POS using an exponential model as on an 8 Mb/s (4G mobile network), for two sets of PostGIS APIs, for a total of 1,000,000 records of each 0.5 Mb size and T=$ Figure 9.1. Scenario of two different users travelling at different distances from a POS. The probability of user1, who is tangential to a POS, is less likely to backtrack as indicated with a red cross...88 xii
13 xiii ACKNOWLEDGEMENTS It is a pleasure to thank the many people who made this thesis possible. This work would not have been possible without the support from my thesis chair professor Dr. Mahasweta Sarkar who gave me the chance to work on this project. I would like to gratefully acknowledge the supervision of my advisor, Dr. Christopher Paolini, who has been abundantly helpful and has assisted me in numerous ways. The discussions I had with him were invaluable. Special thanks to my thesis committee member Prof. Carl Eckberg for his support and invaluable advice. My final words go to my family. I want to thank my parents, whose love and guidance is with me in whatever I pursue
14 1 CHAPTER 1 INTRODUCTION 1.1 MOTIVATION The problem we are trying to solve in this thesis is to derive a way for cloud customers to choose, dynamically, an optimal number of microprocessor cores to drive a relational database, hosted in a cloud infrastructure, that supports location based advertising services for mobile smart-phone applications as shown in Figure 1.1. Upon choosing a particular commercial cloud provider, a mobile application firm hosts their back-end database application within a cloud instance, which is used to send offers for good or services to mobile smart-phone users. Based on the revenue generated by transaction fees charged to smart-phone users who consent to an offer received by purchasing goods or services at a point of sale, the mobile application firm then chooses to either add or remove microprocessor cores to maximize revenue. 1.2 BACKGROUND Cloud computing is a general terminology for anything that involves delivery of hosted services over the Internet or a Local Area Network (LAN). These services can be broadly classified into three categories: Infrastructure as a Service (IaaS), Platform as a Service (PaaS) and Software as a Service (SaaS). The name cloud was inspired by the symbol used to represent the Internet in many diagrams. Infrastructure as a service is sometimes referred to as Hardware-as-a-Service (Haas) and it is a provision model in which an organization outsources resources such as hardware, storage, servers, and networking components to support operations on demand. The service provider is completely responsible for running, housing, and maintaining these resources. The client typically is billed on a per-use basis. IaaS can be obtained as a public or private infrastructure, based on the type of network under which this classification is done. If the infrastructure consists of shared
15 2 Figure 1.1. The cycle shows different stages for a cloud consumer to determine the optimal number of microprocessor cores to invest to drive a database, based on revenue generated through point of sale transaction fees. resources deployed on the Internet then its public cloud, and if the infrastructure that emulates the cloud computing features is on a private network, then it is a private cloud. Listed are certain features and characteristics of IaaS: Resources are distributed as a service The resources can be dynamically scaled Variation in cost varies the utility pricing model Multiple users on a single hardware is the general concept. The IaaS model is suitable where the demand is very volatile: and there might be spikes or troughs in terms of demand of infrastructure, where there is a limit to capital expenditure and for a specific line of business, trial or temporary infrastructural needs. IaaS is a form of hosting; an IaaS provider will generally provide the hardware and administrative services needed to store applications and a platform for running applications. The scaling of memory, storage, and bandwidth are included, vendors compete on the performance and pricing offered for their dynamic services. In our work, we have built a cloud network using
16 the open source Amazon EC2 based Eucalyptus  cloud network for hosting a database and Web services required for hosting a smartphone application. A Service Level Agreement (SLA) is an agreement between a cloud provider and cloud consumer based on the complete description of a list of services provided to the consumer by the provider, along with the metrics analysis to determine whether the consumer is being delivered the services as promised by the provider. A SLA also provides details about the responsibilities of the consumer and the provider and the remedies to both if the terms of the SLA are not met, and also briefly discusses how the SLA would change over time and requirements for consumer requests. Public clouds tend to offer negotiable SLAs. The specific definitions of pertinent SLA terms are important. Below are a few definitions that are discussed in this thesis: Downtime implies more than five percent user error for a setup. Downtime Period means, for a domain, a period of ten consecutive minutes of downtime. Intermittent downtime for a period of less than ten minutes will not be counted towards any downtime periods. Monthly Uptime Percentage means total number of minutes in a calendar month minus the number of minutes of downtime suffered from all downtime periods in a calendar month, divided by the total number of minutes in a calendar month. Scheduled Downtime means those times where a cloud provider notified a customer of periods of downtime at least five days prior to the commencement of such downtime. There will be no more than twelve hours of scheduled downtime per calendar year. Scheduled downtime is not considered downtime for purposes of this Google Apps SLA , and will not be counted towards any downtime periods. Thus, an SLA is a contract with the service provider and sets expectations for the business relationship between a consumer and a provider. SLA needs to be written to protect the cloud service(s) according to the level of risk. The goal is to have an SLA which both the cloud consumer and provider can understand and agree to, including an exit strategy. The SLA should be considered as the document that establishes the business partnership between the parties and is used to mitigate any problems. In this thesis, we design a model that a cloud consumer can use to estimate the number of needed microprocessor cloud resources, based on mobile application requirements, and to establish an SLA with a particular cloud provider for meeting those requirements. 3
17 Development in technologies such as wireless networks, the Internet, Geographical information systems (GIS), and Global Positioning Systems (GPS), have given birth to a new type of information technology called Location Based Services (LBS). Location Based Services refer to computational services that locate a mobile user geographically and deliver information services to the user based on their location. A Location Based Service is a geospatial mobile-based application that provides services based on a user s geographical location. An example of such a service is a food service application that informs mobile device holders of nearby restaurants. First generations of LBSs were reactive and clientserver focused where users would query for information and received a response back from the server. With the advancement of push notification techniques, improved mobile Internet access, and widespread adoption of the Web2.0 paradigm, next generation user-to-user interactive LBSs evolved where information is pushed asynchronously to users based on their location, rather than users having to query for services. The benefits of LBSs, from the users and providers perspective are: An LBS avoids users having to manually enter their physical location and interests and search for services; the LBS automatically handles the exchange of information and services based on a user s interest. By sharing location-tagged information, there is global awareness of localized information provided by all users. Location Based Services can be classified according to the kinds of information and services provided. Common classifications include: Information Services LBS provides information about dining places, tourist attractions, gas stations, etc. Entertainment Services LBS provide some form of entertainment and are typically integrated with social media services such as Facebook, LinkedIn, and Twitter. Accident Services LBS provide information based on one s location about nearby automobile accidents, traffic congestion, or road emergencies. Navigation and Route Assistance LBS assist drivers with navigation and road selection to minimize either travel time or distance. LBS based applications are another form of networking based on places one frequents. Typically, when using LBS applications, one gain points, discounts, and other rewards from participating businesses. 4
18 According to Internet and American Life Project research : 7% of adults who go online with a mobile phone use location-based services 8% of online adults (age group 18-29) use location-based services (more than online adults in any other age group) 10% of online Hispanics use these services, more than online Caucasians (3%) or online African-Americans (5%) 6% of online men use location based services compared to 3% of women. For a typical LBS use case example, people use a mobile application to check-in at a meeting or perhaps a community-wide event (e.g. parade, football stadium, field house, and classroom). People checking in are then alerted to the presence of others that are also at the same location. There are a number of location-based applications available for mobile phones that allow user-to-user communication via texting. Geospatial functions are widely used in earth science modeling and applications. The fundamental purpose of geospatial processing is to allow the user to automate Geographical Information Science (GIS) tasks. Almost all uses of GIS involve the repetition of work, and this creates the need for methods to automate, document, and share multiple-step procedures. The geospatial processing functions in GIS have been developed over many decades and are well used in desktop-based computing. The rapid development of Web technology and smart phone applications has made it possible to share and process large volumes of distributed geospatial data through the Web and smart phone. However, a powerful, dependable and flexible information infrastructure is required to process geospatial data into information useful to mobile phone users. Cloud computing is rapidly emerging as a technology almost every business that provides or consumes software, hardware, and infrastructure can leverage. The technology and architecture that a cloud service and deployment model offers is a key area of research for deploying GIS technology to users of mobile applications. From a cloud provider s perspective, the key aspect of a cloud is the ability to dynamically scale and provide computational resources in an efficient way via the Internet. From a client mobile application provider s perspective, the ability to utilize cloud facilities, on-demand, without managing underlying infrastructure and dealing with related investments and maintenance costs to provide service to smart phone users, is of paramount importance. Some popular cloud computing platforms are Amazon Web Service (AWS) , Google App Engine , and 5
19 Microsoft Azure . Users of these platforms can request microprocessors, storage, database, and other services and therefore gain access to a suite of elastic IT infrastructure services according to the dynamic demands of smart phone users. The purpose of using storage service in, say, Amazon AWS is to manage application data by processing and storing output data for further computation. Amazon AWS platform provides two storage services: Amazon Simple Storage Service (S3) and the Amazon Elastic Block Store (EBS). Amazon EBS provides block level storage (they are volumes with network-attached, and persist independently from the life of an instance) volumes for use with Amazon EC2 instances. Amazon EBS volumes are off instance (EC2 allows scalable deployment of applications by providing a Web service through which a user can boot an Amazon Machine Image to create a virtual machine) storage that persists independently from the life of an instance, which allows the user to create volumes that can be mounted as devices by EC2 instances. Compared with Amazon EBS, S3 is subject to delay in writes appearing in the system whereas EBS has no consistency delays. Also EBS can only be accessed by one machine at a time whereas snapshots on S3 can be shared. Amazon S3 provides a highly durable storage infrastructure designed for mission-critical and primary data storage. Some GIS enterprises, such as the Economic and Social Research Institute (ESRI), have made certain progress in moving their products and services into cloud computing. ESRI, in collaboration with Amazon, uses the public cloud environment in several different ways, and currently the following options are available from ESRI that can be deployed on AWS: ArcGIS Server ArcLogistics (a cloud application for optimizing navigation routing) Business Analyst Online (a cloud application for geographic analysis of demographic, consumer, business, and other data) Geospatial processing functions have been developed within professional GIS applications for over decades. However, most commercial GIS packages do not support an open processing and analysis environment, which means that geospatial functions can only be used under their own proprietary software s. Hence, geospatial processing functions that are required to implement location based services need to be adapted to the cloud computing 6
20 7 environment. A cloud platform should have the ability to scale computing resources up or down, automatically, according to current mobile application usage conditions. Single-core geospatial processing using only one microprocessor core within a cloud platform could not show the advantage of cloud computing, which is the flexibility to increase the number of computing resources during demand spikes. In this context, the desired SLA is between a mobile app provider and the cloud platform provider and the agreement is to always deliver the least number of cores required to maximize transaction revenue to the client app provider, such capability is a major feature of cloud computing and is necessary to maintain a desired SLA. When demand decreases, it is also necessary to scale down assigned computing resources to minimize costs to the mobile application provider. First, the geospatial processing functions deployed within a cloud computing platform should provide such flexibility in a transparent way to end-users. Second, because most current commercial cloud computing providers do not provide free usage, the consumer should take economic costs into account when deploying a mobile application in a commercial cloud environment. We have designed a new methodology to consider both of these factors. There is an extensive literature on resource management techniques for commercial data centers. Utility is often adopted as a metric for resource allocation; building frameworks using these utility functions can be used to optimize resources. Utility functions provide criteria for trading off between multiple competing systems. In this thesis, we propose and evaluate a new model for maximizing the net revenue of a cloud consumer who deploys location-based mobile applications, where net revenue is defined as the fees received from providing location based services to smart phone users minus fees paid for cloud infrastructure usage. RT C (1.1) Fees Fees where R is net revenue, T Fees is fees received from providing LBS to smart phone user, C Fees is the cloud infrastructure usage. Profit maximization is one of the important factors that a cloud consumer should always consider and it is assumed that the cloud consumer always tries to maximize profit. The intersection of marginal revenue and marginal cost is the equilibrium point. There are
21 8 several approaches to explain the equilibrium point regarding profit maximization. One is the marginal revenue (MR)-marginal cost (MC) approach . Our model uses the MR-MC approach. If a cloud customer wants to maximize profit, it must choose that level of equilibrium point where the marginal cost equals marginal revenue. Marginal cost, in the context of our model, is defined as the increase in the cost paid by the mobile application provider of investing in exactly one more additional resource in the cloud infrastructure. Marginal revenue is defined as the change in total revenue as a result of an additional unit of resource added in the cloud infrastructure. Equivalently, this is the slope of the total revenue function. Where marginal cost is less than marginal revenue, for each extra unit invested in adding a resource, the revenue will be greater than the cost, so more investment should be done on adding the resource into the cloud infrastructure to maximize profit as shown in Figure 1.2. Where marginal cost is greater than marginal revenue, for each extra unit invested in adding a resource, the revenue will be less than the cost, hence further investment on adding the resource into the cloud infrastructure would decrease profit. Figure 1.2. Marginal revenue vs. marginal cost (MR=MC curve).