Is it possible to use Socket.io with AWS Lambda?

后端 未结 8 1457
深忆病人
深忆病人 2021-01-30 01:31

Is it possible to build a function in AWS Lambda that creates a websocket and send data to subscribed applications?

Something like this:

John has the app SuperPh

相关标签:
8条回答
  • 2021-01-30 02:17

    I don't think that Lambda is going to work for the case you described here. The link to the AWS forum below points out that the Lambda function can only run for a maximum of 15 minutes and further since you are charged per 100ms of function runtime this would probably be cost-prohibitive. There is a comment from Amazon saying they've heard the request several times so are interested in some way to allow for this.

    https://forums.aws.amazon.com/thread.jspa?threadID=205761

    Here is a post from someone who appears to have a good deal of success using EC2 and NodeJS but he had to use an alternative to Socket.io called Websockets/ws.

    http://www.jayway.com/2015/04/13/600k-concurrent-websocket-connections-on-aws-using-node-js/

    If you plan to run your server behind a load balancer it looks like you are going to have a few more hoops to jump through:

    https://web.archive.org/web/20160118124227/http://coding-ceo.ghost.io/how-to-run-socket-io-behind-elb-on-aws

    0 讨论(0)
  • 2021-01-30 02:19

    No! Lambda was not designed for socket.io. Lambda was designed for short-time processing only.

    If you want to provide cheap notifications, you can try external services like PubNub or Realtime Framework.

    If you want to stay using only Amazon services, don't bother trying SNS because it won't serve for this use case (there isn't an endpoint for browsers).

    However, you can try AWS IoT. I know that it sounds strange, but since it supports browsers through MQTT, it's a great tool for cheap, fast and easy to develop notifications. Follow this link for a great tutorial. Demo code is available here.

    0 讨论(0)
提交回复
热议问题