Mobile Cloud Computing
Satish [email protected]
MTAT.03.262 - Mobile Application Development – Lecture 8
Outline
• Cloud Computing
• Mobile Cloud
– Binding Models
• HomeAssignment3
11/3/2017 Satish Srirama 2/48
WHAT IS CLOUD COMPUTING?
No consistent answer!Everyone thinks it is something else…
“It’s nothing new”“...we’ve redefined Cloud Computing to include everything that we already do... I don’t understand what we would do differently ... other than change the wording of some of our ads.”
Larry Ellison, CEO, Oracle (Wall Street Journal, Sept. 26, 2008)
“It’s a trap”“It’s worse than stupidity: it’s marketing hype. Somebody is saying this is inevitable—and whenever you hear that, it’s very likely to be a set of businesses campaigning to make it true.”
Richard Stallman, Founder, Free Software Foundation (The Guardian, Sept. 29, 2008)
Slide taken from Professor Anthony D. Joseph’s lecture at RWTH Aachen11/3/2017 Satish Srirama 3
What is Cloud Computing?
• Computing as a utility
– Utility services e.g. water, electricity, gas etc
– Consumers pay based on their usage
11/3/2017 Satish Srirama 4/48
Clouds - Why Now (not then)?
• Experience with very large datacenters– Unprecedented economies of scale
– Transfer of risk
• Technology factors– Pervasive broadband Internet
– Maturity in Virtualization Technology
• Business factors– Minimal capital expenditure
– Pay-as-you-go billing model
11/3/2017 Satish Srirama 6/48
• Virtualization techniques are the basis of the cloud computing
• Virtualization technologies partition hardware and thus provide flexible and scalable computing platforms
• Virtual machine techniques– VMware and Xen– OpenNebula– Amazon EC2
• Recent updates - containers
Virtualization
Hardware
OS
App App App
Hypervisor
OS OS
Virtualized Stack11/3/2017 Satish Srirama 7/48
Containers
• Use kernel of the host operating system instead of a hypervisor– Linux namespace
• Lightweight– No hypervisor overhead– Each Container acquires only required resources
• Fast start-up/ Bootup– Starting a container is faster than booting new OS or spinning up a
new VM
• Performance– Near native performance
• Different container frameworks– LXC, Docker, Linux VServer, OpenVZ– Docker is an Open platform [https://www.docker.com/]
11/3/2017 Satish Srirama 8/48
Cloud Computing - Characteristics
• Illusion of infinite resources
• No up-front cost
• Fine-grained billing (e.g. hourly)
• Gartner: “Cloud computing is a style of computing where massively scalable IT-related capabilities are provided ‘as a service’ across the Internet to multiple external customers”
11/3/2017 Satish Srirama 9/48
Cloud Computing - Services• Software as a Service – SaaS
– A way to access applications hosted on the web through your web browser
• Platform as a Service – PaaS– Provides a computing platform
and a solution stack (e.g. LAMP) as a service
• Infrastructure as a Service –IaaS– Use of commodity computers,
distributed across Internet, to perform parallel processing, distributed storage, indexing and mining of data
– Virtualization
SaaS
Facebook, Flikr, Myspace.com, Google maps API, Gmail
PaaS
Google App Engine, Force.com, Hadoop, Azure,
Heroku, etc
IaaS
Amazon EC2, Rackspace, GoGrid, SciCloud, etc.
Level ofAbstraction
11/3/2017 Satish Srirama 10/48
Cloud Computing - Themes
• Massively scalable• On-demand & dynamic• Only use what you need - Elastic
– No upfront commitments, use on short term basis
• Accessible via Internet, location independent• Transparent
– Complexity concealed from users, virtualized, abstracted
• Service oriented – Easy to use SLAs
SLA – Service Level Agreement
11/3/2017 Satish Srirama 11/48
Cloud Models
• Internal (private) cloud– Cloud with in an organization
• Community cloud– Cloud infrastructure jointly
owned by several organizations • Public cloud
– Cloud infrastructure owned by an organization, provided to general public as service
• Hybrid cloud– Composition of two or more
cloud models
11/3/2017 Satish Srirama 12/48
Cloud Application Demand
• Many cloud applications have cyclical demand curves– Daily, weekly, monthly, …
• Workload spikes are more frequent and significant– When some event happens like a pop star has expired:
• More # tweets, Wikipedia traffic increases• 22% of tweets, 20% of Wikipedia traffic when Michael Jackson expired in 2009
– Google thought they are under attack
Demand
Time
Reso
urc
es
11/3/2017 Satish Srirama 13/48
Unused resources
Economics of Cloud Users
• Pay by use instead of provisioning for peak
Static data center Data center in the cloud
Demand
Capacity
Time
Reso
urc
es
Demand
Capacity
Time
Reso
urc
es
11/3/2017 Satish Srirama 14/48
Unused resources
Economics of Cloud Users - continued
• Risk of over-provisioning: underutilization
– Huge sunk cost in infrastructure
Static data center
Demand
Capacity
Time
Reso
urc
es
11/3/2017 Satish Srirama 15/48
Economics of Cloud Users - continued
• Heavy penalty for under-provisioning
Lost revenue
Lost users
Reso
urc
es
Demand
Capacity
Time (days)1 2 3
Reso
urc
es
Demand
Capacity
Time (days)1 2 3
Reso
urc
es
Demand
Capacity
Time (days)1 2 3
11/3/2017 Satish Srirama 16/48
Optimal resource provisioning for auto-scaling enterprise applications
• Auto-Scaling– Scaling policy -> When to Scale– Resource provisioning policy -> How to scale
• Cloud providers offer various instance types with different processing power and price– Can it be exploited in deciding the resource provisioning policy?– Makes the policy to be aware of current deployment
configuration
• Another challenge: Cloud providers charge the resource usage for fixed time periods– E.g. Hourly prices of Amazon cloud
• Developed an LP based optimization model which considers both the issues [Srirama and Ostovar, CloudCom 2014]
11/3/2017 Satish Srirama 17/48
Scaling enterprise application with the optimization model
11/3/2017 Satish Srirama
Incoming load and scaling curves of Optimization model
Instance type usage curves of Optimization model
Scaling with Amazon AutoScale
[Srirama and Ostovar, CloudCom 2014]
Basics of Cloud Computing - MTAT.08.027 (Spring 2018)18/48
Short Term Implications of Clouds
• Startups and prototyping
– Minimize infrastructure risk
– Lower cost of entry
• Batch jobs
• One-off tasks
– Washington post, NY Times
• Cost associatively for scientific applications
• Research at scale
11/3/2017 Satish Srirama 19/48
Long Term Implications of clouds
• Application software:
– Cloud & client parts, disconnection tolerance
• Infrastructure software:
– Resource accounting, VM awareness
• Hardware systems:
– Containers, energy proportionality
11/3/2017 Satish Srirama 20/48
Economics of Cloud Providers
• Cloud Computing providers bring a shift from high reliability/availability servers to commodity servers– At least one failure per day in large datacenter
• Why?– Significant economic incentives
• much lower per-server cost
• Caveat: User software has to adapt to failures– Very hard problem!
• Solution: Replicate data and computation– MapReduce & Distributed File System
11/3/2017 Satish Srirama
Basics of Cloud Computing - MTAT.08.027 (Spring 2018)[Srirama et al, FGCS 2012]21/48
Mobile Cloud Computing
• One can do interesting things on mobiles directly– Today’s mobiles are far more capable
– We can even provide services from smart phones[Srirama et al, ICIW 2006; Srirama and Paniagua, MS 2013; Chang et al, ICSOC 2012; Liyanage et al, MS 2015]
• Already have checked in lecture 6
• However, some applications need to offload certain activities to servers– Processing sensor data
• Resource-intensive processing on the cloud – To enrich the functionality of mobile applications
11/3/2017 Satish Srirama 23/48
Mobile Cloud Applications
• Bring the cloud infrastructure to the proximity of the mobile user
• Mobile has significant advantage by going cloud-aware
– Increased data storage capacity
– Availability of unlimited processing power
– PC-like functionality for mobile applications
– Extended battery life (energy efficiency)
11/3/2017 Satish Srirama 24/48
Demo
• Demonstrate the trade-off of using Mobile Cloud
– Image processing application
11/3/2017 Satish Srirama 25/48
Mobile cloud - Binding models
Task Delegation Code Offloading
MCM
[Flores and Srirama, JSS 2014] [Flores et al, IEEE Communications Mag 2015]
11/3/2017 Satish Srirama 26/48
Task Delegation: Mobile Cloud mash-up applications
• Mobiles may have to take advantage of multiple clouds
• Follows traditional SOA (Service Oriented Architecture) model to invoke services
• Typical scenarios – Process intensive services
• Face recognition, sensor mining etc.
• Critical challenges – Cloud interoperability is a huge trouble
– Mobiles need to possess multiple APIs
– Unavailability of standards and mobile platform specific API
11/3/2017 Satish Srirama 27/48
Mobile Cloud Middleware
[Flores et al, MoMM 2011; Flores and Srirama, JSS 2014]
[Srirama and Paniagua, MS 2013]
11/3/2017
[Warren et al, IEEE PC 2014]
Satish Srirama
Google Cloud Messaging
Microsoft Push Notification
Service
28/48
MCM – enables
• Interoperability between different Cloud Services (IaaS, SaaS, PaaS) and Providers (Amazon, Eucalyptus, etc)
• Provides an abstraction layer on top of API
• Composition of different Cloud Services
• Asynchronous communication between the device and MCM
• Means to parallelize the tasks and take advantage of Cloud’s intrinsic characteristics
11/3/2017 Satish Srirama 29/48
CroudSTag – Scenario
• CroudSTag takes the pictures/videos from the cloud and tries to recognize people – Pictures/Videos are actually taken by the phone
– Processes the videos
– Recognizes people using facial recognition technologies
• Reports the user a list of people recognized in the pictures
• The user decides whether to add them or not to the social group
• The people selected by the user receive a message in facebook inviting them to join the social group
11/3/2017 Satish Srirama 30/48
CroudSTag [Srirama et al, PCS 2011;
SOCA 2012]
• Cloud services used
– Media storage on Amazon S3
– Processing videos on Elastic MapReduce
– face.com to recognize people on facebook
– Starting social group on facebook
11/3/2017 Satish Srirama 31/48
Other applications
• Zompopo [Srirama et al, NGMAST 2011]
– Intelligent calendar, by mining accelerometer sensor data
• Bakabs [Paniagua et al, iiWAS-2011]
– Managing the Cloud resources from mobile
• Sensor data analysis– Human activity recognition – Context aware gaming– MapReduce based sensor data analysis [Paniagua et al, MobiWIS
2012]
• SPiCa: A Social Private Cloud Computing Application Framework [Chang et al, MUM 2014]
11/3/2017 Satish Srirama 32/48
Checking for updates
• Polling
• Polling consumes lot of battery of mobile • Heavy load on the resources of the server• Strains the network
11/3/2017 Satish Srirama
Any new updates ?
No
Any new updates ?
No
Any new updates ?
YES
33/48
Firebase Cloud Messaging
• Free service that allows you to send data from your servers to your users and vice versa
• FCM replaced Google Cloud Messaging (GCM)– GCM is now deprecated
• Firebase by platform– Goes beyond just messaging– Firebase provides the tools to develop high-quality apps,
grow your user base, and earn more money– Provides services for Authentication, Realtime Database,
Performance Monitoring, Cloud Storage, Analytics, AdWords etc.
– https://firebase.google.com/docs/
11/3/2017 Satish Srirama 34/48
Firebase Cloud Messaging (FCM) -continued
• A cross-platform messaging solution – Can now send messages to Android, iOS, etc.
• Handles queuing of messages and delivery to the target application– Application does not need to be running in the background for
receiving data messages– The system will wake up the Android application via Intent
broadcast when the message arrives
• FCM also supports sending messages to multiple phones, to devices subscribed to topics etc.
• FCM also supports sending messages to the application server from the mobile– Using the Extensible Messaging and Presence Protocol (XMPP)
11/3/2017 Satish Srirama 35/48
Working with FCM
11/3/2017 Satish Srirama
Mobile App
FCM
1.Request for Registration
2.Reply with Registration Id
5. Send Message
3.Send Registration Id 4. Send message {RegId, msg}
https://firebase.google.com/docs/cloud-messaging/
36/48
Working with FCM – Course Exercise
• Add Firebase to your app
https://firebase.google.com/docs/android/setup
• If there are problems such as
– failed to resolve compile 'com.google.firebase:firebase-messaging:10.0.1'
– install Google Play Services and Google Repository in Android Studio, SDK Manager on SDK Tools tab
• Access the device registration token and log it
11/3/2017 Satish Srirama
String token = FirebaseInstanceId.getInstance().getToken();
37/48
FCM – Course Exercise - continued
• Create a service that extends FirebaseMessagingService
• Add the following to the manifest file
• Override onMessageReceived(RemoteMessageremoteMessage) of the service to read the message
11/3/2017 Satish Srirama
<serviceandroid:name=".MyFirebaseMessagingService"><intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/></intent-filter>
</service>
38/48
FCM – Course Exercise - continued
• Sending a notification message
– Install and run the app on the target device
– Open the Notifications tab of the Firebase consoleand select New Message
– Enter the message text
– Select Single Device for the message target
– In the field labelled FCM Registration Token, enter the registration token you obtained
– Click send message
11/3/2017 Satish Srirama 39/48
Mobile cloud - Binding models
Task Delegation Code Offloading
MCM
[Flores and Srirama, JSS 2014] [Flores et al, IEEE Communications Mag 2015]
11/3/2017 Satish Srirama 40/48
Code Offloading
• Also known as Cyber-foraging [M. Satyanarayanan, 2001]
• Not a completely new topic
– Can be realized similar to RMI, RPC etc.
• Devices offload some of their heavy work to stronger surrogate machines in the vicinity (Cloudlets)
11/3/2017 Satish Srirama 41/48
Major Components
• Mobile– Code profiler
– System profilers
– Decision engine
• Cloud based surrogate platform
11/3/2017 Satish Srirama 42/48
Some of the well known frameworks
• MAUI
– Manual annotations [Cuervo et al., 2010]
• CloneCloud
– Code profilers & Automated process [Chun et al., 2011]
• ThinkAir
– Manual annotations and scalability [Kosta et al, 2012]
• EMCO [Flores and Srirama, MCS 2013] & etc.
11/3/2017 Satish Srirama 43/48
Code offloading – Major challenges
• Work in controlled environments like nearby servers
– However, none can be adapted for real life applications
• Major research challenges
– What, when, where and how to offload?
11/3/2017 Satish Srirama
[Flores et al, IEEE Communications Mag 2015]
44/48
Practical adaptability of offloading
Applications that can benefit became limited with increase in device capacities11/3/2017 Satish Srirama 45/48
Conclusion
• Cloud computing offers interesting opportunities in different domains
• Mobile applications benefit a lot by pushing some of the resource intensive tasks to cloud
• Checked two binding models
– Task Delegation
– Code offloading
11/3/2017 Satish Srirama 46/48
What have we learnt?
• You can develop Android applications
• Location based services
• Sensors and Internet of Things
• Providing sensor information from smart phones
• Testing android applications
• Multi-platform mobile application development
• Mobile Cloud
11/3/2017 Satish Srirama 47/48
Home Assignment - 3
• Image processing on the cloud
• Being able to repeat the task demonstrated in the lecture
• Deadline – 16th November 2017
• Last deadline for all submissions – 23rdNovember 2017
11/3/2017 Satish Srirama 48/48
References• S. N. Srirama, A. Ostovar: Optimal Resource Provisioning for Scaling Enterprise Applications on the Cloud, The 6th IEEE International Conference on
Cloud Computing Technology and Science (CloudCom-2014), December 15-18, 2014, pp. 262-271. IEEE.• S. N. Srirama, P. Jakovits, E. Vainikko: Adapting Scientific Computing Problems to Clouds using MapReduce, Future Generation Computer Systems
Journal, 28(1):184-192, 2012. Elsevier press. DOI 10.1016/j.future.2011.05.025.• S. N. Srirama, M. Jarke, W. Prinz: Mobile Web Service Provisioning, Proceedings of the Advanced International Conference on Telecommunications
and International Conference on Internet and Web Applications and Services (AICT-ICIW 2006), February 23-25, 2006, pp. 120-125. IEEE CS Press.• S. N. Srirama, C. Paniagua: Mobile Web Service Provisioning and Discovery in Android Days, The 2013 IEEE International Conference on Mobile
Services (MS 2013), June 27 - July 02, 2013, pp. 15-22. IEEE.• C. Chang, S. N. Srirama, S. Ling: An Adaptive Mediation Framework for Mobile P2P Social Content Sharing, 10th International Conference on Service
Oriented Computing (ICSOC 2012), November 12-16, 2012, pp. 374-388. Springer LNCS.• M. Liyanage, C. Chang, S. N. Srirama: Lightweight Mobile Web Service Provisioning for Sensor Mediation, 4th International Conference on Mobile
Services (MS 2015), June 27 - July 2, 2015, pp. 57-64. IEEE. • H. Flores, S. N. Srirama: Mobile Cloud Middleware, Journal of Systems and Software, ISSN: 0164-1212, 92(1):82-94, 2014. Elsevier. DOI:
10.1016/j.jss.2013.09.012.• H. Flores, P. Hui, S. Tarkoma, Y. Li, S. N. Srirama, R. Buyya: Mobile Code Offloading: From Concept to Practice and Beyond, IEEE Communications
Magazine, ISSN: 0163-6804, 53(3):80-88, 2015. IEEE. DOI:10.1109/MCOM.2015.7060486• I. Warren, A. Meads, S. N. Srirama, T. Weerasinghe, C. Paniagua: Push Notification Mechanisms for Pervasive Smartphone Applications, IEEE
Pervasive Computing, ISSN: 1536-1268, 13(2):61-71, 2014. IEEE. DOI:10.1109/MPRV.2014.34.• H. Flores, S. N. Srirama, C. Paniagua: A Generic Middleware Framework for Handling Process Intensive Hybrid Cloud Services from Mobiles, The 9th
International Conference on Advances in Mobile Computing & Multimedia (MoMM-2011), December 5-7, 2011, pp. 87-95. ACM.• S. N. Srirama, C. Paniagua, H. Flores: CroudSTag: Social Group Formation with Facial Recognition and Mobile Cloud Services, The 8th International
Conference on Mobile Web Information Systems (MobiWIS 2011), September 19-21, 2011, v. 5 of Procedia Computer Science, pp. 633-640. Elsevier. • S. N. Srirama, C. Paniagua, H. Flores: Social Group Formation with Mobile Cloud Services, Service Oriented Computing and Applications Journal, ISSN:
1863-2386, 6(4):351-362, 2012. Springer. DOI: 10.1007/s11761-012-0111-5.• S. N. Srirama, H. Flores, C. Paniagua: Zompopo: Mobile Calendar Prediction based on Human Activities Recognition using the Accelerometer and
Cloud Services, 5th Int. Conf. on Next Generation Mobile Applications, Services and Technologies (NGMAST 2011), Sep. 14-16, 2011, pp. 63-69. IEEE. • Cuervo, Eduardo, et al. "MAUI: making smartphones last longer with code offload." Proceedings of the 8th international conference on Mobile
systems, applications, and services. ACM, 2010.• Kosta, Sokol, et al. "Thinkair: Dynamic resource allocation and parallel execution in the cloud for mobile code offloading." INFOCOM, 2012
Proceedings IEEE. IEEE, 2012.• Satyanarayanan, Mahadev, et al. "The case for vm-based cloudlets in mobile computing." Pervasive Computing, IEEE 8.4 (2009): 14-23.• H. Flores, S. N. Srirama: Adaptive Code Offloading for Mobile Cloud Applications: Exploiting Fuzzy Sets and Evidence-based Learning, The Fourth ACM
Workshop on Mobile Cloud Computing and Services (MCS 2013) @ The 11th International Conference on Mobile Systems, Applications and Services (MobiSys 2013), June 25-28, 2013, pp. 9-16. ACM.
11/3/2017 Satish Srirama 49/48