---
# System prepended metadata

title: Cloud Computing - University of Beira Interior

---

# Cloud Computing - University of Beira Interior

At the moment, I will do an overview about the Cloud Computing content. The methodology is divided in: 

~~1. ==Introduction about the Cloud Computing==~~; 
~~2. ==Classic Models==;~~
~~3. ==Parallel and Distribuited Programming==;~~
~~4. ==MPI==:~~
    ~~4.1 ==Algorithms==;~~
    ~~4.2 ==Calcules==;~~
~~5. ==Containers==;~~
~~6. ==Serveless==.~~

---
Here, you will find a overview about all the concepts that the professor Paul Crocker goes to solicite in Cloud Computing test.



---

## Introduction and Concepts about the Cloud Computing

This is the timeline upon this chapter: 

- Computing Evolution 
- Definition and Charactterics of Cloud Computing
- Service Models and Deplyment
- Enabling Technology - Virtualization 
- Further Reading 

Two terms that is very used in this methodology are the **HPC - High Performance Computing** and **HTC - High Throughput Computing** with parallel and distributeed technologies. Here, there is a figure that provides a knowledge about this appraoch.

![](https://i.imgur.com/mB7fFvI.png)

The evolution of Computing Paradigms is determined into this way: 

1. Virtualization;
2. Cluster Computing;
3. Per-to-Peer System - P2P; 
4. Grid Computing;
5. Utility Computing;
6. Cloud Computing; 
7. Edge Computing.

![](https://i.imgur.com/eAUdCrh.png)

:::info

An important concept is about the environment, in which, this deplyment can be on premisse or in cloud.

In which, this deployment, cost, control, security and compilance. Next, in scenario all paradigms can be on premisse or in cloud about the environment. 

:::
Now, you will know abot wo models for distributed and Cloud Computing: 

- Utility Computing
    - Methodology
        - Is a service provisioning model in which a ==service provider makes computing resources and infrastructure management available== to the customer as needed, and charges them for specific usage rather tan a flat rate.
        - As in other types of on demand computing, such as **Grid Computing**, ==the utily model seeks to maximize the efficiency use of resources and maximize associated costs==.
- Edge Computing
    - Methodology
        - It is a ==new paradigm focused on bringing computing as close to the source of data== as possible in order to reduce latency and bandwidth. 
        - Edge Computing **means running fewer processes in the cloud and moving those processes to the edge of the Internet**, such as Iot device or an edge serve.
    - Advantages
        - M**inimizes latency and the amount of long distance communication** that has to hapeen between a client and server,
        - It is very good for real time applications that share data  

**Below, you will find the definition about the Cloud Computing:**
:::success
A computação na cloud é o fornecimento de serviços informáticos, incluindo servidores, armazenamento, bases de dados, rede, software, análises e inteligência, através da Internet ("a cloud") para disponibilizar mais rapidamente inovação, recursos flexíveis e poupanças no dimensionamento.
:::

- It can be viewed as containing both a physical layer and an abstraction layer. 
    - **Physical Layer**:
        - ==Consists of hardware==: Server, storage and Network Components.
    - **Abstraction Layer**:
        - ==Consists of software deployed across the physical layer==, which manifests the essential cloud characteristics.   

Now, as cited in Abstraction Layer, the software deployed across the physical layer has some essential characteristics, and I will mention them:

1. **On Demand Self Service [==Auto Atendimento sobre Demandas==]**: A consumer can unilaterally provision computing capabilities.
2. **Broad Network Access[==Amplo Acesso a Rede==]**: Capabilities are available over the network and acceses througth stadar mechanisms.
3. **Resource Pooling[==Combinacao de Recursos==]** Resources are pooled to serve multiple consumers using a multi tenalt model.
4. **Rapid Elasticity[==Elasticidade Rapida==]** Capabilities can be elastically provisioned and released, in some cases automatically.
5. **Measured Service[==Serviço Medido==]**: Cloud systems automatically control and optimize resource use by leveragin e mering capability.
6. **High Available[==Alta Disponibilidade==]**

Hence, it is possible to identify a convergence between two terms similiars derivated **High Availability**, for instance: 

- **Availability**: Period of time when services are available for a system response, any loss is considered an interruption.
- **Highly Available**: System designed to avoid service losses, reducing and managing failures. Any loss is not acceptable.

Exist some actos in a cloud, for instance:

- User person or organization that is a consumer of a cloud  service;
- Hardware that is available to the users;
- Services available to users;
- Developer produces tools for cloud;
- Broker manages the relationship between users dnd providers;
- Auditor Audits the cloud services.

Consequently, there are some challenges about this approach, such as: 

- Security, Service Level Agreement problems, energetic efficiency/impact, standardization.

:::success

The companies that offer these computing services of cloud computing and cloud infrastructure are called ==Cloud Service Providers==.

:::

The Cloud Service are offered using Service Levels Agreements (SLAs), in which, these odels can be: 

![](https://i.imgur.com/m62doYS.png)

- Software as a Service - SaaS
    - The capability provided to the consumer is to use the providers application running on a cloud infrastructure.
    - These applications are accesible from various client devices. 
    - The consumer does not manage or control the underlying cloud infrastructure
        - Network 
        - Servers
        - Operation System
        - Storage
    - Examples
        - Google Workspace
        - Dropbox
        - Salesforce
        - Cisco WebEx
- Platform as a Service - PaaS
    -  The capability provided to the consumer is to deploy applications onto the cloud infrastructure.
    -  Using programming languages, libraries, services supported by the provider
    -  The consumer does not manage or control underlying cloud infrastructure.
    - Examples
        - Windows Azure
        - Heroku
        - Force.com
        - Google App Engine
        - OpenShift
- Infrastructure as a Service -IaaS
    - The capability provided to the consumer is to provisiong processing, storage, network, and other fundamental computing resources
    - Examples 
        - Linode
        - Rackspace 
        - Amazon Web Services (AWS)
        - Microsoft Azure
        - Google Compute Engine (GCE)
![](https://i.imgur.com/0x42OU9.png)

The cloud deployment models can be considerad like: 

- Private Cloud
    - A private cloud consists of cloud computing resources used exclusively by one business or organization. The private cloud can be physically located at your organization’s on-site datacenter, or it can be hosted by a third-party service provider. But in a private cloud, the services and infrastructure are always maintained on a private network and the hardware and software are dedicated solely to your organization.
    - Advantages
        - More control
        - More flexibility
        - Security
    - Example
        - HP Data Centers
    - Disvagem
        - Skilled People
        - High Cost
        - Restriction

    - Public clouds are the most common type of cloud computing deployment. The cloud resources (like servers and storage) are owned and operated by a third-party cloud service provider and delivered over the internet. With a public cloud, all hardware, software, and other supporting infrastructure are owned and managed by the cloud provider. provider.
    - Advantages
        - High reliability
        - Lower Cost
        - No maintenance
    - Example
        - Microsoft Azure 
        - IBM Cloud
        - Amazon
- Hybrid Cloud
    - A hybrid cloud is a type of cloud computing that combines on-premises infrastructure or a private cloud—with a public cloud. Hybrid clouds allow data and apps to move between the two environments.
    - Advantages
        - Control
        - Flexibility
        - Cost
- Multi Coud
    - When a single public cloud is insufficient to meet an organization computing need basicaly a more complex hybrid cloud example, combines a private cloud with muultiple cloud services
    - In a multicloud model the separate cloud environments perform disntinct non overlapping tasks. 

:::warning
The hybrid cloud computing differs from multicloud computing is one sigifnicant way, thus I will cite two observations:

1. Hybrid Cloud is an environemtn based in IT aparently single from several other environments linked by networks.Hybrid cloud always include a private cloud, and are typicall managed as one entity.
2. Multi cloud always include more than one public cloud service. Multi cloud can necessite of a fornecedor from public or private cloud.

**Todas as nuvens hibridas sao multiclouds, mas nem todas as multiclouds sao hibrids. As multiclouds se tornam hibrids quando estao conectadas por alguma forma de integracao.**
:::

For finish this chapter, I will cite the virtualization approach. In which the virtualization has the purpose of pooling resources about the hardware or operation system and this virtualization can be using two types of hypervisors: 

- Native - type1
    - Virtualization runs directy on the host hardware, control the hardware and monitors the gues os
- Hosted - type2
    - This virtualization runs on top of a conventional host OS and the guest.

The virtualization can be three types: 

1. Full Virtualization: The guest system non requires modification aviyt the hardware. Enable by direct execution of user requests and binary translation.
2. Para Virtualization: The guest operation system is modified to enable communication with the hypervisor to improve performance and efficiency.
3. Hardware: certain logical abstractions of their componentry, or only the functionality required to run various operating systems. 

---
## Classic Model 

This chapter will mention about:

- Definition
- Parallel Computers Models
    - Shared Memory and Distribuited Memory
- Arquitecture Classification
- ILP

I will start this chapter with this sentence "Qualquer computador, sequencial ou paralelo, opera executando instructions com dados" 

The computer achitecture is formed by:

- Input/Output
- Processador {Control and Processing of instructions}
- Memory {Stored of data,programs and files}

Now, you will find three approaches about this methodology:

1. ==Concurrent Computing==: A programação concorrente é a mais comum, onde o programa é executado sequencialmente concorrendo pela disponibilidade do(s) processador(es) com os demais programas. Cada processador executa apenas uma linha de comando por vez, por isso a concorrência, e quem cuida dessa concorrência é o Escalonador de Processos 
    - Disvantagem
        - A maior desvantagem desse tipo de programação, é que qualquer ação que demanda algum tempo de processamento irá "travar o usuário" e ele não poderá realizar nenhuma outra ação até que a primeira termine. 
2. ==Parallel Computing==: A programação paralela também conhecida como assíncrona é também uma programação concorrente, porém com mais linhas de execuções, onde o programa é dividido em vários "sub-processos" conhecido como Threads que serão executados paralelamente com o processo pai. Essa forma de desenvolvimento é melhor aproveitada quando dispõe de dois ou mais núcleos de processamento.
3. ==Distribuited Computing:== Na programação distribuída o sistema é executado em vários ambientes interligados por uma rede (internet ou intranet). Esse tipo de sistema tem a vantagem de dispor de uma maior capacidade de processamento e consequentemente aguentar um número maior de usuários/requisições/processos.  

Thereby of the process, the memory also can be parallel. 

Sequential - RAM {Random Access Memory}
Parallel - PRAM {Parallel Random Access Memory}

Next, the memory is controled by: 

- **EREW: Exclusive Read, Exclusive Write**: Only one processo can access a memory location at one time;
- **CREW: Concurrent Read, Exclusive Write**: Multiple processors can read a memory location, but only one at a time can write;
- **ERCW: Exclusive Read, Concurrent Write**: Multiple processors can write to a memory location but read are exclusive;
- **CRCW: Concurrent Read, Concurrent Write**: Processors may freely read or write to memory locations without restrictions.

Exist a concept based in Taxonimia de Arquitecture, it is shows below. This concept says upon the convergence between Data flow and instructions flow

![](https://i.imgur.com/xsSasdm.png)

- SISD:
    - Methodology
        - Sum the n number from array
        - The process use the memory at n time
        - It does not exist paralllelism
        - Von Neumman Architecture 
    - Example
        - Solve this equation {B=A=*4}
            - time1 = load A
            - time2 = mult 4
            - time3 = store B 
    - Citation
        - Person Computer
    - Indirect Parallelism
        - Input/Output Overlap
        - Graph Card

![](https://i.imgur.com/Lm1s5Us.png)


- MISD
    - Methodology
        - This is used when the same input is utilized to distint operations
    - Example
        - Verify if the number is primo
- SIMD
    - Methodology
        - Exist n sequentials of data, one to every processor
        - It is necessary a global clock
        - All the units must to receive the same intrution in the same time. It is necessary a communication between the processors to share the result/data
            - This share is possible altrough of memoria partilhada or rede interligacao{Memoria distribuida}  
    - Example
        - Pipelined vector computers Cray 1 e 2 

![](https://i.imgur.com/vBP53hm.png)

- MIMD
    - Methodologyy
        - N processor sand n instructions sequential
        - Every processors is able of uexecute a diferent program with dinstint data
        - The data are shared via memoria partilhada or rede de interligaçao
    - Example
        - Sincrono
            - IBM RS/6000
        - Assincrono
            - Transputer Network  

![](https://i.imgur.com/5muIjzq.png)

The main difference between the memory and shared-memory is that the same memory is used by multiples processors

The threads has a big importance beucase the threads is a code sequence wrote in high level for individual processors that it can use the shared places. Next, the single way of coomunicate the taks is using the one language for it, for instance, MPI - Message Passing Interface.
:::success
The better wy is buy some processors of high performance, such as: MIPS, Intel, combine together with RAM memory some periferics altrought bus

- Memoria Compartilhada: Em computação, memória compartilhada é uma memória que pode ser acessada simultaneamente por múltiplos programas com a intenção de prover comunicação entre eles ou para evitar cópias redundantes.
- Memoria Distribuida: No modelo de paralelização com memória distribuída, serão criados vários processos para a execução paralela, mas ao contrátio do modelo de memória compartilhada, esses processos estarão em servidores (computadores) distintos. 
- Memoria Distribuida Compartilhada: Cada processador tem acessa a toda a memoria utilizando um unico espaço de endereçamento de memoria.  
:::

---    
## Parallel Paradigms
This chapter I will mention about these approaches: 

- Overview
- Embarrassingly Parallel Computations
- Partitioning and Dvide and Conquer Strategies
- Pipelined Computations
- Synchronous Computations
- Assynchronous Computations
- Load Balancing and Termination Detection

:::success
Exist many problems with parallel and distribuited programming: 
1. Non-Deterministic
2. Communication
3. Synchronization
4. Deadlocks
5. Scheduling
6. Heterogeneity
:::

The parallelism can be: 

1. ==Paralelismo Implicito==: Identificam oportunidades de paralelismo e tratam escalonamento e distribuição de dados. 
2. ==Paralelismo Explicito==: Esta abordagem o programador é responsavel pelo grande esforço de paralelização, tais como(decomposição de problemas, mapeamentos para processadores, definiar a distribuição e comunicação de dados). 

Now, you will find several computing paradigms, such as: 

- Master Worker:
    - O master divide o problema em tarefas mais pequenas que são distribuidas aos escravos.
    - O mapeamento pode ser:
        - Dinamico
            - Quando o numero de tarefas é maioor que o numero de processadores faz se um escalonamento dinamico
        - Estatico
            - Distribuição a prior das tarefas aos processadores
- Decomposicao Geometrica:
    - SIMD
        - Use the same istruction to all process
        - The control of a SIMD using a MPI is based in the number of process, cited as RANK.
- Particionamento:
    - Decomposição de dados
    - Decomposição funcional
    - Recursividade
- Recursividade:
    - A aplicação é organizada como uma arvore
    - Operators
        - Split(dividir em tarefas menores)
        - Escalonar tarefas
        - Join(Juntar resultados)
- Linhas de produção - Pipeline:
    - Os processos são organizados sequencial e cada processo se comunica com o antecessor e o proximo
- Sincrono vs Assincrono:
    - Sincrono
        - Equações Lineares
        - Todos os processadores são sincronizados em pontos regulares
    - Assincrono 
        - MEtodos de ponto fixo 
        - Não existe dependencia explicativa entre processos.
- Speculation: 
    - Use many algorithms and the better algorithm is choice to finalize the execution
    - Use the lookahed strategie(Busca para frente)

Niveis de paralelismo ou granularidade:
1. Grande: Processos, tarefas 
    1.1 Task1, Task2... 
2. Media: Funções, procedimentos 
    2.1 Functions, Threads
3. Fina: Bloco de Instruções 
    3.1 Loop 
4. Muito Fina: Instrução
    4.1 Sum, multipler... 

![](https://i.imgur.com/AhGTq9Y.png)

:::danger
Um programa distribuido é formado por um conjunto de processos ou tarefas, comunicando entre si
:::

A metodologia de um programa paralelo têm quatro fases: 

1. Particionamento: Dividi
3. Communicação
4. Aglomeração
5. Mapping

Example
:::success
Master-Slave
Particionamento: Line Number
Communication: Line number from master, data results to master
Aglomeração: Lines->Blocks
Mapping: MPI configuration
:::

---
## MPI Message Passing Interface

![](https://i.imgur.com/oAYQSa1.png)

Here, will find a small overview about the code
```
> MPI_Init (Initialize the MPI)
> MPI_Finalize() (Finalize the MPI)
> mpiexec() (This sintaxe is same than mpirun)
> MPI_Comm_size = number of total process initialized
> MPI_Comm_rank = What is the number of this process 
> MPI_Comm_world = Communicator between the all process

For example, if you want to run 4 processes together in your machine: 

> mpiexec -np 4 file.exe %using four processes together

```
RANK is responsible by number of process, that is, to controll the program flow. 

![](https://i.imgur.com/F9NvVNi.png)

A message tem dados + envelope

Dados= Contem o tipo de dado * numero de dados
Envelope= Para onde é que vai a mensagem

:::success
Here, there are some parameters that are inclused in comand sintaxe:
- Message (Dados)
- Count (Dados)
- Datatype (Dados)
- destino (Envelope)
- tag (Envelope)
- communicator (Envelope)
:::

==Comunicação Coletiva==: A  comunicação coletiva  é um tipo de troca de informações em que uma fonte principal transmite uma mensagem massivamente grande número de pessoas, de maneira completamente unilateral. Isso significa que os destinatários da primeira mensagem não podem responder, algo que não ocorre na maioria dos processos de comunicação.

- Example (Radio, television)...
 

Now you will fint three examples

==03. The program below "um grupo de processos enviarao uma unica mensagem para o processo com rank zero que recebera as mensagens e as imprimir no ecra."==


```
> int main(){
    > int rank %rank do process(numbmer of process)
    > int p %total number of processes
    
    > MPI_Init(); %Creating the communication
    > MPI_Comm_rank(MPI_COMM_WORLD, &rank) %What is the number of this process
    > MPI_Comm_size(MPI_COMM_WORLD, &p) %Saber o numero total de processos inicializados usando MPI_COMM_SIZE
    > if(rank == 0)
    > printf("Total Number of processes is %d", &p)
    > printf ("Hello, from rank %d", &rank)
    > MPI_Finalize();
> return 0,
}
```

To send a message from rank1 to rank2 use:
```
>  MPI_Send(&x, 1, MPI_INT; 2, 0, MPI_COMM_WORLD)
```
To send a message all process with rank!0
```
>  MPI_init()
>   MPI_Comm_rank(MPI_COMM_WORLD,rank)
>   MPI_Comm_size(MPI_COMM_WORLD. p)
>    if(rank!=0)
>        {
>        printf(Message, hello process %d, rank)
>        destino =0
       > MPI_send(message,strlen(message),100,MPI_CHAR, destino, tag, MPI_COMM_WORLD)}
>    else{
>        for(source =1, source<p, source++){
>            MPI_recv(message,100, MPI_CHAR, source, tag, MPI_COMM_WORLD, &status)
>            printf(message)
        }
    }
```
:::success

A principal diferença entre o processamento paralelo e distribuído é que as configurações paralelas incluem muitos processadores dentro de um único sistema, enquanto configurações distribuídas aproveitar o poder de processamento de muitos computadores ao mesmo tempo. 

:::

---    
## Serverless

:::success
Arquitetura Serverless,  é uma arquitetura de computação orientada a eventos. Sua principal proposta é permitir que as empresas de software criem e mantenham seus aplicativos web sem se preocupar com a infraestrutura em que esses aplicativos estão rodando.
:::

- The serverless computing enables us to construct applications without needing to manage the underlying  infrastructure

- With serverless applications, s the cloud service provider that automatically provisions, scales, and manages the infrastructure required to run the code


The Serverless EcoSystem:
- IaaS (Infrastructure as a Service): As plataformas IaaS usam máquinas virtuais ou hardware bare metal como recursos fundamentais, como recursos de computação para sem servidor
    - Example
        - Digital Ocean
- PaaS (Platform as a Service)
    - Example
        - Red Hat OpenShift
- CaaS (Containers as a Service): CaaS é um degrau acima na escada da abstração. As plataformas CaaS empacotam aplicativos e todas as suas dependências em contêineres que são mais “leves” do que as máquinas virtuais.
    - Example
        - Google Kubernetes
- FaaS(Functions-as-a-Service): FaaS é o elemento mais central e definicional da pilha sem servidor. FaaS é focado no paradigma de computação orientada a eventos, em que o código do aplicativo, ou contêineres, só é executado em resposta a eventos ou solicitações
    - Example
        - AWS Lambda

 A maior diferença entre PaaS e Caas, is that the CaaS refere-se ao processo de rodar o código em vários sistemas sem precisar alterá-lo, o PaaS trata de lidar com esses containers em uma camada mais ampla de virtualização, oferecendo gerenciamento e segurança com esse processo.

### A comparisson between PaaS and Serverless

![](https://i.imgur.com/mYiIlJu.png)

![](https://i.imgur.com/GwBPH1n.png)

![](https://i.imgur.com/HzIJsRd.png)

### Serverless vs Containers

Serverless computing and containers are both architectures that reduce overhead for cloud-0hosted web applications, but they differ in several important ways 

Containers are more lightweught than virtual machine, but serveless deployments are even more lighweight and sacel more easily than container based architecture. 

#### Key Differences

- Physical Machines
- Scalability
- Cost
- Maintenance
- Time of deployment

:::success
A big advantage of containers is the difficult to test severless web applications because the backend environment is hard to replicate on a local environmnet. In contrast, the containers run the same no matter where they are deployred, making it relatively simple to test a container based application before deploying it to production. 

- Backend-as-a-Service (BaaS): Um modelo de serviço em nuvem no qual os desenvolvedores terceirizam todos os aspectos de bastidores de um aplicativo da web ou móvel para que eles tenham apenas que escrever e manter o front-end.

- Function as a service (FaaS) O FaaS destina-se a ajudar os desenvolvedores a atualizar ou gravar um segmento de código rapidamente, que pode ser executado na resposta de um evento, como clicar em um elemento pelo usuário em uma página da web.

Usando código sem servidor como FaaS, os desenvolvedores da web podem se concentrar em escrever o código do aplicativo, enquanto o provedor de serviços cuida da alocação do servidor e dos serviços de back-end.
:::

Microsserviços são uma abordagem arquitetônica e organizacional para o desenvolvimento de software, onde o software é composto de pequenos serviços independentes que se comunicam por meio de APIs bem definidas

Dividir um aplicativo em microsserviços é atraente para os desenvolvedores porque significa que eles podem criar e modificar pequenos pedaços de código que podem ser facilmente implementados em suas bases de código

Here, there are several examples of serverless computing services, such as:

- Microsoft Azure Functions
- Google Cloud Functions
- Cloud Functions for Firebase
- Amazon Lambda


---
## Questions about the Depeer-Study

1. Explain what is Utily Computing. You must provide some example.
2. Talk about the Edge Computing paradigm. Provide examples and cite tha advantages of this use.
3. Cite the evolution about the cloud computing. What is the main elements in this evolution cited?