NetSys - Network Communication System

TobiasDev

Developer
Staff member
Developer

Nov 12, 2019
19
22
3
Germany
Hello NetherGames Community and welcome to another Devblog. As you might have seen in the Weekly Update Blog from June 15th, we have introduced a new System to our infrastructure to ensure the correct working of all components of the Network.

Today's subject is exactly this system, and I will explain to you how it works, what it does, and how it affects you as our players.

Base Idea:

NetSys stands for Networking System and is a basic data exchange system for all kinds of services to communicate with each other. Those can be
Discord Bots, Minecraft Servers, Minecraft Proxies, Websites, and anything that can be programmed. It is using the lowest possible way of
network communication, which is Sockets. You can imagine sockets like a chat between two people, one server and one client, exchanging information.
Most things on the Internet are based on Sockets. As for the choice of the programming language, I chose Java as I determined that this would be the easiest
to do in Java while not trading simplicity for performance. In Java, the High-Performance NETTY Framework can be used to easily create production-grade socket-based systems. NETTY is for example used by Twitter to speed up search results and as a huge part of their infrastructure, as Twitter wrote about here.
For reliability reasons and because of the high performance and flexibility, I chose to use the TCP Protocol for this project, which ensures no packet loss while providing
me with an easy-to-use stream I can use to read data from or write data to.

How it is working:

There is one NetSys-Server, which Clients can connect to. Clients will not be able to execute any actions until they passed a login sequence, which I cannot talk about,
as you might understand. Once a Client passes the login sequence, it can assign so-called Connection Tags to itself. Those Connection Tags can be used to identify groups of nodes, for example, all nodes from a specific region or all Discord Bots. Those Tags can be changed anytime, what makes them different from the Connection Name,
which can only be set once in the Login Sequence. Clients can then exchange information with other Clients using custom packets or update data in the NetSys Server itself.

Packets

All pieces of information in the NetSys Network are delivered in a Packet-Like structure, similar to the one Minecraft uses. A packet is a set of Information that
serves a specific purpose. Each Packet has it's own packet ID, which all connected nodes, following the same standards, use to identify it. As we are receiving
the data in a byte-format, this would look something like this:
[PacketId] <PacketData> [PacketId] <PacketData>
There are multiple Packet IDs as multiple packets can be received at once. The following example can be given to explain a bit better how it's working:
[11] <Password> <Name> [12] <EU>
11 would be the Packet ID of the Login packet, followed by the data of the password and the connection name.
12 would identify the packet as a packet to add tags to the connection, followed by the tag it wants to have added.
Those are examples, they are not like that in our implementation

Problems on the way

During the development of this software, we had multiple issues that needed to be solved. As you might have noticed during the last two weeks we restarted the server around 11 pm ECST a lot of times. This was a result of us finding and fixing bugs in the NetSys PHP Implementation. Yesterday night, we successfully pushed a fix which is working fine until now ( 25.7. ), and we continue to monitor for bugs and other unexpected behavior. The PHP implementation might have been the biggest issue in the development of NetSys, as is requires a lot of manual work to get a multithreaded socket connection working in PHP.

What can this be used to?

You can use this for everything. As Sockets are one of the absolute basics every computer has, this system can be easily implemented in any
programming language. The main purpose is to exchange data. Your data is transferred from one server to another in milliseconds? easy. Sending someone else a message
via /msg with literally no visible delay, no matter what server or region the target player is on? easy as well.

Performance

After this project was finished, we implemented mechanics to monitor its performance. Performance is a critical aspect of developing such Infrastructure-critical applications.
Our performance test results have been extremely positive. We are experiencing around 1% of CPU Usage (#1) and a Memory Usage of less than 1GB under the full load of the Production Network. Each minute, on average 1 thousand data packets are being received by NetSys and about 500 sent while having 50+ Clients connected to the Network(#2). This performance could have only been achieved through the Netty Framework, which is taking advantage of threading to handle the socket connections and all the In/Outbound throughput. You can read more about Threading in Shaheryars Devblog. Thanks to the use of sockets, the delay between sending and receiving data is really short.

How are players noticing the change?

A good example of this would be the friend list. Sometimes it showed the wrong amount of online friends, or even completely showed wrong online players, leaving some out
that are online. Using NetSys, this is fixed. Another issue that was fixed by NetSys was the random disbanding of parties when joining a server. That was caused because the server you have previously been on sends your session data to the target server. Sometimes it happens that your data is taking longer to arrive than
the transfer. In that case, the server will send you back to a lobby (fallback server) and load new session data. As Session Data is now exchanged much faster through NetSys, this issue is fixed as well.
Thanks to NetSys, it's also possible to reply to players that are not even on the same Game Server as you using /r now.
We are planning to integrate this system at more and more places, as it serves us well until now, and we are thrilled to see the improvements we can achieve through it.




Developers who have been working on NetSys: Tobias G, Dries C, mat345st

Statistics for people who are interested:
4.000+ Lines of Code
~100 Files
135 Comments
1 Month of Development

Images/Sources:
#1 CPU Usage
1595679562031.png

#2 In/Outbound Packets
1595679622429.png
 

HippoBaguette

Member

Apr 7, 2020
116
21
18
Cool!

I have two questions:

1. So you wrote the Netsys in java? i thought nethergames used php

2. Was it this that causes the guild not showing the online player bug?
 

TobiasDev

Developer
Staff member
Developer

Nov 12, 2019
19
22
3
Germany
1. NetSys is a standalone program that uses Sockets to interact with other programs. Therefore I could write it in any language I'd want to.
2. Yes, it was probably the same issue the Friend List had. It should be fixed by now.
 

Huy Enter

Trainee
Staff member
Trainee

Mar 9, 2020
45
11
8
17
VietNam
Wow. This blog may have explained a lot of issues we have when we playing on NetherGames. Like you can't join server although it still online, Friends list bugs, ... And it explained how Player Profile Protection, No chat delay on messages. Also it had shown that server performance was extremely positive. That make me so impressed. I hope all Developer will more and more developed in the future. :mc_137-0: <3 <3 <3:D
 

May 26, 2020
32
3
8
I liked that explanation a lot, nice job Tobias explaining and gj to the dev team :D
 

Chapl

New Member
Aug 5, 2020
1
1
1
That sounds great! Good job Tobias! What I'm asking myself is why you, as a developer "committee" at NetherGames did not consider using something like RabbitMQ? Everything you described in the post, from categorizing/tagging services to sending packets with data, is taken care of by RabbitMQ. It does a phenomenal job at queuing, distributing messages (packets), fan-out messaging, all that in a first-in-first-out manner, has a lot of fault tolerance (a perk that comes with writing software in Erlang) and it's performant too! Rest assured that RabbitMQ can handle a million "interactions" a second.
 

  • Like
Reactions: HippoBaguette

TobiasDev

Developer
Staff member
Developer

Nov 12, 2019
19
22
3
Germany
We are not only using NetSys for communication, NetSys has several services embedded into it, which we don't wanna run as separated services over f.e. RabbitMQ, although RabbitMQ is nice aswell.
 

  • Like
Reactions: HippoBaguette

Support Us

NetherGames is a community-based Minecraft server network that operates a large amount of in-game servers and online websites for our users. The majority of our staff members are dedicated volunteers who put their valuable time and effort into the server everyday for free. We rely on displaying advertisements, donations and earnings from purchases to keep our services running.

If you want to keep driving & supporting our team and the network forward, please buy a rank or donate now.

Advertisement

Join our Discord Server

Like us on Facebook

AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock    No Thanks