Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Unit 4

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

UNIT 4

IoT PHYSICAL SERVERS AND CLOUD OFFERINGS

Introduction to Cloud Computing

The Internet of Things (IoT) involves the internet-connected devices we use to perform
the processes and services that support our way of life. Another component set to help IoT
succeed is cloud computing, which acts as a sort of front end. Cloud computing is an
increasingly popular service that offers several advantages to IOT and is based on the concept of
allowing users to perform normal computing tasks using services delivered entirely over the
internet. A worker may need to finish a major project that must be submitted to a manager, but
perhaps they encounter problems with memory or space constraints on their computing device.
Memory and space constraints can be minimized if an application is instead hosted on the
internet. The worker can use a cloud computing service to finish their work because the data is
managed remotely by a server. Another example: you have a problem with your mobile device,
and you need to reformat it or reinstall the operating system. You can use Google Photos to
upload your photos to internet-based storage. After the reformat or reinstall, you can then either
move the photos back to your device or you can view the photos on your device from the internet
when you want.

Concept

In truth, cloud computing and IoT are tightly coupled. The growth of IoT and the rapid
development of associated technologies create a widespread connection of ―things.‖ This has led to
the production of large amounts of data, which needs to be stored, processed and accessed. Cloud
computing as a paradigm for big data storage and analytics. While IoT is exciting on its own, the
real innovation will come from combining it with cloud computing. The combination of cloud
computing and IoT will enable new monitoring services and powerful processing of sensory data
streams. For example, sensory data can be uploaded and stored with cloud computing, later to be
used intelligently for smart monitoring and actuation with other smart devices. Ultimately, the
goal is to be able to transform data to insight and drive productive, cost-effective action from
those insights. The cloud effectively serves as the brain to improved decision-making and
optimized internet-based interactions. However, when IoT meets cloud, new challenges arise.
There is an urgent need for novel network architectures that seamlessly integrate them. The
critical concerns during integration are quality of service (QoS) and quality of experience (QoE),
as well as data security, privacy and reliability. The virtual infrastructure for practical mobile
computing and interfacing includes integrating applications, storage devices, monitoring devices,
visualization platforms, analytics tools and client delivery. Cloud computing offers a practical
utility-based model that will enable businesses and users to access applications on demand
anytime and from anywhere.
Characteristics

First, the cloud computing of IoT is an on-demand self-service, meaning it‗s there when you
need it. Cloud computing is a web-based service that can be accessed without any special
assistance or permission from other people; however, you need at minimum some sort of internet
access.
Second, the cloud computing of IoT involves broad network access, meaning it offers several
connectivity options. Cloud computing resources can be accessed through a wide variety of
internet-connected devices such as tablets, mobile devices and laptops. This level of convenience
means users can access those resources in a wide variety of manners, even from older devices.
Again, though, this emphasizes the need for network access points.
Third, cloud computing allows for resource pooling, meaning information can be shared with
those who know where and how (have permission) to access the resource, anytime and
anywhere. This lends to broader collaboration or closer connections with other users. From an
IoT perspective, just as we can easily assign an IP address to everything on the planet, we can
share the "address" of the cloud-based protected and stored information with others and pool
resources.
Fourth, cloud computing features rapid elasticity, meaning users can readily scale the service to
their needs. You can easily and quickly edit your software setup, add or remove users, increase
storage space, etc. This characteristic will further empower IoT by providing elastic computing
power, storage, and networking.
Finally, the cloud computing of IoT is a measured service, meaning you get what you pay for.
Providers can easily measure usage statistics such as storage, processing, bandwidth, and active
user accounts inside your cloud instance. This pay per use (PPU) model means your costs scale
with your usage. In IoT terms, it's comparable to the ever-growing network of physical objects
that feature an IP address for internet connectivity, and the communication that occurs between
these objects and other internet-enabled devices and systems; just like your cloud service, the
service rates for that IoT infrastructure may also scale with use.

Service and Deployment

Service models
Service delivery in cloud computing comprises three different service models: software as a
service (SaaS), platform as a service (PaaS), and infrastructure as a service (IaaS).

Software as a service (SaaS) provides applications to the clouds end user that are mainly
accessed via a web portal or service-oriented architecture-based web service technology. These
services can be seen as ASP (application service provider) on the application layer. Usually, a
specific company that uses the service would run, maintain, and give support so that it can be
reliably used over a long period of time.

Platform as a service (PaaS) consists of the actual environment for developing and provisioning
cloud applications. The main users of this layer are developers that want to develop and run a
cloud application for a particular purpose. A proprietary language was supported and provided
by the platform (a set of important basic services) to ease communication, monitoring, billing
and other aspects such as startup as well as to ensure an applications scalability and flexibility.
Limitations regarding the programming languages supported, the programming model, the ability
to access resources, and the long-term persistence are possible disadvantages.

Infrastructure as a service (IaaS) provides the necessary hardware and software upon which a
customer can build a customized computing environment. Computing resources, data storage
resources and the communications channel are linked together with these essential IT resources
to ensure the stability of applications being used on the cloud. Those stack models can be
referred to as the medium for IoT, being used and conveyed by the users in different methods for
the greatest chance of interoperability. This includes connecting cars, wearables, TVs,
smartphones, fitness equipment, robots, ATMs, and vending machines as well as the vertical
applications, security and professional services, and analytics platforms that come with them.
Deployment models
Deployment in cloud computing comprises four deployment models: private cloud, public cloud,
community cloud and hybrid cloud.

A private cloud has infrastructure that’s provisioned for exclusive use by a single organization
comprising multiple consumers such as business units. It may be owned, managed, and operated
by the organization, a third party or some combination of them, and it may exist on or off
premises.

A public cloud is created for open use by the public. Public cloud sells services to anyone on
the internet. (Amazon Web Services is an example of a large public cloud provider.) This model
is suitable for business requirements that require management of load spikes and the applications
used by the business, activities that would otherwise require greater investment in infrastructure
for the business. As such, public cloud also helps reduce capital expenditure and bring down
operational IT costs.

A community cloud is managed and used by a particular group or organizations that have
shared interests, such as specific security requirements or a common mission.

Finally, a hybrid cloud combines two or more distinct private, community or public cloud
infrastructures such that they remain unique entities but are bound together by standardized or
proprietary technology that enables data and application portability. Normally, information that’s
not critical is outsourced to the public cloud, while business-critical services and data are kept
within the control of the organization.

Cloud Storage: Cloud Storage is a managed service for storing unstructured data. Store any amount of data
and retrieve it as often as you like. oud storage is a cloud computing model that enables storing data and files
on the internet through a cloud computing provider that you access either through the public internet or a
dedicated private network connection. The provider securely stores, manages, and maintains the storage
servers, infrastructure, and network to ensure you have access to the data when you need it at virtually
unlimited scale, and with elastic capacity. Cloud storage removes the need to buy and manage your own data
storage infrastructure, giving you agility, scalability, and durability, with any time, anywhere data access.

Advantages of using cloud storage

1. Cost reduction: The largest benefit of cloud storage is cost saving. It lets you save considerable
capital costs because no actual hardware expenditures are required.
2. Security: There are several reasons why cloud storage is more reliable than in-house computing,
including certain high-profile cloud data breaches.
3. Reliability: One of the main benefits of cloud storage for businesses is reliability. You will still get
updated about the updates immediately.
4. Data centralization: There are also projects that are housed in a specific location that can be viewed
anywhere and at any time.
5. Ease of accessibility: An Internet cloud infrastructure maximizes enterprise productivity and
efficiency by ensuring your application is always accessible.
6. Mobility: Both facilities can be easily obtained by staff operating on the premises or at distant
locations. What they need is a link to the Internet.
7. Unlimited storage capacity: The cloud has computing space that is nearly infinite. You can easily
increase the storage space at any time with very nominal monthly charges.
8. The high degree of collaboration: The cloud computing infrastructure facilitates extremely
convenient and safe communication between employees situated in various geographies.
9. Back up and restore data: Once the information is stored in a server, it is simpler to provide the
backup and retrieval of that, which is otherwise a very time-consuming on-site operation.
10. Quick deployment: Your whole infrastructure will be completely functioning within a few minutes
when you plan to use the cloud. Although the amount of time taken varies depending on the type of
technology used in the business.

Disadvantages of cloud storage

1. Vulnerability to attacks: Security vulnerability is another downside of dealing with cloud computing
providers. Any confidential information about the business can be exchanged with a third-party cloud
computing service provider. Hackers could exploit this knowledge.
2. Downtime: That’s because your cloud provider may face power failure, poor access to the internet,
maintenance of services, etc.
3. Vendor Agreement: A organization may face some severe challenges due to the discrepancies
between provider solutions as it wants to switch from one cloud platform to another.
4. Limited control: Cloud clients can be faced with minimal influence over their implementations. On
remote servers that are entirely operated and managed by service providers, cloud services run
5. Platform dependencies: Another of the drawbacks of cloud storage is tacit dependence, also known
as provider lock-in’. Deep-rooted discrepancies between provider platforms will often make it difficult
to switch from one cloud platform to another.
6. Variation in Costs: Cloud hosting is an inexpensive choice, but it can be expensive if you remember
the implementation of the applications.
7. Internet connectivity: In cloud computing, good Internet access is a must. Without an internet
connection, you can’t get cloud connectivity.
8. Lack of support: Cloud Storage providers struggle to provide clients with sufficient assistance. In
addition, they tend to focus on FAQs or online assistance from their customers, which can be a boring
task for non-technical individuals.
9. Varied performance: Any selfish action or DDOS attack on your tenant could impact your shared
resource efficiency.
10. Technical issues: Cloud infrastructure is often vulnerable to instability and other technological
problems. Even in terms of retaining high maintenance standards, the best cloud service provider
companies can face this kind of challenge.
WAMP for IoT

