Jump to content

Question about websockets

Recommended Posts

Hi. It is my first post in the forum. I was looking for a specific category for server-side topic, but found nothing related.

I have some experience using PHP with Laravel to create web applications (even I have created some SPAs with Ajax calls),

but now I see that Node.JS is the better choice to create multiplayer games (because it provides a realtime interaction between server and connected users).


Some days ago I found Firebase and was using it for a bit. I see that the realtime database is really easy to use. The only bad thing is that the validation rules in firebase are strange. We have to validate defining a JSON with the rules.

But in general, we can use the realtime feature very easy. We don't need to configure servers with Node.js or socket.io

My question is, why nobody is using Firebase? When I look for realtime games, always see people using Node.js and Socket.io (I haven't used it yet but I think that Firebase = Node.js + Socket.io + MongoDB + the necessary steps to set up all of this).


Thank you.

Link to post
Share on other sites
59 minutes ago, rgk said:

For an easy answer, node.js and a websocket server (aka socket.io or ws) etc... is more configurable, and more control.

Do you use Node.js with MongoDB for develop multiplayer games?

In Firebase the data has to be denormalized, and usually is necessary to update in multiple locations when some data changes. That may produce inconsistencies.

I have read that MySQL without FKs is also a good option, even in some times it can be better than MongoDB in performance.

Link to post
Share on other sites

MongoDB is generally dreadful for performance, but, its used incorrectly a lot of the time.

However, Mongo was created with Node in mind as a primary consumer, it has excellent integrations with node and there are many many modules available to help with almost any scenario.

Firebase surely doesn't enforce the use of Mongo? Use whatever type of DB is best fitted to your game, if you don't know then use whatever you're comfortable with until you hit problems.

I think I've heard of a couple of peeps using Firebase for gaming though, but, I'd assume that it either comes down to a lack of perceived performance or maybe people just don't like the api Firebase provides, or maybe too complicated for what they need. I've never used it a lack of adoption normally comes down to performance, bugs and usage (i.e. will it work? will it break? can I use it?).

Link to post
Share on other sites

@jcarlos17 I use node.js with primus.io (with ws) and for a database I use PostgreSQL (with pg). I setup the majority of that pretty quickly compared to how long it took to just get a proper express login working. I never used Firebase but I generally prefer to setup and configure things myself. I have thought about using MongoDB for large data like replays, but PostgreSQL features great noSQL support.

Link to post
Share on other sites

I've used Firebase for non-realtime messages in multiplayer games, like setting up the lobby, doing chat, etc. I found that the updates are too laggy (hundreds of milliseconds) for real-time control. WebRTC or websockets back to a broadcasting server would work better. It doesn't matter what that server is, BTW: nodejs is nice because it's JavaScript but does not have performance gains over-and-above PHP or Python and certainly not above C/C++ -- but writing an entire server in C++ might not be everyone's bag. ¯\_(ツ)_/¯

I second matt's advice: use what will get a game out the door first. Use what you know until what you know doesn't get you far enough.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...