Domanda

First post on the software engineering stack exchange, I hope the question fits the purpose of this sub.

I'm building a serverless game server with the following architecture and was wondering if anyone here has already attempted this and if it's a valid strategy. Also if you're aware of any caveats I should know of, I will be grateful for any input here.

I've run into a problem here which I'm not completely sure how to address.

The infrastructure

I am using is AWS Lambda and SQS

How it works

The core of the game is intended to work as follows:

A game consists of a number of rounds.
Each round has a duration of 10 seconds, has one question and one correct answer.
Each player must have their answer in before the end of the round.

I.e. a game would look like this:
Game started at 10:00:00
round 1 starts at 10:00:00
round 1 ends at 10:00:10
round 2 starts at 10:00:10
round 2 ends at 10:00:20
etc...

My approach: When all players have confirmed their participation, the game is created. This will queue up a delayed SQS message that will trigger a lambda function for each round. Delayed by round number * 10 seconds each.

The code of this lambda function will simply round up all the answers that have been entered for its assigned round, assign a score to each and persist that to a DB and die.

The problem

Delayed SQS messages are cool and all, they do exactly what you'd expect, they only appear in the queue after your specified timeout, however, that is currently not a valid trigger for a lambda function. I'm aware SNS does serve this purpose but AFAIK there is no way to delay an SNS.publish() invocation.

What I'm bending over backwards here to avoid is to have a lambda function waiting for X amount of seconds until it publishes an SNS notification.

Are there any solutions that could help me approach my goal?

Thanks in advance

Nessuna soluzione corretta

Altri suggerimenti

In AWS when you want to orchestrate this sort of thing, you want to look at using Step Functions. You can create the game event state machine with Step Functions.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
scroll top