Scale horizontally depending on connection count instead of resource usage?

I’m currently using the Docker API to start containers with a minecraft-server image depending on the other servers usage. The thing is that this depends on the number of connections per server not resource usage.
Can i replace my current code to open more containers when the player limits are reached for some kind of kubernetes solution?

Sorry if this is the wrong place to ask.

Kubernetes comes with some resource overhead and some learning curve, but yeah it can spin up containers with any metrics you setup. You would need to setup a sidecar to export connection metrics per pod. From that you can use a horizontal pod autoscaler to handle scaling.

Something to bear in mind with Java specifically is you will need to expore JMX metrics if you want to scale based on memory usage. Java doesn’t really like releasing memory, you have to measure usage for scaling from the heap.