I've developed a site which hosts a two-player board game (backgammon) and while a match is being played other users can view the game and watch in real time. The AWS lambda that implements the game logic accepts moves from the players over websocket, stores in DynamoDB and uses ApiGatewayManagement.postToConnection to notify players and watchers about changes to the board state.
To send updates to watchers I am using Promise.all like this...
await Promise.all(watchers.map(to => gateway.postToConnection({
ConnectionId: to,
Data: <message>
})))
This is working fine for small numbers of watchers (10-20). My question is about how this will scale to 100s or even 1,000s of watchers. I can't absolutely confirm this, but looking at XRay it appears that using the method above, notification is done in batches of four concurrent postToConnection calls.
Does the node thread pool come into play in this scenario? I'm not 100% clear whether node will use NIO and fire off 100 backend requests for 100 notifications all at once, or put them on its internal thread pool which would limit concurrent requests to a small number. I am assuming here that
postToConnectionresults in an http call to an AWS service and that call can use NIO.Are calls to
postToConnectionrate limited? There is good information on inbound rate limits into API Gateway but I cannot find any information on outbound rate limits
Many thanks.