Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

MMO database/server setup

Discussion in 'Multiplayer' started by MikeHergaarden, Apr 5, 2008.

  1. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    I'm wondering about how to make a MMO game in unity.
    I've read, and I believe, that unity is perfect for MMO's, but how to organize the networking/database stuff is a bit unclear.

    I've working on a concept, and would love to hear if this is somewhat in the right direction of a proper setup. But of course; several different setups will probably do the job.

    Let's say you want to make game with several areas where players walk around, chat, quest and kill monsters.
    As an example, you could think of World of Warcraft, but leave away the seamless worlds, that will probably require another full thread and I'm actually not very interested in a seamless world.

    The setup I was thinking about:



    There is one login database, containing account details for logging in ;).
    There is one "game" database, containing all game details (levels, items, quests).

    There is 1 unity game server per location. If a player moves to another location it will be reconnected to a new unity game server.

    Note that the game servers(LOCATION-servers) and the databases could of course each have their own physical server, or be hosted on the same machine.

    I haven't added a login server here yet, because that could either be integrated in all game servers, or have its own specific program, that's not too hard to decide about.

    Now, it would be nice if this idea was do-able:
    Make 1 unity project for this complete game.
    Each location has it's own scene, and scripts of course check if the application is running as server, or as client.
    The clients get a build application with all scenes in it, and the game servers get a file with just the 1 scene they got to run, or actually probably also all scenes: As I believe it wouldn't matter performance wise, but it's lots easier to deploy.

    My questions:

    • 1 Does this setup sound alright ?
      2 How can I safely deploy the files for client&server ? (The problem is that if i code the server&client in the same file, users could possibly hack the file and run a server ?)
      3 How can I integrate MYSQL into unity ? (without using the WWW->php method ofcourse)
     
  2. JeroenVO

    JeroenVO

    Joined:
    Aug 10, 2007
    Posts:
    52
    The setup looks ok in my opinion, but there is a lot to consider.

    Firstly, I agree that aiming for a seamless world is not a necessity. In most cases the client will have all the levels locally, so loading times should not be too much of an issue (if designed well).

    One thing I would add in the setup would be a game server that handles the logins, but more importantly, gives the clients the ip's of the 'sub' servers, or what you call locations. Another one would be that I would give a direct connection from the client to the data server to retrieve persistent character data, just to make sure you don't push everything over the entire network. This might be a security issue (if so, correct me), but I think you're better of reducing the load over you location servers.

    A more important issue in constructing your MMO system however, is network traffic. Unity's networking system is great, and might be able to pull off an MMO, but not out of the box. As far as I can tell, Unity uses multicasting, which is not always a good thing when building MMO-like systems. There are solutions like making your own network system with .net, but this involves a lot of work and expertise. But if you can handle this or have a better way, go for it.

    To answer 2 and 3, it is always best to make client and server 'physically' seperate, for exactly the reason you mention, and I would simply use PHP or similar, not integrate mySQL. Maintainance looks easier that way.
     
  3. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    Thank you for your reply!

    I would indeed save all IP<->Locations information in a database,so that the login server, and all location-servers can easily point an user to the right server for its current location.

    And yea, having 1 specific login servers makes it all clearer.

    Hm I was thinking of having those location servers load the characters info from the database once when loading the character. After that theres no more need to access the database during the game session, as the game server can save everything.
    However, at the end of the session (and regularly) the game server will have to sync the database.

    I believe you absolutely can't have the clients access the database (you could sniff the packets for the connection info, and access the database).

    Hmm, will have to get more information about unity's built in networking performance.

    The setup I described is in fact "1 world". Runescape and WoW have 2000 and 5000 players per world. I would not be aiming to have such a location server carry more than 500 players, and if I'd really start to work on a project like this I'd should probably aim for even less.

    For what do you suggest php ? To get things from the database ? Sounds unnessesairy slow to me. I'd better integrate MYSQL in the server files isn't it ?

    But for the clients: Yes, if they need database information, either via PHP, or via a gameserver.
     
  4. JeroenVO

    JeroenVO

    Joined:
    Aug 10, 2007
    Posts:
    52
    You have a point. The reason I would do so anyway, was to divide the load over the network. By letting the game servers deal the data, you put all the data over the game server. By letting the client access the DB, the load goes from db server to client, without bothering the game server. But, yes, you have a good point about security...

    Well, in the setup I suggested it was ok to do so, but in your setup, it might indeed be slow.

    I think it is indeed best to let the game servers get the data from the DB, although I'm afraid of the amount of traffic this is going to generate ( or put differently, the amount of traffic I hadn't seen before :) In my line of thinking, that sort of data didn't go by any game server, or a dedicated one, leaving the game server to do the 'more important' stuff like syncing and so on. If you needed stats, you talk to the DB, not to the game server.

    Maybe I'm just too obsessed by network traffic :) It might be not such a big issue when dealing with game stats.
     
  5. crasyboy42

    crasyboy42

    Joined:
    Jun 29, 2010
    Posts:
    28
    leepo je bent uit nederland tog??
    kan je me helpen met de sql database ik snap er niks van (komt omdat ik 13 ben :p)
    en hoe kan ik er exp op opslaan??

    alvast bedankt voor je reactie ;)
     
  6. Deleted User

    Deleted User

    Guest

    Nice gravedig of a 2 year old topic :D