gentimouton/crowd-control — Issue #18: Server loop and pumping
Author: gentimouton
Created: 2012-02-07 08:12:23+00:00
State: open
Labels: critical, feature

Right now, the server runs at 20 fps = 50 ms. The client runs at 100fps = 10ms.
The average C-S RTT is approximately

- 10ms/2 = 5ms on average to fit an action during the client's loop
- 1ms on localhost
- 50ms/2 = 25ms on average to wait for the server to pump to receive packets
- <2ms server processing, stack packets to be sent
- 50ms for the server to loop, then pump to send those stacked packets out
- 1ms on localhost
- 10ms/2 = 5ms on average for the client to receive a packet during its loop

**Total**: from 54ms to 124ms, average of **89ms**. In practice, 100ms was common.

Solutions
---

A -- This RTT could be reduced to an average of 39ms (range = [4ms, 74ms]) if the server was pumping twice during a server loop: 1) at the beginning, to process the received packets and put new packets on the network according to the game logic, and 2) at the end of the loop to push those packets out without having to wait a whole server loop. To do so, send an event just before having the clock sleep?

B -- Switch to epoll and rewrite the whole network component on each sides (i have more urgent to do right now, though ...)

C -- Leave as it is right now. If the RTT becomes a big issue in the near future, switch the server to 100FPS (10ms) or 200FPS (5ms). (most likely to happen for now)