I'm not great at networking concepts, but my basic understanding is that computer networking relies on constructs like IP addresses and port numbers to direct data packets to the correct device and application.
So, if I'm playing an online game like Minecraft or Counter-Strike, I am able to connect to the dedicated game server using the server's IP address (which might be associated with a physical device, or a virtual device like a VM or a OCI container) and port number (which is like a communication "channel", associated with a particular piece of software).
And, as such, you can host multiple game server instances for the same game on different IPs or ports, as long as each server has some way to be individually addressed.
But I start to get a bit confused when I think about the packet's return trip and how the server communicates back to the clients...
In some cases, each client will be connecting from their own network modem, with their own IP address assigned to them dynamically or statically by their ISP. In that case, I would imagine that the server could just keep a list of client connections and route relevant data back to each client.
But in other cases, you might have a multiple clients playing a game behind one modem (like housemates or a LAN party where multiple players join the same remote/internet server), or a newer problem, multiple different networks sharing an IP address due to CG-NAT at the ISP level. In which case, from the perspective of the server, multiple players would be playing from the same IP address and communicating over the same port, right?
So how does the server differentiate between >2 players connecting from the same IP address and communicating over the same port?
Or does it not even try, and instead just broadcast all of the relevant game data to every client?
And if that's the case, how do huge games like battle royales or MMOs handle sending game state to a large number of users?
In some cases, the game server's IP address is actually anycasted, which is an approach that (very carefully) breaks the notion that a network identity belongs to a single machine. Instead, that one IP address would actually be routed to a nearby machine which is authorized to assume the identity of the game server, and will thus handle the game traffic for that region. So long as all regions handle their traffic identically and the results are consistent as if there were one giant machine that were handling all the traffic, this can work. An example where the seams are visible are how YouTube's view counters will momentarily not match up across all geographies, because the backend servers don't sync up to each other instantly or even quickly; and few people require that precision anyway, so they just don't bother engineering it to do that. When you're providing a global service, that is exactly the sort of engineering tradeoff that must be considered, because even they do not have unlimited money.
In other situations, the game server IP address really is for a single machine, but that machine is a specialized hardware load-balancer that is situated in a cloud provider's network. All that this machine does is to be the frontend for the 5-tuple, and will create a new conversation/connection 5-tuple with a cluster of game servers within the cloud provider's network. There might be some superficial comparisons between a load-balancer and NAT, but the latter works by fraudulence whereas a load-balancer is a subcontractor.