I am designing a game too. I am using NodeJS and Apache. Because of Node query processing speed, I am using it only for real-time things, while the Apache server is for login, register and things which not need fast processing.
But that's for now. I am considiring to migrate to Node only and use the power of JavaScript only. There are enough libraries for Node which can replace PHP at all.
But you always can open several node servers with different ports which to reflects different aspects of the game.
For example: if the battle system is such like a WoW or any other desktop games, that means a lot queries to the server, especially if you have a battle with more than 1 enemy player. This includes positioning queries(when you move, you always need to show to your enemy player where is your actual position), spell queries(when send spells each-other), calculations and etc.
So this would be better to be processed by another server. Should increase the performance for the rest of the site.
One advice when you use Node. Always use "Promises". They are very powerful and useful for code structuring and for promise that you'll get a result.
function someFunc(args, args, ..., cb) {
//... code code...
cb(result); // some result or data
}
// some other file
someFunc(data, data, ..., function ( result ) {
// using the result from someFunc as Promise
});
Is there a best practice for including all of my game code on the node server?
This, for me, is worst thing ever. I am also trying to structure my code, but for now when I'm using PHP with Apache all my stuffs are structured with MVC pattern. But when I need to use NodeJS all files there, are spread away.
So now, I am trying to create some MVC pattern. But if I migrate to Node at all I'll maybe use MEAN stack(Mongodb(for Models), Express(for Controller), AngularJS(for View) and NodeJS(for server)), which provides this.
Of course there are many other libs for that as ReactJS for View in M-V-C.
Sorry about my english. I hope that I've been understanable.