Up to Main Index                          Up to Journal for February, 2021

                    JOURNAL FOR SUNDAY 21ST FEBRUARY, 2021
______________________________________________________________________________

SUBJECT: Chat server experiments
   DATE: Sun 21 Feb 19:34:10 GMT 2021

In my last journal entry I said I was going to work on a little chat server.
This was to experiment with some performance ideas related to how WolfMUD
handles networked clients. Using a simple chat server, instead of WolfMUD
itself, allows me to focus on just the relevant parts of the problem. I now
have a chat server and a botrunner implemented.

The results?

I have a chat server that can handle 1024 clients at once, each client is
broadcasting messages to all the other clients at the same time. 1024 clients
may not sound like a lot. However, when every client sends a message and it is
broadcast to every other client that is 1024x1024 or 1,048,576 messages.

Each client pumps out a message every 0.5-1 second, on average one message is
sent every 0.75 seconds. That equates to broadcasting roughly 786,432 messages
every second. Monitoring the chat server I’m actually seeing 800,000-900,000
messages a second. About 27Mb/second of data is transferred with messages
being 15-58 bytes long. Each client has a backlog channel of 1024 entries for
buffering messages.

Here is a sample run over 25 minutes on my quad core desktop:


  Accepting connections on: 172.16.1.1:4001
  c[   0] sΣ[   0.00Mb] ss[ 0.00Mb] ms[     0] bs[  0.00] dΣ[0] ds[0.00]
  c[ 332] sΣ[   0.95Mb] ss[ 0.95Mb] ms[ 32743] bs[160.90] dΣ[0] ds[0.00]
  c[ 721] sΣ[   9.17Mb] ss[ 8.22Mb] ms[264917] bs[482.49] dΣ[0] ds[0.00]
  c[ 941] sΣ[  29.09Mb] ss[19.92Mb] ms[627622] bs[725.25] dΣ[0] ds[0.00]
  c[ 997] sΣ[  54.17Mb] ss[25.36Mb] ms[790929] bs[808.13] dΣ[0] ds[0.00]
  c[1021] sΣ[  80.35Mb] ss[26.91Mb] ms[838302] bs[829.87] dΣ[0] ds[0.00]
  c[1024] sΣ[ 106.95Mb] ss[27.36Mb] ms[847631] bs[827.89] dΣ[0] ds[0.00]
  c[1024] sΣ[ 137.42Mb] ss[27.56Mb] ms[849322] bs[829.42] dΣ[0] ds[0.00]
  c[1024] sΣ[ 165.29Mb] ss[27.08Mb] ms[838259] bs[818.61] dΣ[0] ds[0.00]
  c[1024] sΣ[ 182.98Mb] ss[26.21Mb] ms[807509] bs[788.58] dΣ[0] ds[0.00]
        :                                                    :
        :                                                    :
  c[1024] sΣ[2942.08Mb] ss[25.72Mb] ms[801706] bs[782.92] dΣ[0] ds[0.00]
  c[1024] sΣ[3008.14Mb] ss[27.32Mb] ms[845761] bs[825.94] dΣ[0] ds[0.00]
  c[1024] sΣ[2992.43Mb] ss[26.68Mb] ms[830468] bs[811.00] dΣ[0] ds[0.00]
  c[1024] sΣ[3068.89Mb] ss[26.77Mb] ms[827562] bs[808.17] dΣ[0] ds[0.00]
  c[ 946] sΣ[3140.36Mb] ss[26.90Mb] ms[837161] bs[831.30] dΣ[0] ds[0.00]
  c[ 457] sΣ[3436.10Mb] ss[19.52Mb] ms[620443] bs[834.04] dΣ[0] ds[0.00]
  c[ 119] sΣ[3439.22Mb] ss[ 2.12Mb] ms[ 70013] bs[229.70] dΣ[0] ds[0.00]
  c[   5] sΣ[3439.31Mb] ss[ 0.07Mb] ms[  2594] bs[ 39.20] dΣ[0] ds[0.00]
  c[   0] sΣ[3439.29Mb] ss[ 0.00Mb] ms[     1] bs[  0.60] dΣ[0] ds[0.00]
  c[   0] sΣ[3439.28Mb] ss[ 0.00Mb] ms[     0] bs[  0.00] dΣ[0] ds[0.00]

  Report key:    c: Number of connected clients
                sΣ: Total message data sent in megabytes
                ms: Message data sent in megabytes per second
                bs: Number of message broadcasts made per second
                dΣ: total number of dropped messages
                ds: Number of dropped messages per second

  Note: The per second values are calculated over the previous 10 seconds


The server was using about 300% CPU and the botrunner 90% CPU. Currently I’ve
been focused on getting things working and not optimised the code.

Testing has mostly been local with my desktop running the chat server and
botrunner together. If I offload the botrunner to another machine, a Raspberry
Pi 4, and run the connections over ethernet I can get similar results.

Testing conditions are not optimal at the moment. The Raspberry Pi is running
fan-less due to the Pimoroni Fan SHIM failing. This caused some throttling of
the CPU when the Raspberry Pi hit 80-81°C. My ethernet is using an old Netgear
DS108 10/100 hub[1]. Luckily the Raspberry Pi 4 has a smart Ethernet socket
and I can just plug an ethernet cable between my desktop and the Raspberry Pi
and it detects it needs switching without using a cross-over cable, giving me
a gigabit link :)

I’m still testing, tweaking, optimising and benchmarking but I think the new
client code will suffice for WolfMUD ;) I just need to transplant the code
from the chat server to the WolfMUD server…

--
Diddymus

  [1] Most of my equipment is old, slow and second hand - I just haven’t been
      able to afford any upgrades. I’ve had the Netgear DS108 for 20 years. I
      plugged it in and never had a problem or touched it since.


  Up to Main Index                          Up to Journal for February, 2021