Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

MMO Server with Unity?

Discussion in 'Multiplayer' started by ronicec, Mar 10, 2023.

  1. ronicec

    ronicec

    Joined:
    Mar 10, 2023
    Posts:
    2
    Hello everybody,
    I believe this topic has already been discussed at some point here, however, I could not find something that takes into account my doubt.

    I've been designing an MMO model for a few years now, which for me would be "perfect", that said, I decided to start my prototype now and, analyzing the scenario, Unity seems to me to be much more "robust" in terms of development.

    I've been a developer for +10 years using PHP and Node, and recently I've been studying the C++ language even to apply it to Unity.

    Well I have some doubts..
    - Which database is recommended? (I particularly like Mysql and Postgresql but thinking of an MMO that may have many records to choose from)

    - For the server I develop everything using Unity? Or do I need to create a separate project to just get the server logic? How would this work?

    - I've seen some video classes on the internet and everyone I've seen uses Unity for the client + server, but I couldn't understand how the connections to the database are and so on.

    Anyway, I would like to ask for a suggestion for course indications or something related to these doubts that I pointed out, I want to go deeper and study this tool more to be able to get my project off the ground.

    I appreciate everyone's help in advance.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    2,079
    Any will do for now. You can always migrate later on.
    The thing is: if this is your only question regarding databases and your first MMO project, you just have to get it going. It simply doesn't matter which database you choose so pick the one you're comfortable with. It should be the least of your concern for now.

    Depends on the game!
    To get started, try out the "dedicated server" build platform for Unity so you don't have to deal with multiple projects and server/client share the same codebase. But if your game does not require the server to do more than update & verify positions/collisions against a tile-based world then the server could just be a console app.

    But that said, what are your MMOs basic features and requirements, and goals for the first release (date, server & user counts)? What is the price/business model?

    If you're happy with about 100 players in the same world at the same time on a single server that may be okay with any networking solution. Possibly check out Fish-Net since it supports LOD for networking. You can manage one or two servers (US + Europe) by yourself. Your biggest challenge will be attracting this many players in the first place. And to do so, you need LOTS and LOTS of content. Like maybe a year just designing the world when all the art and programming is done if you do it all by yourself.

    If you are thinking 1000+ players on a single server at the same time with multiple servers running around the world, let's say maybe just two for each major continent (North America, South America, Europe, Ocenia, Asia) then you're thinking way, way ahead. For that scope you need a team and serious funding in the millions.

    I mention this because frequently devs completely underestimate the scale of developing an MMO.
     
    friflo likes this.
  3. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    4,282
    The reason why you would use Unity for the client and the server is productivity.
    Sharing physics, assets, navigation and code saves you a lot of time.
    Several smaller MMOs have been made this way, and you can target about 200-300 CCU per Unity server instance. For example, Inferna, Samutale and Naica are MMOs which were made entirely in Unity (Mirror).


    Note that the lower your tick rate, the more CCU you can achieve.
    For example, if your server runs at 60 Hz, that gives you 16 ms to update the whole world.
    If your server runs at 10 Hz, that gives you 100 ms.
    With 6x more time to update, you can probably have 2-3x more CCU.

    This is how many early MMOs achieved 500+ CCU already 15 years ago.
    Many of them ran at 10 Hz or less.
    The downside is extra latency. But hey, 500 CCU :)

    Keep in mind that Unity is not a great choice for game servers if you care about robustness, stability, scale.
    C# standalone projects (outside of Unity) can run on netcore, which is significantly faster and more stable.

    Outside of Unity you also have more choices for programming languages which may be better suited for high scale / high performance servers.
    • Go is worth learning. A concurrent language developed by google for scalable systems. Much easier to do multithreading than with C#, due to go-routines. Also garbage collected, like C#.
    • Rust is great too. Bare metal C/C++ performance, but with memory safety. Multithreading is great too, because Rust protects you from data races (unlike Go and C#). Not garbage collected, so there won't be GC pauses to worry about.
    • C# is still great choice. However, some of the low level networking defaults aren't great. For example, there's an ongoing discussion about C# UDP socket allocations here. Allocations require garbage collection, which introduces GC pauses, which introduces performance issues in high scale servers.

    Worth noting that Unity is in the process of switching to netcore.
    That would be great for game servers!

    TL;DR:
    Unity is the slowest, most unstable solution for game servers.
    But it's also the most productive.

    Pick one :)
     
    Last edited: Mar 11, 2023
    friflo likes this.
  4. ronicec

    ronicec

    Joined:
    Mar 10, 2023
    Posts:
    2
    Thanks for your answers, do you have any example the Unity with databases? (something like mysql, postgree or others)

    Well, I would like this game to be magnific, hahaha, So, I wish that the thousands players online. (like Tibia, Runescape, WOW e etc).

    Thank you very much for your tips, they were very valuable.
    Thinking about that first moment, I believe that perhaps to create a "prototype" Unity would apparently give me much more speed, correct? Being that I can work with Server+Client together.
    I asked a previous question and I leave it here for you too, how can I work with the database (mysql and etc) to save data and recover in my game? I've been researching this term and I couldn't find anything that would help me with this process.. hahah


    Thanks again for all the responses.
     
  5. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    4,282
    You can use pretty much any database with Unity.
    For my MMO project I have an abstract Database class that can be used with SQLite, MySQL, etc.
    Just google for "C# MYSQL" samples.

    As for your other question.
    If you want large WoW/ EvE online scale MMOs, you can't use Unity as the server.
    Maybe it's best to settle for small MMO with 300-500 CCU per server instance.
    Maybe run every map in a different instance, so if a world has 4 maps, you can have 4 x 300-500 CCU.

    Imho better to make a small MMO, then never finishing a large MMO.
    It's extremely difficult as is.

    For what it's worth, both Unity, server hardware and netcode libraries are always improving.
    By the time you finish your MMO in 5 years...
    • Unity may have finished the netcore transition. If you are lucky, that may give you an extra +100 CCU
    • CPUs will certainly get faster. Maybe giving you another +50 CCU.
    • Netcode always improves. UNET supported ~30 CCU when we started Mirror. We've doubled CCU every year, to about 10x. We are hitting Unity's limits now, but another +100 CCU may be possible with hard work and patience.
    If you can do 300-500 CCU today, you can probably do 400-700 CCU in 5 years.
    That's pretty good if you ask me.
     
  6. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    291
    As the FishNet author scalability has been something I'm regularly asked about. CCU is largely based on the server specs so numbers are kind of irrelevant, the important part is choosing whichever solution scales the best.

    I'm always working on improving my product, but even now I am certain no other Unity based solution comes close to FishNet in terms of scalability. A recent release on our product deployed to tens of thousands of players in a single day.

    We are the only solution (at least free) that offers Network LOD which is essential to server cost and scalability. The tick rate can be adjusted at runtime as well; so if your servers get really busy you can lower their tick rate, reducing how much your servers work while trading more latency. We are also testing a new feature for release which we know as of now doubles scalability but we're aiming to quadruple current benchmarks by completion.

    So in short if you are looking for a Unity based networking solution I'm confident in recommending you my product.

    Others have said you may not want to use a Unity based solution for such a feat. I'm partial to this belief as initially I agreed but overtime I've became less confident with my initial decision. A Unity based solution will drastically speed up development time but of course won't scale as well as writing your own backend outside Unity. But, I feel it's a pretty common belief time is more important than micro-optimizations, so with that said, personally I'd utilize a Unity based framework. In addition, if your game is doing well enough to where you could have benefited from an outside framework you're already making a very large sum of money, certainly enough to just use a stronger server.

    Hope this helps you on your way.
     
    Last edited: Mar 15, 2023