Server locked after a few hour uptime

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

hokmbaz
Posts: 2
Joined: 15 Aug 2017, 08:18

Server locked after a few hour uptime

Postby hokmbaz » 10 Oct 2017, 14:16

Hi SFS Team,
currently i am learning sfs api and evaluating its features
but while i am developing extensions and sfs server is idle in background (with no connected user), after a few hours it freeze and accepts no connection even from admin panel.
i attached an image of admin panel when this situation happens. it always happen after a few hours. indeed i dont have any special logic in zone extension just some basic request handlers and log statements.
is it a bug or it is a problem with my system?
thanks
Attachments
sfs.jpg
(250.89 KiB) Not downloaded yet
User avatar
Lapo
Site Admin
Posts: 19732
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Server locked after a few hour uptime

Postby Lapo » 10 Oct 2017, 14:31

Hi,
from the screenshot it looks like there's been quite a bit of recent activity in the server.
SFS2X is takin 25% of the CPU and the system is also pretty busy.

Indeed the user counts are super low, which seems to indicate that you've something running in your Extension and causing problems.
With no user activity you should have no CPU usage (or at least < 1%)

I'd recommend turning off your Extensions one by one and by checking the AdminTool see which one is causing the anomalous activity.

Hope it helps.
Lapo
--
gotoAndPlay()
...addicted to flash games
hokmbaz
Posts: 2
Joined: 15 Aug 2017, 08:18

Re: Server locked after a few hour uptime

Postby hokmbaz » 20 Oct 2017, 17:28

Hi again and thanks for your quick reply,
as i said this problem occurs after a few hours, so tracking it is real hard and time consuming.
i removed all extensions and even installed a fresh copy of SFS with default configuration but the problem still happens.
i installed SFS on a vps server and after about one day nothing happened, so there is something in my machine causing this.
maybe android studio have something to do with this because it's running most of the time on my pc. my guess is maybe some services in android studio (like adb) have conflict with SFS ports and sending corrupting packets to it.
if it's true then it could be a security vulnerability, because one can make server hang by sending special packets to it.

but let's talk about another issue that draw my attention while i was monitoring SFS outging traffic. i observed every single call to SFS API functions (in server side) will be translated to separate tcp packets.
for example in room extension i call getApi().setRoomVariables(...) and on the next line of code i call getApi.setUserVariables(...). the api will generate packets for each call and put them in packet queue of receipent user sessions and finally the bitswarm engine will write packets to wire.
as i know each TCP packet can transfer 64 KB of data. each TCP packet contains extra headers (extra bandwidth usage) and indeed require extra handshaking packets from client side (which increase latency). is it efficient to send separate tcp packets for each tiny update while we can wrap them in a large packet and send them at once?

i examined your sokcet writer service source code and there you are sending packets one by one :
packet = sessionQ.peek();
this.tcpSend(writeBuffer, sessionQ, session, packet);

maybe TCP stack is responsible for this, but in my pc tcp stack is generating separate packets for each of your socket writes. should i do any configuration on my system?

thanks
User avatar
Lapo
Site Admin
Posts: 19732
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Server locked after a few hour uptime

Postby Lapo » 22 Oct 2017, 17:13

hokmbaz wrote:as i know each TCP packet can transfer 64 KB of data. each TCP packet contains extra headers (extra bandwidth usage) and indeed require extra handshaking packets from client side (which increase latency). is it efficient to send separate tcp packets for each tiny update while we can wrap them in a large packet and send them at once?

I am not sure what you're referring to when you mention a 64KB limit for TCP. You can send as much data as you want, the TCP will fragment it according to several variables which depend on the state of the network.

As regards small packets there is no problem in sending tiny messages, typically most TCP implementations have the Nagle's algorithm activated which aggregates small packets sent in a small interval of time, thus optimizing the transmission. (Sometimes you may not want that, but it's an entirely different discussion)

https://en.wikipedia.org/wiki/Nagle%27s_algorithm

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 12 guests