【Other】What is the Serverless architecture

本文涉及的产品
云数据库 RDS SQL Server,独享型 2核4GB
云原生数据库 PolarDB MySQL 版,Serverless 5000PCU 100GB
简介: 【Other】What is the Serverless architecture

Source

What is the Serverless architecture? - Java Stack Flow

image.png

Technology is rapidly growing day by day.

技术日新月异。

New technologies are being introduced to simplify dev works and make applications more efficient.

新技术不断被引入,以简化开发工作并提高应用程序的效率。

I think you may have heard about Serverless Architecture.

我想你可能听说过无服务器架构(Serverless Architecture)。

In this article, I am going to describe more about Serverless. Let’s begin the story. Here I am going to explain the below points.

在本文中,我将详细介绍无服务器。让我们开始故事。在本文中将会介绍下面几点:

  • Why Serverless
  • Serverless functions
  • Databases for serverless
  • Advantages and disadvantages of Serverless
  • 为什么是无服务器
  • 无服务器功能
  • 适用于无服务器的数据库
  • 无服务器的优缺点

Can we deploy web applications without Servers? 我们可以在没有服务器的情况下部署网络应用程序吗?

image.png

No, we need to have physical servers somewhere else to deploy our applications. There are web servers, file servers, mail servers…etc. Nowadays we are dealing with the cloud, all cloud providers already provide those specific services on the cloud.

不,我们需要在其他地方拥有物理服务器来部署我们的应用程序。有网络服务器、文件服务器、邮件服务器......等等。现在我们使用的是云,所有云提供商都已在云上提供这些特定服务。image.png

Monolith to serverless 从单体到无服务器

Years ago we were very satisfied with Monolithic Architecture.

多年前,我们对单体架构非常满意。

A bulky single application contains everything.

笨重的单一应用程序包含了一切。

Then we came across Microservices architecture to avoid the drawbacks of the Monolithic.

后来,我们遇到了微服务架构,从而避免了单体架构的弊端。

Microservices use separate services that are dedicated to a specific task to perform.

微服务使用独立的服务,专门执行特定的任务。

Now we are on another level with serverless.

现在,我们的无服务器架构又上了一个台阶。

It simplifies services even smaller with functions.

它通过函数将服务简化得更小。

The important thing is, that these functions will be managed by a cloud provider, you do not need to care about it.

重要的是,这些功能将由云提供商管理,你不需要关心它。

What is called Serverless?

  • Simply said, “as a developer, you don’t need to bother about the servers” is what Serverless means.
  • On your behalf, your cloud provider will handle this.
  • At least you don’t need to think about it. It is not necessary to create servers, maintain servers, deploy servers…etc.
  • You can fully focus on the development without worrying about the deployment.

Okay, no servers. Then, as developers what should we care about? 好吧,没有服务器。那么,作为开发者,我们应该关心什么呢?

The answer is “Serverless functions”

答案就是 "无服务函数"。

How to select a database for serverless architecture? 如何为无服务器架构选择数据库?

This is another important factor. If we are working with Serverless, we need to have Serverless databases. There are two types of databases.

这是另一个重要因素。如果我们使用的是无服务器,我们就需要有无服务器数据库。数据库有两种类型。

What are Serverless functions?

  • Serverless functions are single-purpose programmatic functions.
  • It is just a simple function.
  • The developer can focus on the logic and create a function and your cloud provider will deploy it, scale it, maintain it, and takes care of it.
  • You can write your serverless functions in different languages which is supported by your cloud provider.
  • 无服务器函数是单一用途的编程函数。
  • 它只是一个简单的函数。
  • 开发人员可以专注于逻辑并创建一个函数,而云提供商将对其进行部署、扩展、维护和管理。
  • 您可以使用云提供商支持的不同语言编写无服务器函数。

Serverless infrastructure providers

Most of the common cloud providers provide serverless functions enabling serverless services and functionalities.

大多数常见的云提供商都提供无服务器功能,可实现无服务器服务和功能。

  • AWS Lambda functions
  • Google Cloud functions
  • Azure functions
  • Cloudflare Workers
  • Digital Ocean functions
  • Alibaba Cloud functions
  • Relational serverless databases
  • NoSQL serverless databases
  • AWS Lambda 功能
  • 谷歌云功能
  • Azure 功能
  • Cloudflare 工作者
  • 数字海洋功能
  • 阿里巴巴云功能
  • 关系型无服务器数据库
  • NoSQL 无服务器数据库

I assume you all know about the difference between relational databases and NoSQL databases. So I am not going to explain this.

我想你们都知道关系数据库和 NoSQL 数据库之间的区别。所以我就不解释了。

Relational Serverless databases 关系型无服务器数据库

Since we are dealing with Serverless architecture I encourage you to use NoSQL Serverless databases. But sometimes it might be required to use relational databases with your requirements.

由于我们处理的是无服务器架构,因此我鼓励您使用 NoSQL 无服务器数据库。但有时可能需要使用关系数据库来满足您的要求。

Amazon Aurora

If you are using AWS, you can use Amazon Aurora RDBMS. This is fully compatible with MySQL and PostgreSQL. According to the official page of Amazon Aurora, they offer the features mentioned below.

如果使用 AWS,则可以使用 Amazon Aurora RDBMS。它与 MySQL 和 PostgreSQL 完全兼容。根据亚马逊 Aurora 的官方页面,他们提供以下功能。

  • Provides very powerful and high-performance data handling.
  • In build security
  • Continuous backup
  • Up to 15 read replicas
  • Automated multi-Region replication
  • 提供非常强大的高性能数据处理。
  • 内置安全性
  • 连续备份
  • 多达 15 个读取副本
  • 自动多区域复制

CockroachDB

This is another cloud-based database that is compatible with PostgreSQL. Here are some features they offered as they mentioned on their official page.

这是另一款与 PostgreSQL 兼容的云数据库。以下是其官方页面上提到的一些功能。

  • Start instantly
  • Auto replicated data
  • Online schema changes
  • 立即启动
  • 自动复制数据
  • 在线模式更改

PlanetScaleDB

If you are looking for a MySQL-compatible relational serverless database, PlanetScaleDB would be a choice.

如果您正在寻找与 MySQL 兼容的关系型无服务器数据库,PlanetScaleDB 将是一个不错的选择。

  • High scalability with horizontal sharding.
  • Unlimited connections
  • Effortless data import
  • 通过水平分片实现高扩展性。
  • 无限连接
  • 轻松导入数据

NoSQL serverless databases NoSQL 无服务器数据库

NoSQL serverless databases are very popular because they can handle a large amount of data in many forms.

NoSQL 无服务器数据库非常流行,因为它们可以处理多种形式的大量数据。

Amazon DynamoDB

  • The NoSQL database for AWS is Amazon DynamoDB.
  • Fully managed NoSQL document and key value database with auto-scaling.
  • Highly scalable with customizable capacity modes.
  • This offers single-digit millisecond performance at any scale.
  • Guaranteed high security with AWS IAM and AWS KMS.
  • AWS 的 NoSQL 数据库是 Amazon DynamoDB。
  • 完全托管的 NoSQL 文档和键值数据库,具有自动扩展功能。
  • 具有高度可扩展性,可自定义容量模式。
  • 可在任何规模下提供个位数毫秒级的性能。
  • 通过 AWS IAM 和 AWS KMS 保证高度安全性。

Google Firestore

  • Firestore is GCP’s database solution for Serverless.
  • This is a real-time database.
  • This is a highly scalable NoSQL document database.
  • Data is fully secured with customizable security and data validation rules.
  • Offline mode enabled easy development.
  • Firestore 是 GCP 针对无服务器的数据库解决方案。
  • 这是一个实时数据库。
  • 这是一个高度可扩展的 NoSQL 文档数据库。
  • 数据通过可定制的安全和数据验证规则得到全面保护。
  • 离线模式支持轻松开发。

Azure Cosmos DB

  • This is a Microsoft product for the Azure cloud.
  • CosmosDB also has common serverless database features like scalability, security, and performance.
  • Supports different APIs like MongoDB API, Gremlin API, Tables API and DocumentDB API.
  • 这是微软为 Azure 云提供的产品。
  • CosmosDB 还具有可扩展性、安全性和性能等常见的无服务器数据库功能。
  • 支持不同的 API,如 MongoDB APIGremlin APITables APIDocumentDB API

Advantages of Serverless

Avoid over-provisioning and under-provisioning. 避免供应过剩和供应不足

Over-provisioning means you are paying for some sort of server capacity, but you are not using this capacity. It looks like you are expecting traffic for 1M users, but you are getting 1K users.

超额配置意味着您为某种服务器容量支付了费用,但您并没有使用这种容量。看起来你期望的流量是 100 万用户,但你得到的却是 1K 用户。

Under-provisioning means your expected capacity is less than the required capacity. In simple words, you are expecting traffic for 1K users, but you are getting 1M. The server doesn’t have enough capacity.

Pay for the exact usage 按准确的使用量付费

Serverless functions allow you to pay only for the usage you consume. Please take a look at the pricing section of your cloud service provider.

无服务器功能允许您只需为所消耗的使用量付费。请查看云服务提供商的定价部分。

Smart scalability

Serverless models will automatically scale on demand. The cloud provider is smart enough to identify the required capacity and it will automatically scale high or low on demand.

无服务器模式将按需自动扩展。云提供商能够智能识别所需容量,并根据需求自动进行高或低的扩展。

Free of servers, no infrastructure to manage. 无需服务器,无需管理基础设施

You don’t need to worry about server maintenance, software/hardware upgrades, security updates, or anything related to servers.

