r/programming • u/dechichi • Oct 25 '26
Just finished my multiplayer system in C and turns out we can support 50k players in a single server at 60hz simulation tick
https://youtu.be/imG2Tt_KOj4
995
Upvotes
987
u/pokeybill Oct 25 '26
This is how it starts, but all estimates from simulating at this scale are out the door with that server sizing and entity behavior. The simulation lacks meaningful player/entity interactions and the amount of game state to track and share will grow exponentially. 10k becomes a questionable target very quickly.
176
u/dechichi Oct 25 '26
I've been writing this engine in C since 2024, yes, before AI.
The netcode architecture is ECS based, inspired by this 2017 GDC talk. The server is authoritative, and replicated state is just regular ECS components tagged for the network, with each field quantized (e.g. position at 1 mm). Codegen writes the serializers. Clients send inputs (each packet repeats the last 4 ticks so a lost packet costs nothing), each client predicts its own character and rolls back and re-simulates on corrections, and everyone else is interpolated. The transport layer is QUIC over UDP, but we'll support swapping out for different layers.
Every client receives every player, in three tiers of relevancy:
The mid and far tiers are encoded once per map tile and shared by every client, so that cost doesn't grow with the number of viewers. The whole server, simulation and networking, runs across all 88 cores.
A couple of stats:
Scaling is linear up to 40k players on this machine (+0.36 ms of server frame time per 1,000 players). At 50k we saturate the machine and the graph stops being linear (needs a beefier server). Simulation is still 60 Hz, the server just runs two ticks per frame, so updates to players drop from 30/s to ~16/s.
Of course not much happening on this demo but I think supporting Fortnite level gameplay at 10k players is not impossible.
The engine is not open source, but it is available to test, you can read the code for the demo on github.
77
u/ducksaws Oct 25 '26
Do you have any situations where interpolated player locations aren't acceptable? IE, someone can try to attack another player who is further than 64m away
48
u/SoilMassive6850 Oct 25 '26
How does this end up performing when you need to start doing entity interactions, raycasts, more complex physics and actual gameplay mechanics? I'll believe you if you claim to have the time budget for it in a client authoritative model, but with any heavier logic? I don't buy it.
8
u/Royal-Discount1214 Oct 25 '26
What is the logic in your server?
I know little about this, but, my main concern would keeping the logic on the server to avoid cheating and being able to process it at low costs. What are your thoughts about this?
18
u/sojuz151 Oct 25 '26
And what kind of lag compensation are you using and what anti cheating system?
210
u/projexion_reflexion Oct 25 '26
They said making a high performance multiplayer open world would be hard, but it's real easy if you leave out the world!
19
u/pabloe168 Oct 25 '26
2 questions:
What about players moving faster?
What about latency on different players?
6
u/xesttub Oct 25 '26
The only multiplayer game I’ve seen where people all pile into a single ‘shard’ and all need to know each others locations like this is Eve online. And they coincidentally slow down game ticks when this happens
23
u/netheit Oct 25 '26
makes sense. there is literally nothing to render
4
u/mr_birkenblatt Oct 25 '26
60Hz? Everybody's computer is in the same room?
4
u/pyabo Oct 25 '26
My Massively Multiplayer Online Forklift Simulator is finally feasible! :D
3
u/smallstepforman Oct 25 '26
I can do 80'000 NPC with no physics and a terrain engine, but with physics, collision avoidance, buildings, grass, etc it drops down to 40'000.
https://youtu.be/gLoVFvoXDew?si=E-2LTWiqqbuJPmvT
2
u/peatear_gryphon Oct 25 '26
Better than what I can do, which is nothing!
2
u/Skizm Oct 25 '26
No. Valve told me 10 players at 64 tick is impossible.
3
u/Redd411 Oct 25 '26
cool stuff!! was always interested in multiplayer/netcode ever since carmack/quake days. I like your target goals even if ambitious from technical standpoint, though lately I've been thinking about it more as game design problem. How do you design a game that makes even 10k players in same area something that still playable and not become visual soup.
for all the snarky redditors.. backup your criticism.. post link to your github.. lets see your superior work.. thought so
1
u/SteelBalls1867 Oct 25 '26
96 vcpu over 5 dollars an hour?? I can support 50k players with only 256 30hz updates on my raspberry pi
1
u/tenix Oct 25 '26
What's your bandwidth needed for this?
1
u/EngineerMinded Oct 25 '26
Awesome
1
u/EinerVonEuchOwaAndas Oct 25 '26
Wtf
1
u/Intelligent_Thing_32 Oct 25 '26
A “single server” isn’t a metric.
1
u/lqstuart Oct 26 '26
So you wrote a web server
1
u/sturmeh Oct 26 '26
What's going on here, are they all trying to stay on a giant treadmill?
How much rotational data is being tracked? What concessions are being made?
1
u/DonJuanDoja Oct 26 '26
Why tho? The more people you put in one place the worse things get, always.
1
u/kova98k Oct 26 '26
i bet you could crank it up to 100k if you remove the players too
1
u/MeBadNeedMoneyNow Oct 27 '26
Damn, you're getting skewered for showing your project. Best of luck.
1
u/P-39_Airacobra Oct 27 '26
This reminds me of the “benchmarks” that are just trivial toy programs
1
u/GniLudio Oct 27 '26
Until one starts cheating and you start using 99% processing time to detect them...
1
u/Relevant-Guarantee25 Oct 28 '26
ok now simulate people from Africa, Europe, Russia, etc space via satellite playing all at the same time and see if you get desync issues or other fun things the problem is your bots connected are all from the same region with great internet also the issue where a players computr cant handle seeing that many people on screen + adding game world mechanics + game objects on top of that that all need to sync
1
u/Luann1497 Oct 30 '26
50k at 60hz in C is no joke. Curious what your memory footprint looks like during peak load.
1
u/mistattwiligjt Oct 30 '26
I needed that laugh.
1
u/Any_Statistician2275 19d ago
а
1
u/burritoads Oct 25 '26
I think your Claude forgot to make the map too? Usually there is a game with the multiplayer stuff
0
u/Vking231 Oct 25 '26
NOOB
-3
u/Ghi102 Oct 25 '26
Isn't 60hz basically faster than the ping of most players? And probably bigger than some random fluctuations for players with bad internet. At least, I rarely get better than 20ms ping. Is that an issue?
-1
u/Legitimate_Author513 18d ago
A move data need 8bits sync to other people on scene, corresponding to a 50KB/s bandwidth when a people produce a move. You need a 20Gbps network support to ensure everyone’s moving . In fact , all MMO game will use AOI skill to make it happen on your screen
5
u/[deleted] Oct 25 '26
[removed] — view removed comment