You are on page 1of 7

Assignment-1 (Big Data Lab)

Shashwat Patel (MM19B053)


17/02/2023
Q-1 Deploying a Google Cloud Function

Figure 1: Cloud Function to be deployed

Figure 2: Deploying the Google cloud function and uploading the file (config.txt)
Figure 3: The Logs

The number of lines in ‘config.txt’ is 19

Steps:

1. Initially, a bucket and a VM instance is created. Start the VM and install python and gsutil. The
cloud function needs to have access to Google-cloud-storage. For that do:

echo ‘google-cloud-storage’ > > requirements.txt

2. Write a function ‘cloud_func’ which prints the file name and counts the number of lines present in
the file uploaded to the Google cloud server. (Fig-1)

3. The function is then deployed to the Google Cloud Function which gets triggered when the file is
uploaded to the GCS.

As seen from figure 2, first the function is deployed using:

gcloud functions deploy cloud_func --runtime python37 --trigger-resource shapap --trigger-event


google.storage.object.finalize

Then the file is uploaded using:

gsutil cp config.txt gs://shapap

4. (Fig-3) Logs are then checked using: gcloud functions logs read --limit 50

Q-2 Deploying a Google cloud function (Print Hello World and get sum of first N Fibonacci numbers)

‘Hello-World’

To deploy the function: gcloud functions deploy hello_world --runtime python310 --trigger-http --
allow-unauthenticated
Parameter meaning:

1. gcloud functions deploy: Used to deploy a function to Google cloud functions

2. hello_world: The name of the function, we are deploying

3. --runtime python310: To specify the runtime environment for the function. Here, we are using
python version 3.10

4. --trigger-http: To specify the trigger for a function. Here the function gets triggered by a HTTP
request.

5. --allow--unauthenticated: To specify that the function is accessible by unauthenticated users.

Figure 4: Deploying 'hello_world' function


Figure 5: Result of hello_world function

Figure 6: Shut down the hello_world function

‘return_fibonacci’ Function deployment

Figure 7: Hello_World & Sum of first N Fibonacci Numbers functions


Figure 8: Deploying 'return_fibonacci' function

Results:

Figure 9: Results of 'return_fibonacci' function


To deploy ‘return_fibonacci’ function:

1. Open ‘main.py’ present in bdl-2023-assignment1-main

2. Complete the calculate_fibonacci function which returns the sum of first N Fibonacci numbers.

3. Then deploy the return_fibonacci function using: gcloud functions deploy return_fibonacci --
runtime python310 --trigger-http --allow-unauthenticated

4. After deployment, you get an URL. Open that URL in your browser. Give input to that function

To give an input to the function do this:

The url you get: https://us-central1-lab-2-377313.cloudfunctions.net/return_fibonacci

To give input add: ?n=50 at the end of the URL

The URL should be: https://us-central1-lab-2-377313.cloudfunctions.net/return_fibonacci?n=50

Q-3 Descriptive Questions:

Serverless Computing: Server less computing is a cloud computing model where the cloud provider
manages the architecture and allocates the required computing memory automatically as needed to
run the application code. The user doesn’t have to anything related to allocating the computing
resources. In server less computing, it doesn’t mean that there are no servers running, it means that
the servers are still running but the user doesn’t have to manage them. The user just provides the
application code, which then runs on the cloud in response to specific requests. This code by the
user can be written in any programming language. The scaling and availability is managed by the
cloud provider. Some popular serverless computing services include Google Cloud Service, Azure
functions etc.

As a student of Big Data Lab, write a comparative analysis, highlighting the pros and cons, as a
student developer, b/w PaaS, IaaS, SaaS.

Depending on the needs of the project, a specified model is chosen.

Platform-as-a-Service (PaaS): It is a platform which allows users to build, test and deploy their
application without worrying about the underlying infrastructure. The runtime environment is
managed by the cloud provider.

Advantages:

 It simplifies the development process, as the user only has to focus on developing
applications.
 Automatic scaling, allowing to handle more traffic without any additional resource.

Disadvantages:

 Limited customization options available to the user, as there is limited control over
infrastructure.
 Higher cost
Infrastructure-as-a-Service (IaaS):It provides the infrastructure to run the application. Virtual
Machine, storage resources are provided to the user, which then the user can use to deploy their
application.

Advantages:

 User has more control over the infrastructure, allowing more customization.
 Lower cost compared to PaaS and SaaS.

Disadvantages:

 Setup is more complex compared to other models.


 Scaling requires additional management of resources.

Software-as-a-Service (SaaS): The user has access to the application only through a web browser or
an app. The storage, infrastructure, platform and other resources are managed by the cloud
provider.

Advantages:

 This allows easy access to the software without any need of setup.
 Automatic updates and maintenance of the software.

Disadvantages:

 Limited customization options available to the user.


 Limited control over the data, as the data is stored on the cloud provider’s server.

Cloud APIs and their role in the cloud computing landscape:

Cloud APIs (Application Programming Interface) is a tool that allows interaction between software
application and cloud computing services. These APIs allows user to access and manage the cloud
resources such as Virtual Machine, storage and databases.

These APIs play an important role in cloud computing landscape by allowing the user to build
applications and then have the added advantage of services provided by the cloud platforms. The
user can access the cloud resources, automate tasks and integrate the cloud services with other
applications. Some of the important benefit of cloud APIs include flexibility, scaling, automation and
easy integration of application with other cloud services.

In summary, cloud APIs are very important component of the cloud computing landscape providing
the users with necessary tools to build and deploy software that are scalable, flexible and cost-
effective.

You might also like