Serverless web socket server?

Are there any server technologies that allow you to create a server without a server without a server?

I know that the nature of long connections is that they are in terms of state, but if the only state is the connection itself at the transport level, then it seems that there may be a serverless product that abstracts this, so you only deal with the application level . Is there a cloud provider (AWS, Azure, etc.) that allows this? I see no way for AWS Lambda or Azure features to achieve this.

Does anyone have any idea? Just check.

thanks

+7
amazon-web-services websocket azure serverless
source share
6 answers

Currently AWMS Lambda and Azure features do not support this. If you plan to configure a scalable environment in AWS using websockets, you can use the Application Load Balancer in front of ECS clusters or EC2 instances using a Websocket supported server, such as NodeJS.

Another solution is to use fully managed services such as Google Firebase or Pubnub in your architecture to process the part in real time.

+1
source share

if the only state is the connection itself at the transport level

This is not entirely true. Web socket connections exchange keep-alives as a payload of level 7. Others may argue that it is more accurately described as a sublevel somewhere between layers 6 and 7 ... but in any case it is well above the transport layer.

And many applications use web sockets in other ways that are also not stateless. After connecting, then authenticated, there is no need to constantly re-authenticate, because the client in the juice will now be the same client after 15 minutes, and this is an overhead that could not be avoided in a serverless environment - every action on the website should be re-authenticated. In another example with a constant stream of data, the server can track what was sent, or which specific subset of the stream the client is interested in.

If you do not support (or do not need) a permanent connection to the server, you can ask the question: "Why are you using a web socket?"

Perhaps this is also true: HAProxy, a widely used web socket load balancer, maintains a constant connection to one server server for every current connection to the web socket. If the backend server goes offline, the balancer does not need to select another server for an existing connection. The client will need to reconnect.

+1
source share

AWS IoT provides MQTT endpoints and supports MQTT + WebSocket on port 443. This may be the closest you can get as a hosted service on AWS. Check out this link: AWS IoT Protocols You can define the rules that run Lambdas on AWS IoT or pass them to Kinesis and process threads through Lambdas.

+1
source share

Fanout can do it. It acts as a proxy server that can translate the activity of a WebSocket client into a series of HTTP requests. This allows FaaS databases, such as Lambda, to manage raw WebSockets. A function is called only when there is activity for the reaction.

Docs: https://fanout.io/docs/devguide.html#custom-websocket-api

WebSocket-over-HTTP Protocol: http://pushpin.org/docs/protocols/websocket-over-http/

Python Helper Library: https://github.com/fanout/python-faas-grip

+1
source share

AWS Lambda / Azure / GCP features do not support the web socket protocol. So it's ok to use third-party services. In addition to the comments above, I can suggest Ably: https://www.bly.io/ . It provides API / libraries for handling a web socket painlessly.

0
source share

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

The WebSocket API consists of one or more routes. To determine which route a particular incoming request should use, specify a route select expression. The expression is evaluated by the incoming request to get a value that matches one of your routeKey values ​​for routes. The API gateway sends the request to the corresponding lambda function.
From the AWS sample blog,
enter image description here

The application consists of the WebSocket API in the Gateway API, which controls the communication between the client and servers (1). Two AWS Lambda features respond when clients connect (2) or disconnect (5) from the API. The sendMessage (3) function is called when clients send messages to the server. The server sends a message to all connected clients (4) using the new API gateway management API. To track each of the connected clients, use the DynamoDB table to save connection identifiers (you can also use it to store other information about the connection status).

You can expand this to send messages to customers about any data changes using DynamoDB Streams

0
source share

All Articles