Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
7
Question by Trekopep · Jun 20, 2016 at 04:15 PM · networkingmultiplayerserverdedicated-serverpeer-peer

Peer-to-Peer vs Client-Server vs Dedicated Server Networking

Hi there!

Being relatively new to the Unity networking scene, but having done a fair amount of research, I'm looking for a couple answers I haven't quite been able to find. My questions are likely opinion-based to some extent, but having the opinions of more experienced network developers would be helpful to people like me who are still trying to get a handle on this.

I'm developing a game with four players per room. Thus far, the popularity of the game and the play-time, bytes sent over the network, etc. are unknown. However, positions, rotations, and actions of the players, AI, and certain objects will need to be synched over the network. Taking a bit of a cue from this question, I would estimate the average message size to be around 150 bytes at 30 messages per second.

(Some other specifics: Using UNET on Unity 5.3.4f1)

Thus far, here's what I've gathered about Peer-to-Peer Client-Server vs Dedicated Server Multiplayer:

Peer-to-Peer

Players each share equal authority and networking tasks; no player is a "host". Generally used in simpler non-synchronous games.

Client-Server with Client as Host:

This is the way the standard Unity Networking system (UNet) operates, though it is also possible to run a Unity standalone player in headless mode on a dedicated server and use UNet.

Note: I confused this with Peer-to-Peer networking for a long time, which led to many cases of confusion.

  • No dedicated server required, so significantly cheaper

  • Able to play via LAN, without connection to internet

  • Harder to prevent hacking/cheating

  • Not HTML5 (WebGL) compatible, since a WebGL game cannot be a host

  • Must be more meticulous when testing, since host-client operates slightly differently from other clients (e.g. reduced latency for host)

Client-Server with Dedicated Server:

  • Expensive to maintain (depending largely on scale; in my specific example, based on Unity's cost estimate—which is based on expected number of users, average message size, and messages per second—anywhere from $50 - 500 per month)

  • Must be connected to internet

  • Easier to prevent hacking/cheating (since everything must go through the non-client dedicated server)

  • HTML5 (WebGL) compatible, since the host is the non-WebGL dedicated server (though certain other missing WebGL components, like microphone use, may make this a moot point for my specific game)

  • Testing is more equivalent for all players since all players interact with the server equally

Moving into more specifics with a dedicated server (unsure whether this warrants a separate question), what are options for running a dedicated server? This is the part where I'm a little more lost. From what I've gathered, some of the options include:

Unity Multiplayer (https://unity3d.com/services/multiplayer) : The standard to use with Unity is Client-Server with a player as the Server. While this is relatively new, I've gotten it to work, and it's relatively well-documented. The Unity Matchmaking Service (which is free) is likely the best way to go about finding players to play with. This can also be set up with a dedicated server (as mentioned above, by running a Unity standalone player in headless mode on a dedicated server and using UNet).

Amazon Web Services (https://aws.amazon.com/documentation/sdk-for-unity/) : Unsure of whether this is possible at all.

Photon Networking (PUN) (http://u3d.as/2ey) : Seems to be easiest, most expandable, and well-documented. Uses Client-Server model with dedicated server. The Photon Cloud can be used (free version includes 20 CCU), however, code cannot be executed on the server, so hacking a game using this wouldn't be too difficult. Photon can also be used with your own dedicated server that you could, like with Unity Multiplayer, have Unity playing on, which would prevent issues with hacking.

Which of these sounds most reasonable for the kind of game I'm developing? If a kind of networking is not ideal for my game, what kinds of games should it be used in? Are there other concepts and ideas I'm missing here? Any thoughts and ideas are welcome. Again, I realize this post does not necessarily have a clear "answer", but is more of a jumping-off point for learning more, and I'm hoping it will also be helpful for future viewers. Often some of the most helpful questions I have encountered have been closed for being non-specific.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SweatyChair · Dec 01, 2016 at 04:54 AM 0
Share

Also added host migration is not fully supported in UNet yet, which is a great disadvantages w/o a dedicated server.

1 Reply

· Add your reply
  • Sort: 
avatar image
8
Best Answer

Answer by Ziflin · Aug 07, 2016 at 01:29 PM

Your breakdown seems pretty accurate. I'm not clear what you mean by 'rooms' in the description of what you're attempting to do though.

The real question is how will cheaters affect your game? If players lose money in some way if someone cheats, then you will likely need to host the servers yourself and as you stated, that can get expensive quickly.

If your game is cooperative or you have other ways to deal with cheating, then player hosted client/server or peer-to-peer (all players connect to each other) should be fine. Unfortunately UNet does not seem to have any support for peer-to-peer as they seem to force a client/server model which is a shame because you can cut latency in half and distribute the upload bandwidth usage with a decent peer-to-peer setup.

You probably don't need to be sending entity updates at 30 updates/second if that's what you were stating. Interpolation should let you get away with 15-10/second depending on the object's movement. But if you have a low entity count then it shouldn't be an issue.

You might want to look into something like the NAT Traversal plugin to avoid completely (or partially) having to pay for the relay server - something you normally shouldn't need (or want because of added latency). It seems to mostly use RakNet to do the NAT Traversal. If you're using Steam, you should be able to use their services and avoid paying anything for matchmaking (or NAT Traversal). See also.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SweatyChair · Oct 12, 2016 at 10:47 AM 0
Share

NAT Traversal looks awesome but note that it doesn't support mobile yet.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

79 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

Custom dedicated server application 3 Answers

Would you recommend p2p or dedicated server for a turn-based strategy game? 1 Answer

Photon Server 1 Answer

What is the CCU of the default Unity Networking? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges