How much memory for 10 online users on a PaperMC server
Just trying to understand different approaches for answering this kind of questions.
40 Replies
@ProGamingDK I've seen you answering this kind of questions a few times on #marketplace-legacy.
there is no number
4-6 gb should work fine
but it heavily depends
Let's try to find something like a formula
you cant.
you physically cant make a formula
for this
10 online users on different parts of the map:
- 6.9k loaded chunks
- 2.4k active entities
These are the objects filling up the memory, can be easily verified with a memory dump to understand if growing is linear.
With PaperMC, memory ranges from ~3 GiB to ~5.5 GiB
If you're lucky and some users are close, loaded chunks and active entities will go down. I'm always measuring with users on different parts of the map, because that's the worst case (more memory in use).
with spikes of nearly 7gigs
Let's ignore Dynmap, which is currently consuming ~1 GiB
adding 8-10 more users we're getting linear increase in entities and chunks, so expecting a similar increase in used memory
yeah 12k chunks, 4.65k entities and memory ranging from 5.25 to 8 GiB
I was expecting a bit less, like 6 GB max for 20 users, but we may be using numbers from previous versions to do these calculations
Shockbyte for example says you can use 1 GB for 8+ users, which is completely stupid.
shockbyte is wrong on every step of the way either way
have u seen their tos
yeah but other popular providers aren't far from these numbers
issue is these numbers just dont work on higher player counts
160+ player servers work fine with 16 gb with usage being around 12
would be interesting to collect more about active entities, loaded chunks when that happens, and their related configs
I'd expect a trend change when hitting ~12 GB of memory usage
mostly because of JVM pauses, but we could find a more or less general formula that will work for < 9-12 GiB use cases
but this is just memory, servers with 100+ users will probably hit longer ticks first (due to single CPU constraints)
If people find this interesting, I'll try to also measure the impact of adding common plugins. Some of them require an almost fixed amount of memory, regardless of users. Others scale with the size of the map, and others with number of users. Others are virtually free in terms of memory.
There is no magic number that correlates between memory usage and player count.
What the players are doing and what the server is doing means far more to memory usage than the player count itself.
the server can always have a huge farm with thousands of entities, slowing everything down and making frequent memory changes.
but thinking about entities and chunks will give you a good estimate, as that's what causes ~90% of the memory increase when more users join the server.
chunks uses different amounts of ram tho
same with entities
and entities and chunks are closely related to player counts, as chunks aren't active if no one is there
entities arent really
1 person could have a 200 villager hall
But they won't be removed from memory until the JVM does garbage collection
while another just lives peaceful base with everything lighted up
but that happens regularly, you can ignore that for a quick capacity planning
Paper Server with currently 7 Playerss online
And the JVM does garbage collection only when it needs to.
It doesn't do it on a timer.
that one shows very random info
its not very accurate in my experience
So if you have a higher memory amount, you'll have more infrequent but larger memory fluctuations.
you can tune your GC configs or even use a different GC implementation, but I'm trying to find something that works for 90% of use cases.
basically everyone uses aikar flags
that's what happens with servers over 9-12 GiB, when GC hits you hard and may need to tune your flags based on really custom needs
if you like a different approach, let's find how much memory is consumed per chunk or entity and then multiply
hopefully these are regular in size 🤞
they arent
not even really that close
especially for villagers
bigger in memory?
well yeah
it has to store all trades etc
atleast thats what im thinking
loaded chunks are for sure more than 53% of the heap, but these are represented by different classes from
net.minecraft.world.level.chunk
and io.papermc.paper.chunk
(and probably others)
so I'll need to identify these classes or packages more precisely before measuring how much memory they're usingYes that is the world data itself.
It doesn't get unloaded from memory until it needs to
if I'm not mistaken, entities are tiny in memory. A high number may cause TPS drops, but they don't require any significant amount compared to chunks.
Correct, memory usage is mostly just world data. Then whatever data plugins need.
that's good! it simplifies memory calculations
Well you'd have to account for players that are next to other players, players that aren't next to other players, and what each plugin is doing.
a ~7% of my heap is filled with Dynmap stuff ðŸ«
Yeah sounds about right :KEKW:
close to 1 GiB
in Varoke we install Dynmap automatically, including TLS termination and custom subdomain, but we may need to find a more efficient alternative
~61% are chunks, ~3.5% are entities
I'd argue that sounds right