Page 1 of 1

Multiplayer Lag

Posted: Thu Aug 02, 2018 6:45 pm
by dani0854
I have a Debian 9 VPS on which I run Headless version of Factorio. When we just launched the server(yesterday) it was fine. My friend was having a very tiny lag but nothing special. Today is completely unplayable. It works for most of times. But some times it lags a lot. The server how ever only uses 40% of ram, and 40-50% CPU. When latency has no minimum it is around 10 for both of us. Even when it lags it is still no more than 15. When it lags there is a little clock appearing above latency. Few times It was even that bad that the server kicked us. The console was spiting something like this.
ImageImage
Most of the time it happens is when some one is running.

What could be the problem possibly be? Our pingtests to that VPS is fine. Thanks in advance.

Re: Multiplayer Lag

Posted: Thu Aug 02, 2018 6:58 pm
by Jap2.0
Try typing "/c game.speed = 0.8" in the console. If this works, it means that your computers cannot keep up with the server. Otherwise, please post everything requested here. Thanks!

Re: Multiplayer Lag

Posted: Thu Aug 02, 2018 7:50 pm
by dani0854
When no lag
Image



When its lagging(there also a litle clock flashing by FPS/UPS but it didnt't get in the screenshot)
Image

Re: Multiplayer Lag

Posted: Thu Aug 02, 2018 7:59 pm
by Jap2.0
I'm guessing that setting sprite resolution to normal should fix this, but (if you still have issues, or want more specific suggestions) a log from the client would help with that.

Re: Multiplayer Lag

Posted: Thu Aug 02, 2018 8:04 pm
by dani0854
No, the problem was before I set Sprite resolution. I set it to very low when trying to investigate my self what happening. How ever nothing changed when I changed sprite resolution. I also changed game speed to 0.8 but it didn't help either.

Re: Multiplayer Lag

Posted: Thu Aug 02, 2018 8:24 pm
by Zavian
Just to add to what Jap2.0 said, on the screenshot where you are lagging, the render step is taking 30ms, and the whole update and render cycle is taking 48ms, which mean you are only getting about 20 fps. (Actually probably lower, since the server is running at 47 ups, and client will skip rendering some frames so it can keep up). Most likely reason is that the textures aren't all fitting into the video card vram. Client side logs should provide more info there.

Edit: You posted a follow up whilst I wrote the above. having looked at the logs, I think you might be memory starved (on the client machine, not the server), and windows might be swapping to and from disk. That would slow down processing each update and rendering as well. (From the screenshots, it looks like most entity updates are taking less than 10ms, but you have also had some 35ms and over 80ms).

Re: Multiplayer Lag

Posted: Thu Aug 02, 2018 8:32 pm
by dani0854
The reson I have 20 fps is because i zoomed out. If I zoom in it goes back to normal. The issue when its laging is that fps could be fine but i will get kind of teleported my few steps in random sides. And also a lot of warnings that server console spits out(In 1st post). Also my friend has a much more powerfull PC than I do. He has the same problem.

Re: Multiplayer Lag

Posted: Thu Aug 02, 2018 8:33 pm
by Loewchen
First thing to do should be removing the minimum latency, 60 is completely nonsensical.
The lag could be explained solely by the lacking graphics hardware, the fact that it occurs at night is suggestive. You could try to run the server at a very low speed (after removing the latency setting) like .3 to rule out a CPU bottleneck on the client but I would expect a non zero jump count if this would be the lag causing issue based on the screenshot.

Re: Multiplayer Lag

Posted: Thu Aug 02, 2018 9:21 pm
by cbhj1
The question that sticks with me is what type of server are you using? You say VPS, sounds like it could be server node congestion, especially with how demanding Factorio is on the RAM and CPU.

Re: Multiplayer Lag

Posted: Thu Aug 02, 2018 9:35 pm
by dani0854
CPU 2 cores 2.4GHz
RAM 4GB
How ever none of them loads more than 50%.

Re: Multiplayer Lag

Posted: Thu Aug 02, 2018 9:49 pm
by dani0854
Also i noticed that trains often after server reboot, or sometimes even during the game, have a "bug" and say that there no path available.

Re: Multiplayer Lag

Posted: Mon Aug 06, 2018 12:05 pm
by nuhll
its just lagging.

client and or server is too slow for ur factorio.

Upgrade client/server or downgrade the game speed (as suggested above)

Re: Multiplayer Lag

Posted: Tue Aug 07, 2018 8:20 pm
by dani0854
What kind of specs i need for server?

Re: Multiplayer Lag

Posted: Tue Aug 07, 2018 8:27 pm
by dani0854
I don't care if client lags. I need to make sure that servers works properly. Server only uses half of its power. Could it be possible that headless version only loads one core of CPU? If VPS is not powerfull enough which specs should be optimal. Because i heard people running server on crapy vps with 1 core and 1 gb of ram and it worked fine.

Re: Multiplayer Lag

Posted: Tue Aug 07, 2018 8:30 pm
by dani0854
Or maybe the connection problem. The VPS has 200 mbit chanel. The ping to it is 30-40 ms averege for us to that server.

Re: Multiplayer Lag

Posted: Tue Aug 07, 2018 11:57 pm
by Zavian
Most of the factorio simulation code is only single threaded, (that applies to both the server and the client), so I'm not surprised that the server is only using one cpu core.

As I've already stated, from your second screenshot above, the client is struggling to keep up. It is doing 47 updates per second, but only 20 frames per second. That means that in order to keep up with the server it is skipping rendering 25 frames per second. From the timings in that screenshot the render step is taking 30 ms. That is a lot. (On my 7 year old HD 5770 rendering normally takes around 3-4ms). It's also around 4 times as long as the render step in your first screenshot. Indeed your timings are all over the place. The game update in the first screenshot takes 17ms, but the same game update takes only 9ms in the second screenshot. Now some of the difference in render time can be explained by the fact that you have zoomed out further, which means your integrated graphics need to render more sprites. There are also more trees on screen, which again adds more sprites, but even both together shouldn't cause the render step to take 30ms.

From the log files you provided above your client machine only has 4GB or ram, some of which is going to be used by the integrated graphics. Hence my suspicion that the root cause is windows running low on available ram and swapping things to disk. There isn't anything here that makes me think the server is the problem, but there is plenty that shows the client is struggling to keep up with the server.

Re: Multiplayer Lag

Posted: Wed Aug 08, 2018 9:54 am
by dani0854
I don't care about client. The reason i had frezez is because of lack of CPU and RAM on my PC. I know that. That was beacause i had about 40 tabs opened in the background in google chrome which took all the RAM. That was because i was ivestegating the problem to do not with frezeez. But instead with server problem, when sometimes server were stop responfing for 10-30 second or responded just a bit. If you still think its client problem. My friends had the same problems with that server. He has 1080ti and 32 gb of RAM. I don't realy think its to do with client. My issue is not the frezez on client side. Is that the server some times respondes much slower. So i can walk up 10 meters in game without frezez and then get teleported back. My friend has the same problem. I can only see the overall loading of the server. And sometimes it jumped to 50% on 2 cores. If the game only uses 1 core for calculation then it means one of them sometimes uses more than 100%. Is there are any way to make game multithreaded? Or what are the required specs for modded headles servers on Debian 9?

Re: Multiplayer Lag

Posted: Thu Aug 09, 2018 1:20 pm
by Zavian
as far as I'm aware the server basically runs the same simulation code as the client, but without the rendering code. Given your oldish cpu (mine is even older), you will probably run into issues client side before you run into issues server side, unless that server cpu is even older than the client. So that leave network issues. If you are using wireless network, you could try switching to wired, and see if that helps. You could also run something like wireshark to log all packets at both end, and see if you can track down the issue that way. (A simpler first step might be to ping the server, and look for packet loss that way).

Regarding multithreading read this post (viewtopic.php?f=5&t=39893&start=60#p238247). Note that Harkonnen was a factorio developer at the time he wrote that post, and that belts had a major performance boosting rewrite since then.

Re: Multiplayer Lag

Posted: Wed Aug 15, 2018 10:07 pm
by adam_bise
My friend and I had same issue (unplayable lag) on Linux headless 16.51 and never could figure out why.

But when we put the map on a windows box suddenly it was fine. You might try that if convenient.

Funny thing though, a routed player only had lag when at least one other player was online. A local player never lagged and a routed player never lagged if alone... no idea why.