P2P or Dedicated Servers? What's the best for your unity game?

game.courses/mp/ - Multiplayer Mastery Course
Answering a question from this weeks student call about peer to peer vs dedicated server game setups. Which type should you use for your unity game and why? There's actually an answer for everyone, depending on your game type, so watch and let me know what you think :)

Пікірлер: 34

  • @EpicTyphlosionTV
    @EpicTyphlosionTV7 ай бұрын

    Peer to peer benefits from not needing any server upkeep, which also means you can play the game online far into the future. Only issues are connection and security.

  • @captainnoyaux

    @captainnoyaux

    7 ай бұрын

    Yup, I went for p2p for a start and if there are too much problems (the hosts quits too much or w/e) I'll use a dedicated server, but implemented like it's already a dedicated server in case I have to migrate

  • @MaZyYTube

    @MaZyYTube

    7 ай бұрын

    @@captainnoyaux I think the word or definition p2p is used wrong here. If you mean a player can start a server in the and and clients connect to it (and cannot host in that time).. this is client server model. This is not p2p. And still if host leaves its a problem. Some network systems offers solution for this. But I like to offer both option. Like Source games. They have the option to use dedicated server or just quick start a server from the main menu. Nice to make quick session with a friend if it is small fun game ( for instance garrysmod ).

  • @captainnoyaux

    @captainnoyaux

    7 ай бұрын

    ​@@MaZyYTubeyup it's unity's definition of P2P

  • @smarttarded

    @smarttarded

    7 ай бұрын

    If your game is competitive based, meaning you need tight control over the server to prevent cheaters and exploits, then a dedicated server is a must

  • @SuperParadine

    @SuperParadine

    6 ай бұрын

    I think if the player becomes a server, but it does not change the gameplay for him, then its still p2p. I never heard about game with p2p where each player sends data to each other player.

  • @princetruth28
    @princetruth287 ай бұрын

    I was just this week starting to learn about this and wanting to have online for my turn based games.. yiu couldn't have chosen a better topicman, great thanks!

  • @roflcopterpilot
    @roflcopterpilot7 ай бұрын

    Would love to see a breakdown of CCU calculations and how to go about cost calculations, maybe use a common platform such as Photon as an example? Outside of the scope of coding but it seems to be a factor that scares many developers.

  • @fmproductions913
    @fmproductions9137 ай бұрын

    For games where there is no competitive aspect and when there are mostly just 2 players in a session, P2P seems like a nice and simpler solution for sure. Epic and Steam offer those relay services for a p2p like network structure too, so you don't have to worry about connecting the peers on your own (which can be be a real hassle, can expose insecurities when peers setup to support directly connecting to others and a lot of times, you end up needing a separate server to relay packages between the peers or to connect them together either way).

  • @MiguelJCintron
    @MiguelJCintron7 ай бұрын

    You also should factor in that simply debugging peer to peer can be much harder so finding and fixing P2P issues can take much more time.

  • @goog983
    @goog983Ай бұрын

    any reccomendations for adding peer to peer into my games? like where i should look

  • @tetryds
    @tetryds7 ай бұрын

    I would like to add that maintenance is the biggest cost of dedicated servers, since hosting is not prohibitively expensive anymore. Most indie games can get away with lowest tier hosting.

  • @alec_almartson
    @alec_almartson7 ай бұрын

    I would say: "It depends on the game".

  • @JonathanbmillerZIG
    @JonathanbmillerZIG7 ай бұрын

    I'm curious of any security risks to the players peer-to-peer networking can open up and how to prevent them. I can't think of any, but the thought of someone directly connecting to another computer does make me wonder if there are any concerns I should prepare for.

  • @captainnoyaux

    @captainnoyaux

    7 ай бұрын

    Of course there are, ddos is one. Probably non existant except if your game is a HIT

  • @alienJIZ1990
    @alienJIZ19902 ай бұрын

    Best way imo is a public server as a p2p client session broker. If it's competitive or hacking becomes a problem, train LLMs to analyze matches and memory states to look for anomalies, use UBA to auto flag suspicious users, efficiently collect telemetry on first launch for more reliable banning purposes (cpu/disk/mobo serial, public IP, MAC Address, etc.), and also anti-cheat post-gameplay telemetry to feed the LLM, with ML jobs to account for intentional disconnects vs latency But most ideally, we need decentralized P2P gaming. The gaming community in general is large enough at this point that to avoid putting server costs on small teams/devs, everyone can just spin up (i.e.) a Raspberry Pi node and share the burden. Decentralized, open source governance, anti-cheat rules, scalable, etc.

  • @paddyh4272
    @paddyh42724 ай бұрын

    So a “versus fighting” game will always be run on p2p architecture, is that right?

  • @Unity3dCollege

    @Unity3dCollege

    4 ай бұрын

    Typically, but with some special considerations. There are some good common solutions for fighting game networking, lots of good gdc talks on it too. Local mp is definitely the best though for it. Apparently parsec is pretty popular for fighting games too (not netcode but a great free tool)

  • @young-salt
    @young-salt22 күн бұрын

    I dont like dedicated servers only. I think peer to peer is best for quickplay with the ability for players to create and host their own servers and those servers being listed in a server browser in-game. I think this would be the best process for bringing a battlefield type of game to the linux and foss crowd. Foss crowd doesnt really like dedicated servers and i dont have the cash or infrastructure to have dedicated servers for more than 10-20 people. I think having a votekick option and giving server owners the ability to permanently ban players is the best way to combat cheaters, abk cant even make an effective anticheat so theres no way i can make one, best to keep that tool in the hands of the players

  • @TarrenHassman
    @TarrenHassman7 ай бұрын

    And folks, when he says getting p2p clients to agree on stuff is possible but it’s complicated. He means graduate level distributed systems level difficult, it’s the same fundamental problem cryptocurrency networks are trying to solve.

  • @Unity3dCollege

    @Unity3dCollege

    7 ай бұрын

    Some games it's a bit easier, but I think it's mostly 1v1 games that I can think of at least

  • @TarrenHassman

    @TarrenHassman

    7 ай бұрын

    @@Unity3dCollege yep. Turn based can also make it a lot easier because the delay is inconsequential.

  • @TheAlienpope
    @TheAlienpope7 ай бұрын

    I might be missing something. but unity's own peer to peer system unity relay, is not free. I haven't looked into the pricing too deeply and done any calculations. But it seems you still have upkeep costs even with peer to peer. Or again, am i missing something?

  • @Unity3dCollege

    @Unity3dCollege

    7 ай бұрын

    Relay costs are a lot cheaper. Last I checked, steam also offered it for free for games hosted on there.

  • @TheAlienpope

    @TheAlienpope

    7 ай бұрын

    @@Unity3dCollege Oh yeah! I forgot steam offered this as well.

  • @rexoverwatch
    @rexoverwatch4 ай бұрын

    yeeeee

  • @bentv839
    @bentv8397 ай бұрын

    What about room based multiplayer games like LOL or Valorant? Most of services like Photon you have to create P2P connection for create room and let one of player rule it. So how we can connect that rooms with dedicated server for prevent cheating?

  • @MaZyYTube

    @MaZyYTube

    7 ай бұрын

    He sadly was not explaining p2p correctly. P2P actually means everybody is host and client at same time. Photon is not like that. You still connect to server and you receive the information from the server not from players directly. Photon has authority system and the server is just a cloud server. This means actually Photon is like AWS (amazon hosting service). But the main difference is you cannot do something on the serverside. Because of this some people try to use the masterclient ( the one who created the room ) to validate things.. but yea masterclient could cheat. I had to once write for customer custom authority system.. it was pain. While games like Lol, Dota are 100% cloud dedicated server but these games are using Matchmaking System. So they know what server are free which one they can use. Its really easy to write your own if you understand how this works. Start with basic and simplied version just to learn it. 1. Write a simple server in unity using mirror, netcode what ever. You don't even need to join. Everytime a server starts let it write(or update) to a "json" file just in any folder you want. Write into the file the player number and the ip + port. 2. Run 2 server with different port. 3. Write now the client part. Just a button "Auto join" and the logic to receive the json file and read the information. Now you already have information about 2 server. Now you can create your own logic.. do you want prio empty server or join a server with players? Of course with players hehe. Connect to the ip you received from json. 4. Voila, you are done and you wrote your first own (even if it is just json file) Matchmaking server. You even can use this information to make a server list. Don't use json for real games. Just for learning.

  • @bentv839

    @bentv839

    7 ай бұрын

    Thanks for your detailed reply. Very helpful @@MaZyYTube

  • @TheRealFlap

    @TheRealFlap

    4 ай бұрын

    @@MaZyYTube I don't think JSON is inherently bad, right? Here's my idea to implement your idea. Utilize something like Firebase's Firestore (NoSQL JSON Database) or Supabase (PostgreSQL Relational Database) which has a table for currently active lobbies which is updated and queried as people "Host Game" and create lobbies. Querying that database even in SQL can be serialized into a simple Object for easy data access. If using Firestore, it's literally just a JSON file that's returned which you can iterate through like you stated.