
Overview of Running an Online Game for 3 Years - def-
https://hookrace.net/blog/ddnet-evolution-architecture-technology/
======
themartorana
€10/m/location is damn impressive. I've run servers for a turn-based
asynchronous and real-time casual game for the past three years. With ~700k
unique monthly players (about 200k/day) we do about 1500 request/s at peak and
pay thousands a month for our AWS stack. I'm not mad at it, I think we get
great utility for what we pay, but this is lean and mean for realz.

Kudos!

~~~
def-
Thanks! Interesting to hear about your experience as well. By requests per
seconds you mean packets? I was curious and with 330 players playing on DDNet
right now[1] we get ~7400 packets/s incoming, ~8300 packets/s outgoing.

[1] [https://ddnet.tw/status/](https://ddnet.tw/status/)

~~~
Cyph0n
My guess is that he's talking about HTTP requests.

~~~
themartorana
Yes, I am talking about HTTP requests. We're just exploring moving over to web
sockets, the original implementations were done before that was practical on
mobile networks.

------
lccarrasco
This was really great to read, in-depth and interesting, thanks a lot for
taking the time to write it. :)

------
adynatos
The author writes: "Reduce the number of syscalls by caching the value of
gettimeofday() until a new tick happens or network packet comes in" But I'm
pretty sure glibc on recent Linux handles gettimeofday in user-space, without
context switch (kernel maps the data to userspace). I guess caching the value
locally and updating it 1/sec or something would still help if there are
thousands of calls/sec, but not as much as if it was really a syscall.

~~~
def-
You're right. Unfortunately with virtual machines that doesn't always work.
You can enable it manually but that's more inefficient because the Kernel
can't use paravirtualization for clock then. I stumbled upon this a month ago:
[https://ddnet.tw/irclogs/2016-05-17.log](https://ddnet.tw/irclogs/2016-05-17.log)

    
    
        21:37 <@deen> A third of the sys calls of a DDNet server are recfrom and
                      sendto each
        21:37 <@deen> they always occur in large chunks, so ideal for
                      sendmmsg/recvmmsg
        21:38 <@deen> the last third are mostly strange time and gettimeofday
                      calls, I thought I got rid of most of them
        21:40 <@deen> server with 30 players causes 3000 syscalls a second
        22:00 <@deen> PACKET_MMAP is very cool, reading packets with 0 syscalls,
                      too bad it's not for regular applications (requires root,
                      doesn't work with normal udp socket):
                      https://www.kernel.org/doc/Documentation/networking/packet_mmap.txt
        22:04 <@deen> and then the glibc version matters a lot for syscalls. new
                      versions of glibc don't syscall at all for gettimeofday
        22:05 <@deen> (or something else is causing that, not sure yet)
        22:13 <@deen> Reading the glibc implementation, that's done by vDSO,
                      interesting: http://man7.org/linux/man-pages/man7/vdso.7.html
        22:32 <@deen> totally confused why some of our servers use vdso
                      gettimeofday, others not even though they have more recent
                      kernel and glibc
        22:41 <@deen> ok, probably depends on the underlying clock that the vps
                      uses. pvclock is used with kvm and doesn't support vdso. but
                      looks like there's some progress being made:
                      https://lkml.org/lkml/2015/12/9/914

------
eggy
Awesome and inspiring to me, great work!

I am now looking at LFE (Lisp Flavored Erlang) and ELM to create a very small
online game. It makes me want to maintain C/C++ chops.

It's sad Apple is so walled in that you need a VM to build for OS X, and iOS
doesn't even make the list. I have an iPad, but I use an Android phone for
that reason, and I only program mobile for Android. Apple is getting better at
supporting iOS devs of late though...

------
mentos
Hey great work!

Curious to hear what the client stack was? Did you use LibGDX by chance?

~~~
def-
Thanks! You can see the client here:
[https://github.com/ddnet/ddnet](https://github.com/ddnet/ddnet)

SDL2, OpenGL, FreeType, pnglite, zlib, curl, md5, wavpack, opus, json-parser

So pretty much low level, keeps the performance and flexibility high.

------
qwertyuiop924
I just re-downloaded (vanilla) teeworlds the other day. After playing a lot of
QW and Xonotic, it's nice to play something like HLDM or TeeWorlds that's a
bit more wacky and less competitive. There is no bunnyhopping in teeworlds.
Just cute fluffballs, hookshots, and heavy weaponry. Although, for whatever
reason, all of the players are in the EU, or SA, and I'm USEast, so the ping's
really high. One of many reasons I want to get a GPU that can handle UT4. Yes,
mine is really that bad.

------
ashitlerferad
What was the reason for the fork with Teeworlds?

~~~
def-
Teeworlds is a shooter. People wanted to race in Teeworlds, so a modification
was required. From there it developed into multiplayer racing and the last few
years of DDNet adding features.

------
urza
I would like to see this kind of post for slither.io

------
ObeyTheGuts
Maidsafe will eliminate all this server problems!

