nodeJS server slow and jerky performance?

Using nodeJS and socket.io as an excercise I built a prototype of a mouse cursor, controlled by an iphone, that moves on the browser viewport. that's it. it works, but the performance is really bad. the cursor is jerky, chopped...it doesnt move smoothly...as I see in my terminal the emission and sometimes it gets stuck...

I was thinking of using something like code below, but is still way from being optimal..

setInterval(function() {
   socket.emit('sendposition', x, y);
}, 25);

I wonder if thatere is any best practice to improve the performance.. How can you build an online multiplayer game, if the performance is so poor?

thanks!

There is probably jitter in the network traffic, which is normal, particularly for TCP traffic where the network guarantees in-order delivery, so that when one packet is late, all the others behind it have to wait.

I recommend you try it with UDP, with each datagram containing a delta in the X,Y position. That way, if a few packets are out of order, the mouse still gets to the same destination, and if a few packets are dropped then the other packets still come through and nudge the cursor along anyway.

I tried using socket.send, instead of socket.emit, and it sounds...better..not perfect but way better...