Implementing a live quiz

Hi !

My company developed a multiplayer trivia game using Unity+Nakama, now we are thinking of adding a live quiz mode, something like HQ Trivia but simpler, without chat or live video stream.

Players have to join the live quiz in a specific time of the day and try to answers as many questions as possible, the game will be synchronous, so every player will see the same answer at the same time, and the time will be managed by the server.

It seems to be something that could be achieved using a server-authoritative match, but I was wondering if nakama could be able to handle tens of thousands players in a single match, I couldn’t read about any limitation in your documentation.

There’s no strict limit on the number of players in an authoritative match. It all depends on the message flow (number and size of messages in/out), the logic you build into your match functions, and the hardware provisioned for the server - it’s best to benchmark for your particular use case so you’ll know exactly what to expect for some given configuration.

That said there are other ways to model this use case. I’m familiar with HQ Trivia so I’ll assume you’re looking to build a quiz experience that looks similar.

You might consider using the streams feature instead. It would look a little like this:

  1. Add all users to a “main” stream that they’ll receive data from the quiz operator on. This is how the client might receive questions, or updates on how many people are currently connected (if you want to expose this), answer statistics and so on.
  2. Users call an RPC function to answer questions when appropriate. This would put the user on a new stream labelled “1a” or “2c” for example. This stream label is a composite string representing the question number and the answer option they’ve chosen. Check that the user doesn’t already have an answer submitted by checking the other stream possibilities for that question number.
  3. If answering any question after the first one, the RPC function would check if they have the previous correct answer. For example the user wants to select answer “c” for the 2nd question, and the correct answer for question 1 was “a”. Before adding them to stream “2c” the server checks if they’re on stream “1a”. This way only users that answered the previous question correctly are allowed to proceed to the next one.
  4. You can see how many users picked each answer by counting presences on each of the streams. Counts on streams “2a”, “2b”, and “2c” for example will tell you how many users chose each of those answers for question 2.
  5. When the last question has been answered list the users on its correct answer stream and those are your winners.

This is the most basic flow as I see it, let me know if I’ve missed anything for your use case. On top of this you’d look to limit time available to answer, I can suggest a couple of ways to do this but see if this makes sense first.

1 Like

Hi Zyro, thank you for your detailed answer, it sound to be a beautiful solution, we are already working on it ! What are your suggestions to manage time in game ? We also need to start the live quiz at a specific time of the day, we thought to implement with a cronjob through jenkins, what do you think about it ?

I would deliver an encrypted/signed token along with the question data, which would contain the question number and time deadline. Clients that want to answer the question must submit the token along with their answer, and on the answer submission RPC you check the deadline has not passed.

To manage the quiz start, end, questions etc you can create a special privileges client (a small single-page webapp perhaps?) and have a user ID with rights to call restricted RPCs to broadcast data on the “main” stream to all users. New questions, results for previous questions, announce winners etc can all be triggered by RPC function invocations made by this client/user.