Giter VIP home page Giter VIP logo

serverlessprojects's Introduction

SCAD-CLUELESS Group 04

Serverless cloud applications ZHAW

Team:

  • Adrian Hornung (hornuadr)
  • Jari Rentsch (rentsjar)
  • Kunsang Kündetsang (kuendkun)
  • Sydney Nguyen (nguyesyd)
  • Tobi Ritscher (ritsctob)

To achieve the tasks in this lab, we have created an account on the Google Cloud Platform. We used Python to implement a cloud function on this Faas service. Here you can find the report PDF of the Lab.

Documentation:

Our frontend and the overview page (displays all feedbacks) is written in Python and deployed on Google Cloud Functions. Our analytics page is written in Java and is also deployed on Google Cloud Functions. We first intended to chose Amazon Web Services as the provider for the database but then we realised that it wasn't possible to get a free database with them. In the end we settled for a Firebase (Firestore) database since that was free and easy to use. Since both GCF and Firebase are developed by Google we decided to make the analytics page in Java so that we have a polyglot application.

Our workflow manager and the dummy functions are listed below and the observations we have made are here

Documentation

  • Manager: receives a json directory with fields such as shown below
  • Dummy00: receives a String, returns a String (calls sleep function)
  • Dummy01: receives a number, returns a number (fibonacci)
  • Dummy02: receives a String, returns a String (reverses the String)
  • Dummy03: receives a String, returns a String (calls sleep function)
  • Dummy04: receives a String, returns a String (does some multiplication)

Example

template_or = {
      "description": "f0-f1-f2|f3-f4",
      "ping": False,
      "urls":  [
          "https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-0", 
          "https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-1",
          "https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-2",
          "https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-3",
          "https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-4",
          ],
      "names": [
          "f0", 
          "f1", 
          "f2", 
          "f3", 
          "f4", 
      ]
}
=> 
result = {'tasks': [{'end': '2021-10-16T00:37:30.787012',
            'json': {'start received': 1},
            'name': 'f0',
            'start': '2021-10-16T00:37:29.527683',
            'status': 200,
            'urls': ['https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-0']},
           {'end': '2021-10-16T00:37:30.808242',
            'json': {'function 1': 0},
            'name': 'f1',
            'start': '2021-10-16T00:37:30.787813',
            'status': 200,
            'urls': ['https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-1']},
           {'end': '2021-10-16T00:37:30.828289',
            'json': {'function 2': 'ollaHillaH'},
            'name': 'f2',
            'start': '2021-10-16T00:37:30.808635',
            'status': 200,
            'urls': ['https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-2']},
           {'end': '2021-10-16T00:37:30.851052',
            'json': {'text': 'Function 4 has used some multiplication.'},
            'name': 'f4',
            'start': '2021-10-16T00:37:30.828679',
            'status': 200,
            'urls': ['https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-4']}]}
template_and = {
      "description": "f0-f1-f2&f3-f4",
      "ping": False,
      "urls":  [
          "https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-0", 
          "https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-1",
          "https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-2",
          "https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-3",
          "https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-4",
          ],
      "names": [
          "f0", 
          "f1", 
          "f2", 
          "f3", 
          "f4", 
      ]
}
=> 
result = {'tasks': [{'end': '2021-10-16T00:32:20.149437',
            'json': {'start received': 1},
            'name': 'f0',
            'start': '2021-10-16T00:32:19.076021',
            'status': 200,
            'urls': ['https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-0']},
           {'end': '2021-10-16T00:32:20.174149',
            'json': {'function 1': 0},
            'name': 'f1',
            'start': '2021-10-16T00:32:20.150183',
            'status': 200,
            'urls': ['https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-1']},
           {'end': '2021-10-16T00:32:20.507381',
            'json': {'function 2': 'ollaHillaH',
                     'text': 'Function 3 has returned nicely after some '
                             'sleep.'},
            'name': 'f2&f3',
            'start': '2021-10-16T00:32:20.175688',
            'status': 200,
            'urls': ['https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-2',
                     'https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-3']},
           {'end': '2021-10-16T00:32:20.526016',
            'json': {'text': 'Function 4 has used some multiplication.'},
            'name': 'f4',
            'start': '2021-10-16T00:32:20.507767',
            'status': 200,
            'urls': ['https://europe-west6-daring-runway-326914.cloudfunctions.net/dummy-function-4']}]}

R2:

Created a basic workflow with Google Cloud Workflows. The first step in the Workflow is to call the ping function, then Frontend, Overview and Analytics.