Web Application Messaging Protocol (WAMP) is a sub-protocol of Websocket which provides


publish-subscribe and remote procedure call (RPC) messaging patterns.

WAMP

1. Transport: Transport is channel that connects two peers.


2. Session: Session is a conversation between two peers that runs over a transport.
3. Client: Clients are peers that can have one or more roles. In publish-subscribe model client
can have following roles:
a) Publisher: Publisher publishes events (including payload) to the topic maintained by
the broker.
b) Subscriber: Subscriber subscribes to the topics and receives the events including the
payload.

In RPC model client can have following roles: –

1. Caller: Caller issues calls to the remote procedures along with call arguments. – Callee:
Callee executes the procedures to which the calls are issued by the caller and returns the
results back to the caller. • Router: Routers are peers that perform generic call and event
routing. In publish-subscribe model Router has the role of a Broker: – Broker: Broker acts as
a router and routes messages published to a topic to all subscribers subscribed to thetopic.

In RPC model Router has the role of a Broker: –

1. Dealer: Dealer acts a router and routes RPC calls from the Caller to the Callee and
routes results from Callee toCaller.
2. Application Code: Application code runs on the Clients (Publisher, Subscriber, Callee
or Caller).

Amazon EC2 – Python Example


Boto is a Python package that provides interfaces to Amazon Web Services (AWS). In this
example, a connection to EC2 service is fi rst established by calling boto.ec2.connect_to_region.
The EC2 region, AWS access key and AWS secret key are passed to this function. After
connecting to EC2 , a new instance is launched using the conn.run_instances function. The AMI-
ID, instance type, EC2 key handle and security group are passed to this function.
Amazon AutoScaling – Python Example

1. AutoScaling Service: A connection to AutoScaling service is first established by calling


boto.ec2.autoscale.connect_to_regionfunction.
2. Launch Configuration: After connecting to AutoScaling service, a new launch
configuration is created by calling conn.create_launch_con f iguration. Launch
configuration contains instructions on how to launch new instances including the AMI-
ID, instance type, security groups,etc.
3. AutoScaling Group : After creating a launch configuration, it is then associated with a
new AutoScaling group. AutoScaling group is created by calling
conn.create_auto_scaling_group. The settings for AutoScaling group such as the
maximum and minimum number of instances in the group, the launch configuration,
availability zones, optional load balancer to use with the group,etc.
Amazon AutoScaling – Python Example

#Creating auto-scaling policies

scale_up_policy = ScalingPolicy(name='scale_up',

adjustment_type='ChangeInCapacity',

as_name='My-Group',

scaling_adjustment=1,

cooldown=180)

scale_down_policy

=ScalingPolicy(name='scale_down',

adjustment_type='ChangeInCapacity',

as_name='My-Group', scaling_adjustment=-1,

cooldown=180)

conn.create_scaling_policy(scale_up_policy)

conn.create_scaling_policy(scale_down_policy)

AutoScaling Policies:

1. After creating an AutoScaling group, the policies for scaling up and scaling down
are defined.
2. In this example, a scale up policy with adjustment type ChangeInCapacity and
scaling_ad justment = 1 isdefined.
3. Similarly a scale down policy with adjustment type ChangeInCapacity and
scaling_ad justment = -1 isdefined.

CloudWatch Alarms

#Connecting to CloudWatch

cloudwatch = boto.ec2.cloudwatch.connect_to_region(REGION,

aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY)

alarm_dimensions = {"AutoScalingGroupName": 'My-Group'}

#Creating scale-up alarm

scale_up_alarm = MetricAlarm(

name='scale_up_on_cpu', namespace='AWS/EC2',

metric='CPUUtilization', statistic='Average',

comparison='>', threshold='70',

period='60', evaluation_periods=2,

alarm_actions=[scale_up_policy.policy_arn],

dimensions=alarm_dimensions)

cloudwatch.create_alarm(scale_up_alarm)

#Creating scale-down alarm

scale_down_alarm =MetricAlarm(

name='scale_down_on_cpu',namespace='AWS/EC2',

metric='CPUUtilization', statistic='Average',

comparison='<',threshold='40',

period='60', evaluation_periods=2,

alarm_actions=[scale_down_policy.policy_arn],

dimensions=alarm_dimensions) cloudwatch.create_alarm(scale_down_alarm)

1. With the scaling policies defined, the next step is to create Amazon CloudWatch alarms
that trigger thesepolicies.
2. The scale up alarm is defined using the CPUUtilization metric with the Average statistic
and threshold greater 70% for a period of 60 sec. The scale up policy created previously
is associated with this alarm. This alarm is triggered when the average CPU utilization of
the instances in the group becomes greater than 70% for more than 60seconds.
3. The scale down alarm is defined in a similar manner with a threshold less than50%.
Python for MapReduce

#Inverted Index Mapper in Python

#!/usr/bin/env python import sys for line in sys.stdin: doc_id, content = line.split(‗‗) words =
content.split() for word in words: print ‗%s%s‗ % (word, doc_id)

The example shows inverted index mapper program. The map function reads the data from the
standard input (stdin) and splits the tab-limited data into document- ID and contents of the
document. The map function emits key-value pairs where key is each word in the document and
value is the document-ID.

Python for MapReduce

#Inverted Index Reducer in Python

#!/usr/bin/env python import sys current_word = None current_docids = [] word =


None

for line in sys.stdin: # remove leading and trailing whitespace line = line.strip() # parse the input
we got from mapper.py word, doc_id = line.split(‗‗) if current_word
== word: current_docids.append(doc_id) else: if current_word: print ‗%s%s‗ % (current_word,
current_docids) current_docids = [] current_docids.append(doc_id) current_word = word

The example shows inverted index reducer program. The key-value pairs emitted by the map
phase are shuffled to the reducers and grouped by the key. The reducer reads the key-value pairs
grouped by the same key from the standard input (stdin) and creates a list of document-IDs in
which the word occurs. The output of reducer contains key value pairs where key is a unique
word and value is the list of document-IDs in which the word occurs.

Python Packages of Interest


1. JSON: JavaScript Object Notation (JSON) is an easy to read and write data- interchange
format. JSON is used as an alternative to XML and is is easy for machines to parse and
generate. JSON is built on two structures - a collection of name-value pairs (e.g. a Python
dictionary) and ordered lists of values (e.g.. a Python list).
2. XML: XML (Extensible Markup Language) is a data format for structured document
interchange. The Python minion library provides a minimal implementation of the
Document Object Model interface and has an API similar to that in other languages.
3. HTTPLib & URLLib: HTTPLib2 and URLLib2 are Python libraries used in
network/internet programming
4. SMTPLib: Simple Mail Transfer Protocol (SMTP) is a protocol which handles sending
email and routing e-mail between mail servers. The Python smtplib module provides an
SMTP client session object that can be used to send email.
5. NumPy:NumPy is a package for scientific computing in Python. NumPy provides
support for large multi-dimensional arrays andmatrices
6. Scikit-learn: Scikit-learn is an open source machine learning library for
Python that provides implementations of various machine learning
algorithms for classification, clustering, regression and dimension
reduction problems.

Python Web Application Framework - Django

Django is an open source web application framework for developing web


applications in Python. A web application framework in general is a collection
of solutions, packages and best practices that allows development of web
applications and dynamic websites. Django is based on the Model-Template-
View architecture and provides a separation of the data model from the
business rules and the user interface. Django provides a unified API to a
database backend. Thus web applications built with Django can work with
different databases without requiring any code changes. With this flexibility in
web application design combined with the powerful capabilities of the Python
language and the Python ecosystem,
Django is best suited for cloud applications. Django consists of an object-
relational mapper, a web templating system and a regular-expression based
URL dispatcher.

Django Architecture

Django is Model-Template-View (MTV) framework.

1. Model: The model acts as a definition of some stored data and handles the
interactions with the database. In a web application, the data can be stored
in a relational database, non- relational database, an XML file, etc. A
Django model is a Python class that outlines the variables and methods for
a particular type ofdata.
2. Template: In a typical Django web application, the template is simply an
HTML page with a few extra placeholders. Django‗s template language
can be used to create various forms of text files (XML, email, CSS,
Javascript, CSV,etc.)
3. View :The view ties the model to the template. The view is where you
write the code that actually generates the web pages. View determines
what data is to be displayed, retrieves the data from the database and
passes the data to the template.

You might also like