Hi all,
I’m trying to run a couple of Kotlin microservers on an Amazon Lightsail server, and I’m running into the problem that even one application uses up a lot of the limited RAM. The server has 1GB of RAM, and when I run both applications, usually within 24 hours they chew up all the RAM.
I’m looking for any tips people have for:
- Modifying my Kotlin code to reduce memory usage
- Options to reduce the memory usage of the JVMs
- Any other advice
I’ve thought about either trying to find a JDK that specializes in low memory usage, or simply compiling native binaries (either with Kotlin Native, or with another tool that can compile Java code to native machine code). I’ve also wondered if it’s possible to run multiple jar files in one JVM, so that there’s only one JVM’s worth of memory overhead.
I’m also ideally planning a third Kotlin microservice to run on this server… but with the way things are looking right now, I might have to write it using something with a much lower memory footprint (maybe Python is good for low memory usage? idk)
I’ve currently got the max heap constrained to 128mb for both services; last time the server ran out of memory they were each constrained to a 256mb max heap. There are a few other things running on this server that are using a bit of memory as well (MariaDB server, PHP server).
How good is Kotlin Native compared to using a JVM? When I was searching for threads earlier, I saw one that said Kotlin Native is slower compared to JVM; is that still the case?
All suggestions welcome.