Batching

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

Moderators: Lapo, Bax

Mrm83
Posts: 22
Joined: 17 Dec 2017, 04:02

Batching

Postby Mrm83 » 11 Sep 2018, 16:37

Are OnMMOItemVariableUpdates events batched? or is it 1 network call per update?

ie:
1000 mmoitems and each have an itemvariable update from server within the same 100ms, will this translate into 1000 separate network calls or are they batched into 1 or a couple automatically by SFS?

If it is not batched and I want batching, does that mean I can't use OnMMOItemVariableUpdate and would have to create my own event?
User avatar
Lapo
Site Admin
Posts: 20390
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Batching

Postby Lapo » 12 Sep 2018, 07:46

Yes,
they're batched on every proximity list update. In other words all the changes happening in the player's AoI between two proximity updates are sent in one update.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Mrm83
Posts: 22
Joined: 17 Dec 2017, 04:02

Re: Batching

Postby Mrm83 » 12 Sep 2018, 15:16

I am only updating 2 ints per mmoitem update and it is causing 74 bytes per item.. 2 ints are only 8 bytes, so there are 66 bytes over head..

Updating 20 units's position for a player is causing roughly 3kb every second..

12 Sep 2018 | 15:12:50,502 | DEBUG | pool-1-thread-1 | v2.protocol.SFSProtocolCodec | | {OUT}: OnMMOItemVariablesUpdate
12 Sep 2018 | 15:12:50,502 | DEBUG | pool-1-thread-1 | protocol.binary.BinaryIoHandler | | Binary size: 74
12 00 03 00 01 70 12 00 03 00 01 72 04 00 00 00 .....p.....r....
00 00 01 76 11 00 02 11 00 04 08 00 01 78 02 02 ...v.........x..
04 00 00 00 3D 01 00 11 00 04 08 00 01 79 02 02 ....=........y..
04 00 00 00 2C 01 00 00 01 69 04 00 00 01 17 00 ....,....i......
01 61 03 03 EF 00 01 63 02 00 .a.....c..

ie:
List<IMMOItemVariable> vars = new ArrayList<IMMOItemVariable>();
vars.add(new MMOItemVariable("x", npc.GetX()));
vars.add(new MMOItemVariable("y", npc.GetY()));
Ext().getMMOApi().setMMOItemVariables(npc.GetMMOItem (), vars);
// 74 bytes

SFSObject params = new SFSObject();
params.putInt("x", npc.GetX());
params.putInt("y", npc.GetY());
SendPacket("pm", params, client);
// 58 bytes

MMOItemUpdates seems to be 30% heavier than a custom event.. Is it possible to tweak setMMOItemVariables locally so theres less overhead?
i would like to use mmoitem updates instead of using custom events if possible.
User avatar
Lapo
Site Admin
Posts: 20390
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Batching

Postby Lapo » 13 Sep 2018, 08:44

Hi,
this is the object dump of the binary MMOItemVariable update you posted:

Code: Select all

(sfs_object) p:
   (int) r: 0
   (sfs_array) v:
       (sfs_array)
          (utf_string) x
          (byte) 2
          (int) 61
          (bool) false
      
       (sfs_array)
          (utf_string) y
          (byte) 2
          (int) 44
          (bool) false
      
   
   (int) i: 279
   

(short) a: 1007
(byte) c: 0

As you can see there's only the strict necessary.
While I understand that every byte counts I can't see how a 74 bytes update is going to negatively affect the game compared to a 58 bytes update, provided the client has a reasonably decent connection. (by which I mean, even an old ISDN connection would suffice)

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
Mrm83
Posts: 22
Joined: 17 Dec 2017, 04:02

Re: Batching

Postby Mrm83 » 13 Sep 2018, 12:36

Unfortunately, theres a monetary cost to bandwidth.

Saving 30% is 30% less.. We don't have big budget to work with.
User avatar
Lapo
Site Admin
Posts: 20390
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Batching

Postby Lapo » 13 Sep 2018, 14:54

Seems like a rather distorted way to look at it :)
It's not that the client/server bandwidth is exclusively made of MMOItem updates, for starters, so the alleged 30% is not really going to have that impact on the overall network usage.

More importantly your previous example with the pure SFSObject, is not even correct. You didn't factor in the Room id, the item id and the hidden flag, which is an attribute of the ItemVariable. So the 30% figure is not even correct.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
Mrm83
Posts: 22
Joined: 17 Dec 2017, 04:02

Re: Batching

Postby Mrm83 » 13 Sep 2018, 21:23

I do not need any of that, x, y, and id are all i need for positional updates.

That is why I asked specifically if there is a way to tweak it so that the extra stuff can be omitted/discarded to save bandwidth.
Both versions of the code i posted works perfectly fine for me, the only difference is the bandwidth used and batching.

I would prefer to use mmoitem updates because like you said there is batching. I read in another post that custom events have no batching. And if there is no way to tweak it, my resort would be to create custom batching for events.

Yes you are correct client/server bandwidth is not mmoitem updates alone, but for my setup, probably 80% of the bandwidth would be from position updates.. Cost estimating at 2k users, thats 1600 bucks every month just for position bandwidth ($.1/gb) at max 2k ccu =(.

If not 30%, lets put it at 10%, which is still alot..10% off $1.6k is 160 bucks saved every month; one year would equate to 2k saving, enough to purchase SFS licenses =). So I would rather save 10% in bandwidth and buy additional SFS licenses. :lol:
User avatar
Lapo
Site Admin
Posts: 20390
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Batching

Postby Lapo » 14 Sep 2018, 08:11

Mrm83 wrote:I do not need any of that, x, y, and id are all i need for positional updates.

You also need Room id, otherwise you don't know where the Item belongs, so essentially you need all of that stuff :)
You might not need the "hidden" flag which is literally 1 extra byte.

That is why I asked specifically if there is a way to tweak it so that the extra stuff can be omitted/discarded to save bandwidth.
No you can't tweak the message, sorry. If you could you would break the client side API.

Code: Select all

I read in another post that custom events have no batching.  And if there is no way to tweak it, my resort would be to create custom batching for events.

Since they are custom you can do whatever you want with them.
You can send a packet with 1 event, 2 events, a 1000 events...

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 21 guests