2
\$\begingroup\$

I'm making a server for MMO in Unity, which implies that I'll have a big world, split into maps which will be on different servers (to distribute the workload), managed by one master server.

Now I can't decide weather I should use one executable per map and have few executables run on each server or have few maps on one executable, which will have it's own server.
Second solution also would allow me to redistribute the workload by moving maps from one server to other (which shouldn't take long to do since servers don't need to load models).

Btw servers need to be made in Unity for the physics simulation and collisions...

The networking part can easily be multithreaded simply by using many threads to process the requests and generate response.
But since Unity is single threaded adding more maps would slow down the physics engine (plus the same thread has to apply all actions of the players to the game), so the first solution helps here by using multiple executables. (Edit: Note: physics engine will take considerable amount of CPU time, even while the scene is empty)

Which solution should I chose?

EDIT: On the end I decided to use both: few executables on each server, with each executable being able to run multiple maps and being able to dynamically create dungeons when needed.

\$\endgroup\$
2
\$\begingroup\$

Without a doubt, an executable per map would be the best option because servers run collisions detection. Collision detection increases in complexity by O(N) so a single instance with 500 objects will be much slower than 5 instances with 100 objects each.

There is a small overhead for each individual executable instance but compared to physics and other server logic, this overhead is negligible.

\$\endgroup\$
  • \$\begingroup\$ I was going to put them together until I realized this problem. But having multiple maps on the single executable would remove the need to transfer the player every time he changes the map. Plus now I don't know how many and which maps to put on each server, since they aren't balanced in size and player numbers. \$\endgroup\$ – zoran404 May 24 '15 at 21:51
  • \$\begingroup\$ Yes, having multiple executables would be a pain because players would have join again each time but the alternative is to partition physics into multiple simulations in a single instance (which is an even bigger pain). For load balancing, you could do what Realm of the Mad God does and create new rooms only when needed. \$\endgroup\$ – JPtheK9 May 24 '15 at 21:57
  • 1
    \$\begingroup\$ Ah yeah, the one map per executable also disables me from creating dungeon rooms on executables. But I think I have a solution, I'll have a controller on each server that would launch new instances of map servers, which would also enable me to redistribute the existing servers if necessary. Problem solved \$\endgroup\$ – zoran404 May 24 '15 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.