I scaled my MMO to 100 concurrent connections

Поділитися
Вставка
  • Опубліковано 7 лип 2023
  • ⁍ Play: mythfall.com
    ⁍ Discord: / discord
    ⁍ Patreon: / unitoftime
    ⁍ Github: github.com/sponsors/unitoftime
    ⁍ Twitter: / unitoftime
    // References
    ⁍ Cod Package: github.com/unitoftime/cod
    // Description
    This week I worked on scaling my game to 100 players. I ended up writing my own code generation package to generate my serialization code. The game is handwritten in Go.
  • Наука та технологія

КОМЕНТАРІ • 34

  • @djukicdev
    @djukicdev 11 місяців тому +7

    Your devlogs are awesome

    • @UnitOfTimeYT
      @UnitOfTimeYT  11 місяців тому

      Haha thanks! Glad you like them!

  • @hoxorious
    @hoxorious 11 місяців тому +7

    I really liked the graph comparison! 👌It really showed the improvements.

    • @UnitOfTimeYT
      @UnitOfTimeYT  11 місяців тому +2

      Thanks! Yeah I'm super glad I added some backend performance metrics. It's been incredibly helpful.

    • @LawZist
      @LawZist 8 місяців тому

      what tools did you use for the backend performances metrics? do you still work on your game?@@UnitOfTimeYT

    • @UnitOfTimeYT
      @UnitOfTimeYT  8 місяців тому

      Hey! I'm using Prometheus and Grafana for the backend metrics currently. Yeah the game is still a work in progress. You can play the constantly updating dev-server demo here: mythfall.com@@LawZist

    • @LawZist
      @LawZist 8 місяців тому

      thanks! btw, do you use Client-Side Prediction and Server reconciliation in your game?
      also, is there a source of knowledge that you recommend to learn about game dev backend design etc? thanks again@@UnitOfTimeYT

    • @UnitOfTimeYT
      @UnitOfTimeYT  8 місяців тому

      Hey @LawZist I just saw this. Yeah I do client-side prediction. My actual network tick rate is very very slow (right now its like 4 Hz, I'm thinking of increasing it though). But its viable because my game can be deterministically simulated on both the client and server. If I had a PVP game, then I wouldn't be able to get away with that kind of tick rate.
      These are the best articles I've found about game networking design: gafferongames.com/categories/game-networking/

  • @dandogamer
    @dandogamer 11 місяців тому +1

    This is really awesome, what encoder was you using before? I'm using gob atm for my game but fortunately it's a 1v1 kinda thing :)

    • @UnitOfTimeYT
      @UnitOfTimeYT  11 місяців тому +1

      Glad you liked it!
      I was using this one before: github.com/kelindar/binary
      My serialization journey looked kinda like this: JSON, Gob, Flatbuffers, binary, and now Cod.
      There's a good serialization comparison github repo here: github.com/alecthomas/go_serialization_benchmarks
      But don't get too caught up on picking the fastest possible serialization strategy if you don't need it for your game/app. Honestly Gob probably works in most cases just fine. Unfortunately in my case it didn't fit so well.

  • @garyadamos
    @garyadamos 8 місяців тому

    Woah Wtf you’re a genius

  • @wils-caru
    @wils-caru 10 місяців тому +1

    hey, what do you think about flatbuffers and protobuffers for the problem you mentioned on serialization?

    • @UnitOfTimeYT
      @UnitOfTimeYT  10 місяців тому +1

      Hey, Yeah I actually started with flatbuffers, but I found the generated code really hard to work with so I stopped using it. I've never really used protobufs so I'm not sure if that's any easier. Also, According to this: github.com/alecthomas/go_serialization_benchmarks - Flatbuffers is slower and encodes to larger bytestreams than a manual binary encoder (You can compare to the MUS encoder, which my code is very similar to).
      Also, my packets are really small, and I almost always need to decode all of the data anyways, so the partial decoding benefits of flatbuffers doesn't really help me much. The only other benefit those would have over mine is that *i think* they provide better backwards compatibility support. So right now, whenever I update the game server code I always push a client update as well. This guarantees that clients will have the latest serialization code. That said, the structs that get serialized don't change very frequently, so its not too big of a deal. Plus my game is browser based, so I have a lot of control over when people download new versions of the game (I can essentially force it).
      I'm not really trying to say flatbuffers/protobufs/or any other encoding strategy is bad. I use JSON for a lot of web requests that don't need as much performance, and I use Gob for some asset data files. It just so happens that the majority of my bandwidth is the high-frequency updates, so I figured I'd make that as fast as I can.
      Sorry for the long message!

    • @wils-caru
      @wils-caru 10 місяців тому

      @@UnitOfTimeYT Thanks for the detailed answer, I'll read the cod code and learn a little more about this serialization part, benchmarks always saving us.

    • @UnitOfTimeYT
      @UnitOfTimeYT  10 місяців тому

      @@wils-caru Sure. Feel free to take a look! The AST parsing and codegen portion is a bit hacked together. But it ultimately generates code which calls these encoding functions: github.com/unitoftime/cod/blob/master/backend/backend.go

  • @mqix3741
    @mqix3741 11 місяців тому +8

    More goroutines then monies in the bank

    • @UnitOfTimeYT
      @UnitOfTimeYT  11 місяців тому +2

      If I had a nickle for every goroutine I've used. I'd be the richest man on earth

  • @Ahelhot
    @Ahelhot 9 місяців тому

    Do you try/test protobuf?

    • @UnitOfTimeYT
      @UnitOfTimeYT  9 місяців тому

      I actually used flatbuffers for a while in this project before eventually moving to a reflection-based binary serializer. I wasn't a huge fan of flatbuffers, I found it way too complicated to work with, then the reflection serializer was just simply too slow and caused too many allocations. You can look here for a benchmark comparison of several serializers. github.com/alecthomas/go_serialization_benchmarks
      Mines probably most similar to a code generated version of the MUS serializer.

  • @baxiry.
    @baxiry. 11 місяців тому

    awesome

  • @MuhammadHosny0
    @MuhammadHosny0 5 місяців тому

    you might want to try a contabo VPS those come pretty cheap and extremely fast.

    • @UnitOfTimeYT
      @UnitOfTimeYT  5 місяців тому

      Yeah from what I've seen from benchmarks, Contabo is very good value. In the upper tiers, I think they are better value than the VPS provider I currently use (HostHatch). . So at some point I might shop around once I start purchasing more expensive servers. I'll definitely look at contabo again.

    • @MuhammadHosny0
      @MuhammadHosny0 5 місяців тому

      @@UnitOfTimeYT Contabo costs like $8 for 4 cores and 50GB NVMe
      Good luck with the development

  • @patix0331
    @patix0331 11 місяців тому

    Is full game open source or only some parts?

    • @UnitOfTimeYT
      @UnitOfTimeYT  11 місяців тому +3

      When I first started, I made the full game open source, But later decided to finish the game as a closed source project. I try and push anything that's not "game-specific" out to OSS though. You can see those on my main github page: github.com/unitoftime
      Your more than welcome to try/use my OSS libraries. If you have any questions/feedback, I'd be glad to try and answer!

  • @atatro-pe9ql
    @atatro-pe9ql 11 місяців тому

    nice i have no clue what your talkin ab but its a good video

    • @UnitOfTimeYT
      @UnitOfTimeYT  11 місяців тому

      Haha. Still, glad you enjoyed the video!

  • @whatthefunction9140
    @whatthefunction9140 11 місяців тому

    Try rack nerd vps

    • @UnitOfTimeYT
      @UnitOfTimeYT  11 місяців тому

      ooo I love VPS suggestions. Thanks! I'll check it out!

  • @jomy10-games
    @jomy10-games 10 місяців тому

    Still not over 9000

  • @carneirouece
    @carneirouece 11 місяців тому

    stop vocal fry

    • @UnitOfTimeYT
      @UnitOfTimeYT  11 місяців тому

      Haha I had no idea what that meant so I googled it, but yeah I definitely do that a lot. I'll keep working on it! Thanks for the feedback!