Server and serverless

Deployment

First step in the deployment process, to run a production application in the Cloud, you need one or multiple servers to upload your application and link them to your domain.

This process of uploading code and data to the servers is called deployment.

Manual

Some people use manual deployment, while others use automated deployment. With the manual method, you need to manually upload everything using File Transfer Protocol, FTP, Secure File Transfer Protocol, SFTP, or tools like rsync.

Automatic

However, automatic deployments are easier. If deployment is properly configured with a version control system and build tools.

It starts when the developer make some changes and pushes code to the repository. The build tools receive the signal and create a build environment identical to the production environment.

It runs the test to ensure everything in your code is working correctly. If everything is okay, the build tools connect to the server where your files will stay and upload your code.

CI/CD

There are two essential terms involved in deployment:

CI

Continuous Integration, or CI, is the process of imitating the development environment and then running the test to ensure your code is okay.

CD

The uploading process is called continuous deployment or continuous delivery or CD for short.

These are often used together. A typical workflow of CI/CD involves these steps; code, version control, build, test, and deploy.

Tools that you can use for these steps are Jenkins, CircleCI, and GitHub's CI actions.

NOTE

But if no test runner is involved, it’s only continuous deployment.

Hosting application

To host your code and database, you need to follow one of two approaches, server or serverless.

The word serverless suggests that no physical servers are involved, but that’s not accurate.

Both methods require physical servers, but the deployment process makes them significantly different from each other and both have their advantages and disadvantages.

Server approach

Hosting companies sell two types of servers, dedicated and virtual servers. Each layer of your application is hosted on one or multiple servers.

Dedicated server

A dedicated server is a computing unit available for only your use. You have full access to this unit and can add RAM and storage whenever necessary.

However, only some applications need lots of memory and computing power. Some can run with just a few megabytes or gigabytes of RAM and one or two processor cores.

In such a case, a dedicated server doesn’t make sense because the remaining resources stay idle and you waste money on bills. This is where the virtual servers come into play.

Using hypervisor software, the dedicated server is virtually split into multiple servers or virtual machines separate from each other.

You can assign fixed resources to each of these servers or allow them to work in a relatively shared fashion where they can occasionally access extra resources that are sitting idle.

An advantage is that you can configure each virtual server with different operating systems and tools as they will not conflict with each other. One virtual server can host the application code while another deals with the database.

The disadvantage is that you have to manage everything by yourself, which can be tedious and time-consuming, this is where serverless is different.

Serverless approach

With a serverless approach, you don’t have to configure anything, not for storage CPU or creating a production environment, and not even for memory allocation.

The advantage is that everything is there and properly managed by the serverless provider. A serverless provider is closely integrated with the version control system. Whenever you push code, the serverless providers starts working automatically.

It builds the code, runs the tests, deploys your code and their servers and provides you with a URL to access the hosted application and database.

You don’t manage or configure any servers and you don’t have to worry about loads, you just push your code and access the application. For this reason, this approach is called serverless.

Serverless providers take care of everything and ensure your application is up and running correctly and they charge you by the amount of computing power, memory, storage, and bandwidth your application consumes.

But since serverless bills by usage, any unmonitored consumption can cause a big spike in monthly bills.

Another disadvantage is that when you use serverless providers, you are locked to the vendors environment and conventions. Serverless vendors do not adhere to universal code requirements. Moving apps to another vendor require some code changes.


Virtual machines and containerization

Both technologies are used to host your applications and run them isolated from each other, but they work very differently.

Hypervisor

First is hypervisors, which are software used for virtualization.

A dedicated server can be split into multiple virtual servers, also called virtual machines or VMs using hypervisor technology. Each of the virtual servers runs separate operating systems and applications and each works like an individual computer. As such, they have dedicated IP addresses to communicate with each other.

There are primarily two types of hypervisors involved in creating virtual machines. One is a Type 1 hypervisor or bare-metal hypervisor. The second one is a Type 2 hypervisor.

Type 1

The Type 1 hypervisors are a software layer that works directly with server hardware, and because of this, they are more efficient when it comes to resource management.

Setting up a Type 1 hypervisor is a complex process, but applications running on a Type 1 hypervisor are usually faster because they have dedicated resources assigned to them.

KVM is one of the most widely used Type 1 hypervisors and it’s open source.

Type 2

On the other hand, a Type 2 hypervisor works mostly on top of an operating system and is usually slower than Type 1, but managing a Type 2 hypervisor is simpler than a Type 1 hypervisor because they come with a simpler management console, and you don’t have to directly deal with the hardware for Type 2 hypervisors.

Oracle VirtualBox is one of the most popular and widely used Type 2 hypervisors. It’s open-source software and available for free.

Resource Sharing

Dedicated

Virtual machines can be configured to use dedicated computing resources or share them.

For example, a dedicated server with three terabytes of storage, 12 gigabytes of RAM, and six processing cores can provide its resources entirely to whichever virtual machine might need it.

Alternatively, it can be configured to split its resources equally between all virtual machines. If there are three virtual machines, each of them can use one terabyte of storage space, four gigabytes of RAM, and two processor cores.

NOTE

