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, 2017 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, 2017 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, 2018 at 20:53

2 Answers 2


If you want only managing database, you can use shared hosting pack. You don't need Bare metal or VPS cloud server. Serverless function or aws Lambda servers developed for instant processing and not being used for a long time. It would be very costly to run them continuously and shut them back down.


With those serverless APIs, you are paying for much more than just traffic and computing resources. You are paying for:

  • Scalability. Suddenly have several orders of magnitude more requests because the game became a viral hit? No problem. Adding a couple instances just takes a couple clicks, or can even be automatized via APIs.
  • Global availability. Companies like Amazon, Microsoft or Google have datacenters around the globe. This allows you to provide short latency times to your players no matter where they are. Renting your own servers all around the world from all kinds of local companies might be possible, but could turn into an administrative nightmare.
  • Platform as a service. You might be able to save a lot of development and administration hours by using their existing services instead of first setting up your server and then creating your own API from scratch in PHP. And person-hours are money!

These factors might or might not matter to you. If you are strapped for cash, then going the "do it yourself" route with a private virtual server might be a viable alternative. And another advantage is that you avoid the vendor lock-in you have with a proprietary PaaS solution.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .