Help me choose the correct server architecture

I have a game already live for about a year on android and iOS. I’m working on a content update for it and one of the things I want to add is psuedo multiplayer. To clarify: the games’ levels are randomly generated, I want to offer a daily challenge where all users can attempt the same rand gen level and post scores to a leaderboard and be ranked against the world.

My question is what sort of server architecture is best for this service and how would I go about setting it up? Since it’s not real time multiplayer, several multiplayer implementations are simply overkill. Note that my rand gen code is far from complex.

I’ve been looking at Amazon Web Services but I’m having difficulty determining which of its myriad of services can be employed to achieve the outcome.

Bullet points of services needed:

  1. run a small rand gen program on a timed interval.
  2. Allow users to connect to a server to download the List of rand gen numbers
  3. Allow users to upload score
  4. Download and display current leaderboard (max ~50 items) - this code can be run client side (sort numbers high to low with names);

All ideas and answers are apprieciated.

This is a biiiigggg topic and there are a few ways to approach it.

First, the easy bit is points 1 & 2 (and partially 3):
Run a server somewhere. This could be an EC2 instance on Amazon, but you might find it more cost effective to use a service like Heroku. To schedule activities you can normally use CRON or some varient of it. Have that call your rnd number generator.

In order to allow people to get these random numbers, I’d write them out to a file which is then downloaded by the players and parsed by the game. Ideally you’d have this file (or a copy of it) on a CDN for best availability. Amazon offer Cloudfront for this but there are plenty of other options. Even just using S3 would be an option, although there are usage limits so a popular game may run foul of this.

Now for the score side of things. Firstly to upload a score you’ll need to be able to have some sort of API to post the score to. Some existing systems provide this, for others you’ll need to run your own server (could run alongside the ideas above). I’d recommend running it as a NodeJS server for best performance and availability.

If you expect your game to be very popular, make sure you can scale easily. Hundreds / Thousands of post score requests will take down small servers, so you need to be able to cope with it, ideally automatically. Again, Amazon offer this service, as do plenty of other places.

Actually storing the scores can be done in several ways. Firstly you’ve got you NoSQL databases like Mongo, CouchDB and Amazons DynamoDB. These are great for storing data and perform brilliantly. However they are not good at sorting data, meaning that asking it to return a list of todays top 20 scores is not really a good idea (there may be some exceptions though).

Relational databases like MySQL, SQL Server and Amazons RDS are perfect for sorting data, but you want to be careful about how much data you throw at it (and they tend to be a bit more expensive to run as a service, but you can roll your own solution on your own server if needed).

I can’t really tell you what is right for you, but for me, if I was literally just storing the daily scores and the traffic wasn’t too heavy I’d store in a relational database. I’d post the scores to some API which then parses and inserts into the database, ensuring that it’s optimized with indexes to search by day and score. I’d also probably look at automatically destroying data after a certain period (say 14 days) in order to keep things running optimally.

Another option is to insert everyones data into a NoSQL database, and have your API post only highscores into the MySQL database (or potentially just write to some other cache). Of course, you could just avoid database altogether and just come up with a caching solution… it really does depend on your needs.

Finally, you’ll probably want to associate the score with a username of the player, and ideally some sort of unique ID. You may need to authenticate with a service like Facebook to do this, but you could also just allow people to create their own username. Another option is to use Amazons mobile authentication service to assign id’s and tie them to scores.

One possible solution to all the above is to post the scores to Facebook scores. This will handle a lot of the lifting for you, but not everything. I honestly don’t remember if they allow Global scores or not, so that’s something to check out. You will also need to have some script running to delete the scores each day (which could prove problematic if you need to recover them at a later time to show poeple their previous performance).

My final bit of advice is to look at using Microsoft Azure as an alternative to AWS. They have a great range of packages and if you can join their Bizspark program, you get A LOT for free, for free years. Much better value than what AWS offer in their free tier. I’m not saying that’s right for you, but a lot of people overlook Azure simply because they aren’t aware of it.

Not sure if that helped or hindered, but hopefully it’s a bit of guidance!