HQ Trivia software architecture

HQ Trivia attracts millions of players every day and a lot of our customers ask the question “What is the architecture behind HQ Trivia?”

Let’s try to uncover the mystery in this blog post. I won’t go into very technical details, the goal is to give an overview. So why not to take the easiest way and check HQ Trivia “Job Opening”, specifically they are looking for Senior Backend Engineer

Ok, so here it is, they useNode.JS. And Node.JS goes with JavaScript or TypeScript. Technically speaking it’s not the best solution since there are other alternatives that outperform Node.JS, likeGo. But when you have a shortage of engineers and Go engineers as you can see from the chart below are rare guys, Node.JS can do the job.

Node.JS need to save data to relational Database, most popular options are PostgreSQL or MySQL. They are similar without big differences, so let it be PostgreSQL.

Next important factor that many providers of “HQ Trivia clone” platforms forget is system ability to scale. When you have one million players clicking the button at the same time that’s a huge load on the system. Achilles heel in the architecture is the Relational Database that physically can’t make one million data savings in a very short period of time.

Question of the day: How to handle that load? They are different options available, let’s assume HQ Trivia use in-memory database like Redis. So Redis can sit in between users and PostgreSQL, aggregate data and eventually save it over the time to PostgreSQL.

Further up the agenda we got mobile applications. What technologies does “HQ Trivia” use?

And that is NotUnity. Why not? Because there is no clear way on how to make low delay video streaming to Unity. If someone propose you to use Unity with video streaming apps, ask them to make a demo first and show that the system can stream with sub-second delay.

Recently we got a customer with Unity mobile app who has a complete system with one “minor glitch” – video streaming doesn’t work. We managed to “fix” it but video streaming delay is 2.5 seconds, which is not the best option for a Trivia game.

Next part is a web application for the Host to run the show. That could be done in React.JS or Angular, not a big deal.

Now let’s talk about video streaming.

HQ Trivia need to stream to millions of users without glitches and delays. There are few video streaming solutions that potentially are able to handle that. And please forget about open sources like Kurento or Jitsi. We testedRed5Pro and it works. Maybe Wowza can handle that too. What HQ Trivia is using no one knows, but since it is a relatively young company I assume they don’t have custom solutions and use something ready from the box like Red5Pro or Wowza.

But again, before buying the video streaming system, ask the vendor to prove an ability to scale and handle all players simultaneously with minimum delays. It is super important!

Finally, we got to the last chapter which is “Cloud”. Market leaders areAmazon AWS,Google Cloud,Microsoft Azure. HQ Trivia use Amazon AWS, but it’s hard to make a mistake here, each and every cloud, mentioned above, will do the job.

Last keywords from the job opening are Terraform and Kubernetes. One game for HQ Trivia could use 100 or more servers easily and engineers need to control that “zoo”. Terraform and Kubernetes help development operations engineers to deploy the platform to servers in the cloud with a click of a button.

That’s it! Hopefully, I was able to lighten technologies behind HQ Trivia.