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.
在本文中,我将详细介绍无服务器。让我们开始故事。在本文中将会介绍下面几点:
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.
不,我们需要在其他地方拥有物理服务器来部署我们的应用程序。有网络服务器、文件服务器、邮件服务器......等等。现在我们使用的是云,所有云提供商都已在云上提供这些特定服务。
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.
重要的是,这些功能将由云提供商管理,你不需要关心它。
The answer is “Serverless functions”
答案就是 "无服务函数"。
This is another important factor. If we are working with Serverless, we need to have Serverless databases. There are two types of databases.
这是另一个重要因素。如果我们使用的是无服务器,我们就需要有无服务器数据库。数据库有两种类型。
Most of the common cloud providers provide serverless functions enabling serverless services and functionalities.
大多数常见的云提供商都提供无服务器功能,可实现无服务器服务和功能。
I assume you all know about the difference between relational databases and NoSQL databases. So I am not going to explain this.
我想你们都知道关系数据库和 NoSQL 数据库之间的区别。所以我就不解释了。
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 无服务器数据库。但有时可能需要使用关系数据库来满足您的要求。
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 的官方页面,他们提供以下功能。
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 兼容的云数据库。以下是其官方页面上提到的一些功能。
If you are looking for a MySQL-compatible relational serverless database, PlanetScaleDB would be a choice.
如果您正在寻找与 MySQL 兼容的关系型无服务器数据库,PlanetScaleDB
将是一个不错的选择。
NoSQL serverless databases are very popular because they can handle a large amount of data in many forms.
NoSQL 无服务器数据库非常流行,因为它们可以处理多种形式的大量数据。
Firestore
是 GCP 针对无服务器的数据库解决方案。NoSQL
文档数据库。Azure
云提供的产品。CosmosDB
还具有可扩展性、安全性和性能等常见的无服务器数据库功能。MongoDB API
、Gremlin API
、Tables API
和 DocumentDB API
。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.
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.
无服务器功能允许您只需为所消耗的使用量付费。请查看云服务提供商的定价部分。
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.
无服务器模式将按需自动扩展。云提供商能够智能识别所需容量,并根据需求自动进行高或低的扩展。
You don’t need to worry about server maintenance, software/hardware upgrades, security updates, or anything related to servers.
您无需担心服务器维护、软件/硬件升级、安全更新或任何与服务器相关的问题。
Cloud providers guaranteed availability because their data centers are highly available and secure in different regions all around the world.
云提供商保证可用性,因为他们的数据中心在世界各地不同地区都具有高度可用性和安全性。
Serverless functions can be written in many languages. So developers who are skilled in different languages can work to gather.
无服务器功能可以用多种语言编写。因此,熟练掌握不同语言的开发人员可以聚在一起工作。
It will take a little bit of time to wake up and return the response. Because some serverless functions will run on demand.
唤醒和回送响应需要一点时间。因为有些无服务器功能会按需运行。
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
相比,它可以降低服务器维护成本、资源成本和其他特定的服务器相关成本。
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上找到相同的文章。