This is the output after calling the workflow:

Waiting for execution [d7d92380-2d6d-4a4f-8a34-bc10ff566f44] to complete...done.     
argument: 'null'
endTime: '2021-10-28T15:07:32.048832311Z'
name: projects/192660774501/locations/us-central1/workflows/workflow-sa/executions/d7d92380-2d6d-4a4f-8a34-bc10ff566f44
result: 'null'
startTime: '2021-10-28T15:07:26.908865616Z'
state: SUCCEEDED
workflowRevisionId: 000001-ac2

R5:

We tried to implement a function through faasification of python native code, that detects the language of a given feedback. Unfortunately the faasification tool Lambada had an bug and was unable to deploy the function to GCF. Here you can find the function and the error message.

R6:

This cloud function enables warm-up pinging which we need for self-optimization.

R7:

This function is a content trigger

R8:

We put OpenFaas on a raspberry pie and used a selfhosted docker registry to deploy the docker container with the cloud function.

  • Display_Blogs/link: We made a short-lived container that runs in the GCP, that displays a list of our blog posts. It's a flask server that returns an HTML page with the list of blogs.
  • Database/link: This is one of the long living crates. It is written primarily in rust but uses some c dependencies, so that we satisfy the given poligot requirements. Additionally to enable a persistent data state we host it on our own service with a dedicated docker volumn mounted in at all time.
  • Make a new Blog/link: Here you can write a blog which will be saved in the database. This long living container runs on our privatly hosted server.

Project explanation

In this project we implemented a simple blog platform, where everyone can post a new message and this will be shown in the blog. In the backround the messages will be saved in a databse with a timetag. The complexity is in the connection between the containers with different languages and different locations as well as saving all data in a sqlite file so the data won't be lost when the server or the container is restartet.

This project uses Google Cloud as well as a private hosted cloud server with Unraid OS. There is also a selfhosted dockerhub (https://dockerhub.ritscher.ch) running inside a container, but we can't share the credentials because of security reasons. We used Rust and Python as the programming language.

Dockerhub links:

Make a new Post: https://hub.docker.com/r/thebluefirefox/scad-ex5-submit Database: https://hub.docker.com/r/thebluefirefox/scad-long-rocket-db

Project explanation

In this lab we used Ballerina to develope three micro services. The first one, called service1, takes an integer as a URL parameter and invokes service2 with the integer as parameter. Ladder one performs a multiplication with specified constant and invokes service3 with the result again as a parameter. Finally, service3 does the same task as service2 but with another specified constanz. The raml file makes the micro services discoverable.

Quality Analysis

Weaknesses

  1. Dockerfile long-rocket: new smaller base image
    Using different a base image as the previous one was on the bigger side. A bigger image will automatically use up more ram in the host system which might cost more. Additionally on scalable systems, where the docker container has to be copied from the storage system to different hosts for load balancing. A smaller image will yield significantly faster start up time.
    By changing some of the application parameters to make it compile with musl instead of the default glibc libraries and using static linking of dynamic instead. We were able to switch to the apline:latest base image from the debian:buster-slim. By applying all these steps we were able to go from a 100Mb large container image to a 11Mb large one.
  2. Dockerfile long-rocket: healthcheck
    A healthcheck will help on long running systems as the administrator gets to check the containers availability without needing to call the application output, assuming there even is an output in the first place.
    Adding a line to the Dockerfile we got the healthcheck working.
  3. Dockerfile Display-Blogs: switch to smaller base image
    We changed the base image from Python:3.7-slim to Python:3.7-alpine, which reduced it's size by 87 MB.
  4. Dockerfile Display-Blogs removal of unnecessary packages and files
    By merging the two previous containers (including the functionality) from Lab5, we were able to reduce the number of files and packages necessary to offer the same funtionality. The new container contains the functionality of these to containers (display_blogs and submit).

The docker compose file defines the frontend and the db (backend) this has been converted to Kubernetes manifest file: https://github.zhaw.ch/nguyesyd/SCAD-CLUELESS/tree/master/Labs/Lab07/Kubernetes for uploading to the ZHAW Cloud Lab

Deploying on the ZHAW Cloud Lab did not work. Following this tutorial we got stuck at the step to download the credentials. It either does not exist in the current UI version or it seems like we don't have permission.

P08

The analysis and explanation to this are written in the P08 folder, due to the inherent complexity of the given system.

serverlessprojects's People

Contributors

thebluefirefox avatar sydneynguyencs avatar tiray7 avatar tobiasritscher avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.