Note that there are some explanatory texts on larger screens.

plurals
  1. POHow expensive to build a realtime massive multiplayer game using node.js/socket.io?
    primarykey
    data
    text
    <p>Hi I am trying to build a realtime multiplayer game using node.js and socket.io.</p> <p>Now, implementing itself in terms of coding won't be so much of a problem, but coming from a traditional http request-response web programming model, I have no idea how expensive this would be in terms of traffic and server load. Basically during a game, a player's browser should track realtime mouse input events and keep broadcasting them to all other players in the same game.</p> <p>Here's an example, let's say my avatar follows around my mouse pointer on the screen, and it should be broadcasted to rest of the players on the screen in realtime. I would do something like:</p> <pre><code>// client side $(document).on("mousemove", function(event){ io.emit("coordinate", {x: event.pageX, y: event.pageY}); }); </code></pre> <p>and on the server:</p> <pre><code>// server side io.sockets.on("connection", function(socket){ ... socket.on("coordinate", function(coordinate){ socket.get("username", function(err, username){ socket.broadcast.emit("move", {username: username, coordinate:coordinate}); }); }); ... }); </code></pre> <p>I think this should work, but this requires the browser emitting several events per second to the server, which subsequently should broadcast them to rest of the players in the same game, and I am worried about the implication of this. One thing though is that the size of each fragment of data being transmitted is not that large (basically it's just an x and y coordinate). If this is too expensive, no matter how great this game is, I don't think I can ship it. Could anyone enlighten me? Thank you.</p> <p>[EDIT] To clarify, I am not asking about how to make this architecture more efficient. I just want to know if this type of system is realistic enough in terms of system load (and maintenance cost) For ordinary web services I can just estimate the cost by looking at page view numbers but websocket is an entirely new field I am not aware of, so I wanted to ask.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload