Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Discussion 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:
    5,108
    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.
     
    ZhavShaw and friflo like this.
  3. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,340
    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
    akuno and friflo like 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. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,340
    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:
    383
    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
  7. hellangel28

    hellangel28

    Joined:
    Dec 28, 2016
    Posts:
    1
    you say you are the only solution that offers network LOD, but your website says network LOD is a pro feature, and the pro version costs a patreon/github subscription, doesnt it?
     
  8. bugfinders

    bugfinders

    Joined:
    Jul 5, 2018
    Posts:
    1,434
    i think there are a number unity based mmo games who would beg to differ.

    but to address the OP:
    However. Like everyone says. In general you wont have 20k players day 1 if this is your first. There is a big mountain ahead to climb and possibly a lot to learn. Get some basic action going so a client and server and even just one small area to run about in and start working on all the aspects you require such as maybe combat, inventory, questing, spawning, player communication, attributes, abilities, factions, handling multiplayer issues like 2 people looting or trying to buy from merchants, groups, death, some GM type tools and dev tools to help you build some of the above. You will grow as your project does and some bits will get scrapped and redone. The better code you make the less you will throw. Such as someone said about the database choice, pick one you know. You can change it later but with the right code it maybe there's enough compatibility between the one you pick now and a future one (note mysql is not free for commercial use it was originally and maybe the changed it again but wasnt last time i looked) that the only bits you need to change are which db library and connection details. After all the client never directly talks to the db only your server.
     
  9. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    383
    The Network Level of Detail is a Pro feature, yes. At the time of my previous post it was free; we were unsure if it would remain free at the time, but we decided to give it specifically to Pro users as thanks.
    Pro is very affordable though; it's a one-time buy in of $10 and $1/mo(stop/start anytime) for updates. We also offer automatic over-time lifetime licenses

    However, our area of interest, or as we call it observer system, is included free and is very powerful in controlling bandwidth and performance as well. Both systems can work independently or together.

    And to add some sprinkles on top, another free product for FishNet is 'FishMMO', developed by jimdroberts.
    FishMMO has been around nearly as long as FishNet and still regularly gets updates. FishMMO utilizes both the observer system and network level of detail, and will use whichever you have access to.
    Link: https://github.com/jimdroberts/FishMMO/

    I suppose my point is, do not let the Pro limitation on Network LOD deter you. Because be it free or pro with FishNet you still get A LOT MORE than any other framework offers.
     
    Last edited: Oct 15, 2023
  10. qbvbsite

    qbvbsite

    Joined:
    Feb 19, 2013
    Posts:
    83
    I'm I correct to assume that FishNet uses Unity for Both Client/Server?

    To answer the OP question, I personally would code the server portion separately without using Unity. This gives you the best performance/control but does have one major drawback that you have to run your own physics on the server. If your project is 3D this is quite the feat and not for the faint at heart, it's much easier to do if it's 2D. For my project I went the 2D route and was able to get something up and running in pretty sort order. You can check out my blog if you are interested, been working on it off and on for a few years as a hobby (Creating an Isometric 2D RPG/MMO (Ongoing Series) - Unity Forum).