Menu

How much RAM does a Java application really need? Sizing a small server
📰

How much RAM does a Java application really need? Sizing a small server

DEV Community: java·Boban C.·17 days ago
#DF7ZBhc9
#devtojava#devto#dev#heap#server
Reading 0:00
15s threshold

When people size a Java server they look at -Xmx . That sets the maximum heap, where your objects live. The operating system sees the whole process, and that is larger:

Heap: your objects, caches and sessions, up to -Xmx .

Metaspace: loaded classes. A framework-heavy application uses 100 to 300 MB.

Thread stacks: about 1 MB per thread by default, so 200 threads is 200 MB.

Code cache: compiled code, tens of MB.

Direct and native memory: network buffers, compression, JDBC drivers.

GC overhead: the collector's own bookkeeping.

As a working rule, the process uses the heap plus 300 to 600 MB. If Nginx, a database and the OS share the server, add those too.

The split I use

With a database on the same server I give 45% of RAM to the JVM heap, 15% to database buffers, and leave 40% for the OS, metaspace, thread stacks and file cache.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.