But take note, while dedicated resources ensure availability, they can also sit idle and lead to wastage.

Say, for example, each virtual server gets a dedicated four gigabytes, but a smaller application hosted on one of them only requires one gigabyte. A considerable amount of memory remains idle, the same goes for the CPU and storage.

Since these resources are dedicated, other virtual machines cannot access these resources even when they are free.

Shared

On the other hand, what if you have a single dedicated machine, but you need more resources than it can offer?

This is where shared virtual machines come in. They can use the resources assigned to them, and they can also use extra resources from shared machines when it’s available.

However, such usage is monitored and continuous over-usage is considered abuse and it can lead to termination of the server if it’s happening with a public provider.

Containerization

It takes time to set up and configure whether a Type 1 or Type 2 hypervisor is used, and you also need to install an operating system on a virtual machine. What if you can remove hardware and the operating system from the equation and focus only on your application and its dependencies?

This undoubtably makes things easier and you can spend more time on development, that’s what containerization is for.

Containerization

Containerization technologies help you pack your application and their dependencies into container image files. This enables you to run them as containers using a container engine, regardless of the operating systems or hardware.

A container can pack single or multiple applications with all dependencies, or you can distribute your applications across multiple containers and configure them to correctly work together using a container engine like Docker.

TIP

For efficient management, you should keep your containers lean and stick to one process or application per container.

Since container engines abstract the operating system layer, and containers don’t run their own operating system, they are smaller in size, run faster, and are more manageable than virtual machines.

Containers are also very portable and you can deploy them quickly.

Docker

Docker is one of the most popular and widely used container engines and it’s available for free.

Terms

There are a few terms you need to know about when dealing with containers like pod, cluster, and node.

Pod

When a group of tightly coupled containers share the same resource and work together to solve a particular problem, it’s called a pod.

Node

The physical or virtual machine that runs one or multiple pods is called a node.

Cluster

Whereas multiple pods and multiple nodes, which could be related to each other or work completely independently, are called a cluster.

Orchestration

Finally, there’s the management, deployment, networking, and scaling of these containers known as container orchestration.

Kubernetes or K8s is one of the most popular and widely used container orchestration solutions used by developers worldwide.


What does self-hosted, PaaS, SaaS and DBaaS mean?

Introduction

When it comes to using cloud tools, you have many different choices to pick from. In this reading, let’s explore what these tools are and what they have to offer to fit your requirements. The tools discussed in this reading include: IaaS, PaaS, SaaS and DBaas. But first, let’s establish what self-hosted means.

Self-hosted

When you create a public or private cloud network and manage everything yourself, it is called a self-hosted cloud. It is expensive, requires a lot of effort and the initial cost to run it is high. Therefore, it’s not a popular option for cloud computing. But, it’s your only option when you deal with sensitive data, need extra security, or have a custom requirement that public cloud providers cannot fulfill. In such cases, you need to use cloud tools. Let’s explore a few.

IaaS

IaaS or infrastructure as a service, is when a cloud provider offers you on-demand infrastructural units like: load balancers, servers, computing units, storage and virtualization so you can create the infrastructure required by your application.

With IaaS, you can completely control your infrastructure and set up everything to correctly host and serve your application. In this computing model, you can scale up or down at any time and pay only for what you use.

Popular IaaS include: AWS EC2, Google computing units, Digital Ocean and Azure virtual machines. You can read more about these in the additional resources of this lesson.

PaaS

PaaS, or platform as a service, is a specialized cloud solution that has all the essentials to develop, build, host and run your application on the cloud. You don’t manage the servers in this cloud computing model but you do use the solutions offered by the provider.

In PaaS, the cloud providers offer different services as APIs that you can use in your applications. These services include: database, caching, file storage and so on. PaaS makes things easier for you by providing scalable and managed services. This means you don’t have to build these commonly used components from scratch. Thus, you can focus more on building the application’s core, business logic and growth.

Meta is an example of a PaaS because it provides an API to use its proprietary services to developers who build applications only for Facebook users. Other popular PaaS solutions include: AWS Elastic Beanstalk, Heroku, Cloudflare, Google app engine and Microsoft Azure. You can read more about these in the additional resources of this lesson.

SaaS

SaaS, or software as a service, is when an application is hosted on the cloud and allows you to use it online with an on-demand or pricing model. Most web applications with a premium or freemium subscription model belong to this category.

DBaaS

DBaaS, or database as a service, is a cloud service provider that offers high-quality, managed database solutions with an on-demand pricing model to store and process data. Many popular SQL, NoSQL, and other database solutions are used in modern applications. Setting them up, managing, optimizing and scaling them can be tedious and time-consuming. DBaaS solutions make life easier for you because you don’t have to manually do all that.

Conclusion

In this reading, you learned about a few different types of cloud computing models called IaaS, PaaS, Saas, and DBaaS and how they can help you to start developing your application in the cloud.


Additional resources

The following resources will be helpful as additional references in dealing with different concepts related to the topics you have covered in this section.


CloudDatabaseservervirtual-machinewebCI-CDDeployment

Previous one → 7.Django and the front-end | Next one → 9.Introduction to cloud computing