I'm working on an online turn-based game. I will have a server, but it will be used strictly for storing match data and relaying it to the match's participants (or spectators). For simplicity, no game logic will be processed in the server and the participants will be the ones to decide the legality of the enemy's moves etc.

My backend cloud knowledge is limited. I can work fine with PHP and MySQL, so I can technically make a PHP API, host it, and have the players poll it via HTTP requests every few seconds to get updates on the match (or upload commands). The PHP script will always open a MySQL connection, do one or two small queries and return a tiny bit of JSON-formatted data. To summarize, I believe that a single request would take at most 2 seconds to complete, and the output will be usually less than 100 bytes.

Given this fact, I figured I could perhaps try one of those serverless cloud functions services, like Azure's. It sounds just perfect for my kind of scenario.

For this project, I am estimating at most 100 users playing a match at any given time. And given the way the game is designed, they should probably poll data every two seconds. So 100 * 30 * 24 * 60 * 30 = ~130M executions per month. With Azure, that could be around $540 monthly just to support about 100 players.

This got me thinking, what if I just host the PHP API and MySQL database in a normal VPS, like GoDaddy's perhaps? Their cheapest option is about $50 a month. They don't meter the number of requests, concurrent users or bandwidth used (my usage is pretty low anyway, less than 15GB monthly).

So my question is, how come a 'serverless function' service is massively more expensive than just using a normal VPS to host my PHP API? Is there a catch that I may be missing?

Naturally it's all about testing - I should try both of them, but I figured someone has been through this already, or perhaps there is something obvious I am missing.

  • 3
    \$\begingroup\$ When you buy the cheapest VPS option, you get what you pay for. Maybe they don't meter your requests, but that won't be of much use for you when you have long ping times, low bandwidth during rush hour, bad storage I/O performance and a slow CPU. Good hosting costs good money. \$\endgroup\$ – Philipp Sep 27 '17 at 22:57
  • 2
    \$\begingroup\$ I would start with a $5 a month account somewhere and see what happens. If your backend really doesn't do much, you should be absolutely fine with that. Even the cheapest of servers are quite powerful when you just do some simple queries. \$\endgroup\$ – Erik Sep 28 '17 at 12:20
  • \$\begingroup\$ With serverless, they run a server, some special software on top, and then your code. And they charge for the special software of course, so it's obvious that if you are doing a lot of serving, you'd need to pay more. (The efficiency comes when you aren't doing much so that you can share the server with other users) \$\endgroup\$ – user253751 Mar 14 '18 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.