您无需担心服务器维护、软件/硬件升级、安全更新或任何与服务器相关的问题。

Highly available

Cloud providers guaranteed availability because their data centers are highly available and secure in different regions all around the world.

云提供商保证可用性,因为他们的数据中心在世界各地不同地区都具有高度可用性和安全性。

Boundless 无边无际

Serverless functions can be written in many languages. So developers who are skilled in different languages can work to gather.

无服务器功能可以用多种语言编写。因此,熟练掌握不同语言的开发人员可以聚在一起工作。

Disadvantages of Serverless  无服务器的缺点

Latency 延迟

It will take a little bit of time to wake up and return the response. Because some serverless functions will run on demand.

唤醒和回送响应需要一点时间。因为有些无服务器功能会按需运行。

Cost 费用

It depends on your traffic. If you are getting more traffic, your cost will be high. But compared to serverful, it will reduce server maintenance costs, resource costs, and other specific server-related costs.

这取决于您的流量。如果流量越大,成本就越高。但与 serverful 相比,它可以降低服务器维护成本、资源成本和其他特定的服务器相关成本。

Debugging

This is one of the major factors and the most contestable.

这是主要因素之一,也是最有争议的因素。

If you are using AWS Lambda, you can use the AWS toolkit and debuggers.

如果使用 AWS Lambda,可以使用 AWS 工具包和调试器。

If you are using GCP, you can use the Functions framework.

如果使用的是 GCP,则可以使用函数框架。

Anyway, this might not be easy.

总之,这可能并不容易。

Because your functions are there, authentication is somewhere else, and you may have an API gateway too.

因为你的函数在那里,身份验证在别处,而且你可能还有一个 API 网关。

It will not be easy to replicate the complete production environment locally.

要在本地复制完整的生产环境并不容易。

I hope you can have a rough idea about Serverless if you are just a beginner.

如果您只是初学者,我希望您能对无服务器有一个大致的了解。

You can refer to the docs of the cloud providers like AWS, GCP, Azure… etc to get a complete idea about Serverless.

你可以参考 AWS、GCP、Azure......等云提供商的文档,以获得关于无服务器的完整概念。

You can find the same article on Medium

您可以在 Medium上找到相同的文章。


相关实践学习
基于函数计算一键部署掌上游戏机
本场景介绍如何使用阿里云计算服务命令快速搭建一个掌上游戏机。
建立 Serverless 思维
本课程包括: Serverless 应用引擎的概念, 为开发者带来的实际价值, 以及让您了解常见的 Serverless 架构模式
相关文章
|
11月前
|
监控 Serverless 测试技术
Serverless Workflow
Serverless Workflow是一种用于定义和执行工作流的开放标准,旨在简化和标准化基于无服务器架构的应用程序中的工作流管理。
143 0
|
Kubernetes Cloud Native Oracle
开源FaaS平台(一):Knative
Serverless构架不仅仅在工业界有诸多厂商不断为之努力,在开源领域也是有诸多优秀的开源Serverless项目。在《CNCF Cloud Native Interactive Landscape》的Serverless标签中,我们可以看到包括OpenWhisk、Fission、Knative以及Kubeless等在内的众多优秀开源FaaS平台。
862 0
|
5月前
|
Serverless 开发者 微服务
Serverless架构
Serverless架构
|
Kubernetes 调度 Perl
serverless-OpenWhisk安装
serverless-OpenWhisk安装
215 0
serverless-OpenWhisk安装
|
9月前
|
JavaScript Serverless API
Serverless Framework
Serverless Framework 是一个开源的工具框架,用于构建和部署无服务器应用程序。它提供了一组工具和功能,简化了无服务器应用程序的开发和部署过程。Serverless Framework 支持多个云平台(如函数计算、AWS Lambda、Google Cloud Functions 等),并提供了命令行工具和配置文件来定义和管理应用程序的各个组件,如函数、事件触发器、API 网关等。它还提供了自动化部署、资源管理、日志追踪等功能,使开发者能够更方便地构建和管理无服务器应用。
159 2
|
9月前
|
存储 JSON JavaScript
AWS Serverless培训分享
AWS Serverless培训分享
96 0
|
JavaScript Java Serverless
理解Serverless技术—FaaS和BaaS
Serverless技术—FaaS和BaaS
2160 1
|
存储 弹性计算 运维
Serverless 和 faas
Serverless 和 faas
|
Serverless
什么是 Serverless——与 Serverless 相对的是 Serverfull
什么是 Serverless——与 Serverless 相对的是 Serverfull自制脑图
85 0
什么是 Serverless——与 Serverless 相对的是 Serverfull
|
机器学习/深度学习 弹性计算 人工智能
什么是 Serverless 架构?
什么是 Serverless 架构?Serverless 与 AI 机器学习之间怎样碰撞出火花?
什么是 Serverless 架构?