Question

I made a game in node.js and uploaded it.. it should be 30 - 60 frames per second..
Now I testing it and it runs slow.. I mean in local network it runs a lot smoother

The server isn't that far away.. So any tips how to make the fps better?

What is better xhr-pooling or websockets, what is faster?
The game is set with xhr-pooling like this -

io.set('transports', ['xhr-polling']);

the game is hosted in appfog

If needed I can post the game link!

Was it helpful?

Solution

The question here is what are you trying to do? If the server is sending a message to the client for every frame, what you are talking about it basically impossible -- network latencies below 16 ms (60 fps) or 33 ms (30 fps) over the internet are impossible to reliably guarantee. It might work over a local network, and almost certainly can work on a local machine, but not over the internet. If you need to get information from the client to the server and back in the next frame, your round-trip latency needs to be that low, including the processing on both sides. Since both xhr-polling and websockets use TCP, it gets worse because one slow/lost packet will pause everything after it until it finally shows up.

You really need to decouple the rendering from the server as much as possible to make a viable game in a browser. The network just isn't fast enough.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top