无服务器Web套接字服务器? [英] Serverless web socket server?

查看:109
本文介绍了无服务器Web套接字服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有无服务器技术可以构建无服务器websocket服务器?

Are there any serverless technologies that allow a serverless websocket server to be built?

我知道长时间运行的连接的本质是它们是有状态的,但是如果唯一的状态是传输层上的连接本身,那么似乎有一种无服务器产品可以将其抽象化,因此您只需处理应用层.是否有允许使用此功能的云提供商(AWS,Azure等)?我看不到AWS Lambda或Azure Functions实现此目标的方法.

I know the nature of long running connections is that they are stateful, but if the only state is the connection itself at the transport layer then it seems like there could be a serverless product that abstracts this away so you only deal with the application layer. Is there a cloud provider (AWS, Azure, etc) that allows this? I can't see a way for AWS Lambda or Azure Functions to achieve this.

有人有什么想法吗?只是检查.

Anyone got any ideas? Just checking.

谢谢

推荐答案

随着WebSocket对AWS API Gateway的支持的发布,您可以创建无服务器的WebSocket API.

With the release of WebSocket support for AWS API Gateway, you can create a server-less WebSocket API.

WebSocket API由一个或多个路由组成.要确定特定入站请求应使用的路由,请提供路由选择表达式.该表达式根据入站请求进行评估,以产生与您的路线的routeKey值之一相对应的值. API网关将请求路由到相应的lambda函数.
从AWS博客示例

A WebSocket API is composed of one or more routes. To determine which route a particular inbound request should use, you provide a route selection expression. The expression is evaluated against an inbound request to produce a value that corresponds to one of your route’s routeKey values. API gateway routes the request to corresponding lambda function.
From AWS blog example,

该应用程序由API网关中的WebSocket API组成,用于处理客户端和服务器之间的连接(1).当客户端从API连接(2)或从API断开连接(5)时,两个AWS Lambda函数会做出反应.客户端将消息发送到服务器时,将调用sendMessage函数(3).服务器使用新的API网关管理API将消息发送到所有连接的客户端(4).要跟踪每个已连接的客户端,请使用DynamoDB表保留连接标识符(也可以使用它存储有关连接的其他状态信息).

The application is composed of the WebSocket API in API Gateway that handles the connectivity between the client and servers (1). Two AWS Lambda functions react when clients connect (2) or disconnect (5) from the API. The sendMessage function (3) is invoked when the clients send messages to the server. The server sends the message to all connected clients (4) using the new API Gateway Management API. To track each of the connected clients, use a DynamoDB table to persist the connection identifiers (You can also use it to store other state information about the connection).

您可以使用 DynamoDB流

这篇关于无服务器Web套接字服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