Issues with Flood Filter on SetUserVariables

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

Moderators: Lapo, Bax

User avatar
Aet
Posts: 34
Joined: 15 Aug 2019, 23:10

Issues with Flood Filter on SetUserVariables

Postby Aet » 18 Aug 2021, 21:17

Hi,
We had some issues trying to setup the flood filter, so I've done some testing and seem to have some issues with getting the flood filter working properly.

I've attached a picture of our flood filter settings for testing, where I've set a limit of 12 per second for public messages and 12 per second for SetUserVariables. The filter seems to work properly for public messages (though I haven't tested significantly).

I am using the stress test code here: https://smartfoxserver.com/blog/buildin ... test-tool/ , but changing the public message send to the following:

Code: Select all

double randomAction = rand.nextDouble();
userVars.clear();
userVars.add(new SFSUserVariable("x", randomAction));
                     
pubMessageCount++;
sfs.send(new SetUserVariablesRequest(userVars));


to test the same code with user variables. I've attached this code below and settings used but it should be effectively the same as your stress testing code.

Despite the 12 message per second limit of the filter, any setting for sending messages more frequently than 1 user variable set every 999 milliseconds seems to cause the following exception:

Code: Select all

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: com.smartfoxserver.v2.exceptions.SFSRuntimeException
Message: Flooding error
Description: Runtime error while processing request
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.controllers.BaseControllerCommand.checkRequestPermissions(BaseControllerCommand.java:166)
com.smartfoxserver.v2.controllers.BaseControllerCommand.checkRequestPermissions(BaseControllerCommand.java:197)
com.smartfoxserver.v2.controllers.system.SetUserVariables.execute(SetUserVariables.java:41)
com.smartfoxserver.v2.controllers.v290.SystemReqController.processRequest(SystemReqController.java:172)
com.smartfoxserver.v2.controllers.v290.SystemReqController.enqueueRequest(SystemReqController.java:127)
com.smartfoxserver.bitswarm.io.protocols.AbstractProtocolCodec.dispatchRequestToController(AbstractProtocolCodec.java:39)
com.smartfoxserver.v2.protocol.SFSProtocolCodec.dispatchRequest(SFSProtocolCodec.java:133)
com.smartfoxserver.v2.protocol.SFSProtocolCodec.onPacketRead(SFSProtocolCodec.java:90)
com.smartfoxserver.v2.protocol.binary.BinaryIoHandler$1.run(BinaryIoHandler.java:477)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


It seems almost always reproducible at 998 milliseconds and always reproducible at 997. But obviously these rates are far below 12 messages per second (83 milliseconds) for expected flood filter issues.

Am I missing something obvious here or is there some other behavior with using the flood filter on user variable updates? For these tests I am running a default 2.17.0 SFS server with no extension selected, let me know if you need any more info.
Attachments
FloodFilterStressTest.zip
(4.3 KiB) Downloaded 306 times
FloodFilterSettings.PNG
(36.23 KiB) Not downloaded yet
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issues with Flood Filter on SetUserVariables

Postby Lapo » 19 Aug 2021, 08:10

Hi,
the behavior of the filter is unlikely to be perfect when you're testing at millisecond speeds. What I mean is that while it's true that 1000/12 = 83.3ms, you cannot expect packets to be ticking exactly at that pace.

What usually happens when you send packets quickly is that they get grouped together and sent in one go (see TCP's Nagle algorithm) so the frequency of reception (server side) is not going to mirror that of the client.

This also depends on the size of the packet sent, and that might exaplain why you see a difference in behavior between public messages and user variables. From the server side the mechanism that handles/filters these messages is exactly the same.

Hope it's clear.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
Aet
Posts: 34
Joined: 15 Aug 2019, 23:10

Re: Issues with Flood Filter on SetUserVariables

Postby Aet » 19 Aug 2021, 16:53

That is clear, but I still find it surprising for the rates I am sending. I wouldn't mind so much if it is tripping the flood filter at 1 message per 200 millisecond rate with that limitation, but I am sending messages at a rate of 1 per second, and it is getting tripped for 12 times that frequency?

Grouping messages may account for some of that but its not like the client has to wait anywhere close to 12 seconds to receive updates so it shouldn't group up more than I few I would expect, my understanding of Nagle's is that the delay is around a half a second to a second max.

We would like to set the flood filter for our actual clients but we might expect at most maybe 6 messages per second, and with these results I might be worried even putting a 72 message per second limit about kicking actual clients.
User avatar
Aet
Posts: 34
Joined: 15 Aug 2019, 23:10

Re: Issues with Flood Filter on SetUserVariables

Postby Aet » 19 Aug 2021, 18:49

Also I found some more extreme results in testing as well.

Server flood filter set to 120 messages per second limit.
Test client set to send 1 message every 950 ms.
Flood filter exception occurred in just under 2 minutes, about the time the client would of hit a total messages sent of 120!

Also all these tests are with:
<tcpNoDelay>true</tcpNoDelay>
So Nagle's Algorithm shouldn't be affecting it. (I can replicate the results with this set to false as well).
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issues with Flood Filter on SetUserVariables

Postby Lapo » 20 Aug 2021, 07:55

Thanks, we'll try to reproduce these scenarios and let you know.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Aet
Posts: 34
Joined: 15 Aug 2019, 23:10

Re: Issues with Flood Filter on SetUserVariables

Postby Aet » 20 Aug 2021, 20:10

Thanks! Let me know if you find anything, this would really help us in our use of SFS, we can't replicate it as easily but this was affecting our actual game client as well, so it isn't simply in isolation to this test case.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issues with Flood Filter on SetUserVariables

Postby Lapo » 23 Aug 2021, 15:38

Hi, we have reproduced the issue and fixed it.
Thanks for reporting. We'll be releasing an update soon.

If you want to test it earlier (and confirm that it solves your test case as well) get in touch with us by sending an email to our support@... email box with a reference to this discussion.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Aet
Posts: 34
Joined: 15 Aug 2019, 23:10

Re: Issues with Flood Filter on SetUserVariables

Postby Aet » 24 Aug 2021, 00:16

Awesome news!

I think we can wait for the official patch, let me know when that releases or the patch number so we can watch for that!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Issues with Flood Filter on SetUserVariables

Postby Lapo » 24 Aug 2021, 07:27

It will be patch 2.17.3

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 73 guests