Download

Node.JS vs ASP.NET as backend server for my game

Hello guys,

I’ve been wondering what would be a better solution for a backend server for my game.

What I need to do?

  • Save player level/experience
  • Save score
  • Save progress on which level was completed
  • Achievements

So I have some experience in ASP.NET MVC & WebAPI but I was wondering if Node.JS would be a better solution in case if it’s faster than ASP.NET.

I have already made my system work with ASP.NET but I’m wondering if I should invest time studying Node.JS for better performance?

What DB are you using? Node.js + NoSql DB would be a good choice for what you need.

Well for now nothing exactly. I just return some strings for testing.

Well I’m not sure if NoSQL database would be a good idea due to the fact that I want to have player right? And his XP and level must be tied to the id. So I do need relations.

Just checked some benchmarks on the internet, and it seems that Node.js performs twice faster than WebAPI.

Edit: I suppose MongoDB would be the solution

It’s fine for basic relationships, but make sure you have planned out how exactly the relationships will be otherwise it ill be costly to update all the rows afterwards.

I understand what you mean. So you are suggesting using Node.JS.

http://www.ageofascent.com/asp-net-core-exeeds-1-15-million-requests-12-6-gbps/

These things will happen how often? When the player saves game, when the player enters/leaves game, and maybe one or two of them will happen on some timed interval.
You’re talking about requirements that will happen once every few seconds. So unless you have a good idea that you will have several million players of your game, the difference in performance between X requests per second and Y requests per second (where both X and Y are greater than 100,000) is entirely moot. Use the tool you already know how to use.

I would build it on new ASP.NET Core 1.0, their benchmarks are just awesome. I have used it too and its really nice (using Azure) is really easy to connect to MS SQL DB and have backend ready, I am using this kind for my game too but old ASP.NET 4.6 but will upgrade to Core 1.0.

Well requests are not going to happen very often. After you get some XP, earn some kills, at the end of the level, stats are going to be saved in the database. Technically I would prefer using MVC4 because I already know how to use it and don’t want to waste time using node.js due to the fact that I have to create routes, controllers, etc.

Technically you do not need MVC since you have no view to be rendered, but in mvc6 there is just a single controller for both MVC and web api so it may be easier.
as for the routing part you could just make a web api project and use Data Routing Attributes for each method:

[RoutePrefix(“api/Whatever”)]
public class WhateverController : ApiController
{
[HttpGet]
[Route(“GetCandy”)]
[ResponseType(typeof(List<CandyModel>))]
public async Task<IHttpActionResult> GetCandy()
{
return Ok(new List<CandyModel>());
}
}

Yeah that’s a cool new feature, but, how do you pass arguments? Might reasearch a bit on it

[RoutePrefix(“api/Whatever”)]
public class WhateverController : ApiController
{
[HttpGet]
[Route(“GetCandy”)]
[ResponseType(typeof(List<CandyModel>))]
public async Task<IHttpActionResult> GetCandy(int param1, float param2, string param3)
{
return Ok(new List<CandyModel>());
}

[HttpPost]
[Route(“UpdateCandy”)]
public async Task<IHttpActionResult> UpdateCandy(CandyModel Model)
{
if (Model == null || !ModelState.IsValid)
return BadRequest(ModelState);

return Ok();

}
}

for the Model validation with HTTP Post you can still use DataAnnotation:
public class CandyModel
{
[Required]
int ID { set; get; }
}

Node is not made for extensive computing. It’s just fast event loop, that why it shines in web dev. Net not so much better. Web, apis, messaging and such “light” and short lived thing are great made with them. C/++, Java, Go(?) are better suited for business computing. More low level, more control, less overhead. But for prototyping stuff, Node, and Net are shining. Just imho.

This. If you have any kind of CPU intensive processing going on in your node application, you will halt the event loop. This makes the whole application unresponsive to other users. Say no to node.

Personally I’d go with java and spring boot. With spring boot you can write a simple restful crud app in minutes: Getting Started | Accessing JPA Data with REST
Other possibility for quick restful crud app would be ruby on rails.

MongoDB is great if you want awful tooling, awful domain specific query language and inconsistent data.

Or you can start right away for free with Google’s AppEngine in Python/Java/Go…

Thanks for all your suggestions friends.

I will test out all other tools and see which one will fit me.

For now ASp.NET Core seems like a reallly good solution.