aws lambda_AWS Lambda –无服务器编程

aws lambda

AWS Lambda is serverless programming. Serverless programming help to ease out the deployment on production. You just care about the code and rest will be handled by the cloud provider (AWS in our case).

AWS Lambda是无服务器编程。 无服务器编程有助于简化生产部署。 您只关心代码,其余的将由云提供商(在我们的情况下为AWS )处理。

AWS Lambda is one of the very popular technology among developers and technology solution providers on AWS Cloud. It’s an event-driven serverless computing platform that runs on AWS infrastructure. AWS Lambda service takes care of the computing machines that are required to run your application.

AWS Lambda是AWS Cloud上开发人员和技术解决方案提供商中非常流行的技术之一。 这是一个在AWS基础架构上运行的事件驱动的无服务器计算平台。 AWS Lambda服务负责运行您的应用程序所需的计算机。

You might have started thinking about the AWS EC2 machines as they have the same capability. As compared to AWS EC2 machines, the AWS Lambda is the lightweight and on-demand solution. AWS EC2 requires expertise to work on and you must know how and when to scale your system. This is not the case with AWS Lambda, it scales automatically. All of the deployment work is gone if you are using AWS Lambda. Having said that you can virtually deploy any solution but there are many use cases for which AWS Lambda is the ideal solution.

您可能已经开始考虑AWS EC2计算机,因为它们具有相同的功能。 与AWS EC2计算机相比,AWS Lambda是轻量级的按需解决方案。 AWS EC2需要专业知识才能开展工作,您必须知道如何以及何时扩展系统。 AWS Lambda并非如此,它会自动扩展。 如果您使用的是AWS Lambda,则所有部署工作都将丢失。 话虽如此,您几乎可以部署任何解决方案,但是在许多用例中,AWS Lambda是理想的解决方案。

To understand the concept of AWS Lambda, you must know about the serverless programming.

要了解AWS Lambda的概念,您必须了解无服务器编程。

什么是无服务器编程? (What is serverless programming?)

The main aim of serverless programming is to simplify the deployment of the application. In serverless programming, cloud providers like AWS run the computing machine(servers). They manage the resource and machine allocation for your application.

无服务器编程的主要目的是简化应用程序的部署。 在无服务器编程中,AWS等云提供程序运行计算机。 他们为您的应用程序管理资源和机器分配。

Serverless programming is also known as Function-as-a-Service(FaaS). It basically runs your function and does not store any data. The complexity will be hidden for a developer such as scaling, resource management, and server capacity, etc.

无服务器编程也称为功能即服务(FaaS) 。 它基本上运行您的功能,并且不存储任何数据。 对于开发人员来说,复杂性将是隐藏的,例如扩展,资源管理和服务器容量等。

什么是AWS Lambda? (What is AWS Lambda?)

AWS lambda is an event-driven, serverless platform on Amazon Web Service (AWS). It can run virtually any type of application with no deployment and administration at all. AWS Lambda service will take care of the deployment and all administration related.

AWS lambda是Amazon Web Service(AWS)上的事件驱动的无服务器平台。 它几乎可以运行任何类型的应用程序,而无需部署和管理。 AWS Lambda服务将负责部署以及所有与管理相关的工作。

AWS Lambda runs the code when you actually use it so it reduces the overall cost drastically. AWS Lambda is the best solution for the event-based application. For Example, You want to resize the image and send an email whenever an image upload in AWS S3 bucket.

当您实际使用AWS Lambda时,它将运行该代码,因此可以大大降低总体成本。 AWS Lambda是基于事件的应用程序的最佳解决方案。 例如,您想要调整图像大小并在AWS S3存储桶中上传图像时发送电子邮件。

AWS took the Lambda service to the next level and integrated this with other services on AWS. You can trigger the Lambda functions in the response to certain events like the upload of an object in AWS S3, change in DynamoDB table, etc.

AWS将Lambda服务提升到了一个新水平,并将其与AWS上的其他服务集成在一起。 您可以在对某些事件的响应中触发Lambda函数,例如在AWS S3中上传对象,在DynamoDB表中进行更改等。

AWS Lambda的功能和优势 (Features and Benefits of AWS Lambda)

自动缩放 (Automatic Scaling)

Unlike other applications, AWS Lambda is designed to scale automatically. It scales on each trigger and runs your code in parallel. The performance of Lambda remains consistent and it can scale to any limit. As there is no limit to the number of request for your code.

与其他应用程序不同,AWS Lambda旨在自动扩展。 它会在每个触发器上缩放并并行运行您的代码。 Lambda的性能保持一致,并且可以扩展到任何极限。 由于对您的代码的请求数量没有限制。

按使用付费 (Pay-per-use)

Like any other service of AWS, Lambda billing model is also based on a pay-per-use model. You only pay for the requests that your lambda function has served. Lambda is highly cost-effective as it only runs to serve the request.

与AWS的任何其他服务一样,Lambda计费模型也基于按使用付费模型。 您只需为lambda函数已处理的请求付费。 Lambda仅在满足请求时才具有很高的成本效益。

无服务器架构 (Serverless Architecture)

You just write your code and upload it to the Lambda. AWS automatically will run your code on compute machines which are managed and provisioned by AWS itself. You are not required to provision the servers.

您只需编写代码并将其上传到Lambda。 AWS会自动在由AWS本身管理和配置的计算机上运行您的代码。 您不需要配置服务器。

内置容错 (Fault tolerance Built-in)

AWS lambda is designed to provide high availability and deal with partial failures. AWS Lambda has the fault tolerance built-in by maintaining the compute capacity across multiple availability zones. This is the primary reason for no maintenance window or downtime of the AWS Lambda?

AWS lambda旨在提供高可用性并处理部分故障。 AWS Lambda通过维护多个可用性区域中的计算能力而内置了容错功能。 这是没有Lambda的维护时段或停机时间的主要原因吗?

对语言的支持 (Support for the Languages)

AWS Lambda supports most of the popular programming languages like Java, Node.js, Python, and C#, etc. Many other languages support will come in the future.

AWS Lambda支持大多数流行的编程语言,例如Java,Node.js,Python和C#等。将来还将提供许多其他语言的支持。

资源控制 (Resource Controls)

AWS Lambda also gives you the flexibility to manage resources like CPU, disk I/O and network bandwidth.

AWS Lambda还使您可以灵活地管理CPU,磁盘I / O和网络带宽等资源。

AWS Lambda的流行用例 (Popular Use Cases of AWS Lambda)

Although, you can use the AWS Lambda for virtually any type of application and backend service. But this is important to know where the AWS Lambda fits well:

但是,您几乎可以将AWS Lambda用于任何类型的应用程序和后端服务。 但这很重要,要知道AWS Lambda适合的位置:

实时文件处理 (File processing in Real-time)

File processing in realtime is the most popular use case of AWS Lambda. You can trigger Lambda functions in the response to file upload in Amazon S3. You can perform a variety of actions like resize images, create thumbnails, process log file, parse a file, etc.

实时文件处理是AWS Lambda最受欢迎的用例。 您可以在对Amazon S3中文件上传的响应中触发Lambda函数。 您可以执行各种操作,例如调整图像大小,创建缩略图,处理日志文件,解析文件等。

Aws Realtime File Processing

Aws Realtime File Processing

AWS实时文件处理

Lambda作为后端 (Lambda as Backend )

Another popular use case is Lambda as a backend service. You can create your services as Lambda functions and expose them to the API gateway. When a request will come to the API gateway, it will trigger the Lambda function to process the request.

另一个流行的用例是Lambda作为后端服务。 您可以将服务创建为Lambda函数,并将其公开给API网关。 当请求到达API网关时,它将触发Lambda函数来处理请求。

See the below request flow of Lambda as a backend service:

请参阅以下Lambda请求流程作为后端服务:

Aws Lambda As Backend Service

Aws Lambda As Backend Service

AWS Lambda作为后端服务

AWS Lambda概念 (AWS Lambda concepts)

AWS lambda is based on function-as-as-service (FaaS). It lets you run your functions in a serverless environment. These functions are invoked in the response to a trigger called event. The Lambda function runs in isolation in response to an event.

AWS lambda基于功能即服务(FaaS)。 它使您可以在无服务器环境中运行功能。 这些函数是在对称为事件的触发器的响应中调用的。 Lambda函数是响应事件而独立运行的。

功能 (Functions)

The actual program or code that runs in AWS lambda is called function. Whenever an event occurs, Lambda passes the event to the function. Lambda processes the request and returns the response.

在AWS lambda中运行的实际程序或代码称为函数。 每当事件发生时,Lambda都会将该事件传递给函数。 Lambda处理请求并返回响应。

运行时间 (Runtimes)

The runtime sits between your function and Lambda service. It passes the context information and responses between these two.

运行时位于函数和Lambda服务之间。 它在这两者之间传递上下文信息和响应。

Lambda runtime allows your function to run in different languages. You just need to configure runtime based on the programming language that you have chosen to for Lambda function.

Lambda运行时允许您的函数以不同的语言运行。 您只需要根据为Lambda函数选择的编程语言来配置运行时。

层数 (Layers)

A layer is typically a ZIP archive that contains custom runtime, libraries, or any other dependencies. Layers allow using libraries in your functions without including them into packages.

层通常是一个ZIP归档文件,其中包含自定义运行时,库或任何其他依赖项。 层允许在函数中使用库,而无需将它们包含在包中。

You can create layers, or use layers published by AWS or other AWS customers.

您可以创建图层,也可以使用由AWS或其他AWS客户发布的图层。

事件来源 (Event Source)

An event source is an AWS service that triggers your function to execute the code such as Amazon SNS

事件源是一项AWS服务,可触发您的功能执行代码(例如Amazon SNS)

日志 (logs)

AWS Lambda monitors your function automatically and sends the metrics to the CloudWatch. It also sends the log stream to CloudWatch that allow you to analyze the performance and flow of your lambda function.

AWS Lambda自动监视您的功能,并将指标发送到CloudWatch。 它还会将日志流发送到CloudWatch,使您可以分析lambda函数的性能和流程。

下游资源 (Downstream Resource)

A downstream resource is an AWS service that your Lambda function calls once it is triggered. It could be DynamoDB tables or Amazon S3 buckets, etc.

下游资源是您的Lambda函数一旦触发就会调用的AWS服务。 可能是DynamoDB表或Amazon S3存储桶等。

AWS Lambda如何工作? (How AWS Lambda Works?)

We will see several detailed examples in our next posts, let’s understand the basic flow of how the AWS Lambda works?

我们将在下一篇文章中看到几个详细的示例,让我们了解AWS Lambda如何工作的基本流程?

How Aws Lambda Works

How Aws Lambda Works

Aws Lambda如何工作

上载/写入代码 (Upload/Write Code)

There are two options to write a lambda function: 1) You can upload code from your local machine or repository. 2) Or you can use Lambda code editor to write the Lambda function.

编写lambda函数有两种选择:1)您可以从本地计算机或存储库上载代码。 2)或者,您可以使用Lambda代码编辑器编写Lambda函数。

设置触发器 (Set Triggers)

Once you have uploaded your code to AWS lambda then you can set up a trigger for other AWS services or endpoints to execute your Lambda function in response.

将代码上传到AWS lambda之后,您可以设置触发器以供其他AWS服务或终端节点执行Lambda函数作为响应。

运行AWS Lambda (Run AWS Lambda)

Lambda runs your code when triggered. An important point to notice is that it only runs the Lambda functions when triggered which makes it cost effective.

Lambda在触发时运行您的代码。 需要注意的重要一点是,它仅在被触发时运行Lambda函数,这使其具有成本效益。

支付时间 (Pay time)

You only pay for the time your Lambda was running to serve the request.

您只需为Lambda运行服务于请求的时间付费。

翻译自: https://www.journaldev.com/29259/aws-lambda-serverless-programming

aws lambda

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值