Wiremock originating OutOfMemoryError: Java heap space in Kubernetes cluster

2,184 views
Skip to first unread message

Nuno Marcos

unread,
Feb 18, 2021, 6:14:31 PM2/18/21
to wiremock-user
Hi There @Tom,

I'm currently launching a Wiremock pod (release 2.27.2) in a Kubernetes cluster and observing heap usage growing till it get's the following errors:
Exception in thread "Connector-Scheduler-5a9f4771-1" java.lang.OutOfMemoryError: Java heap space

Resources configurations are these:
Memory Limits: 2 GB
CPU Limits: 2 cores

Wiremock flags are the following ones:
--container-threads 1200 --jetty-acceptor-threads 20 --global-response-templating --async-response-enabled --async-response-threads 50 --no-request-journal

And tuned Java Options are the following:
-server -XX:+PrintFlagsFinal -Xms750M -Xmx1024M -Xss256k -XX:MaxMetaspaceSize=256m -XX:CompressedClassSpaceSize=32m -XX:ReservedCodeCacheSize=32m -XX:NativeMemoryTracking=summary -XX:+UseG1GC -XX:+UseStringDeduplication -XX:MaxGCPauseMillis=750

I have only 3 mappings enabled on this wiremock instance, but each one of them are using a specific transformer that generates responses body randomly.

Can you please help me out to understand what can be the cause for this java heap to get without any free space?

Can this be related with the way i'm implementing my transformers or with the configurations i'm using?

Grafana dashboard with JVM metrics is attached.

Thanks,
Nuno Marcos

grafana_jvm_dashboard.png

Tom Akehurst

unread,
Feb 18, 2021, 6:35:08 PM2/18/21
to wiremock-user
1200 is far too many container threads if you're only using 2 cores, particularly since you've got async responses turned on. I'd suggest no more than 100-200.

Also, 20 acceptor threads is too much, and you generally only need to change this on very large machines, so I'd drop this parameter entirely and leave it to default.

Finally, if you're using response templating heavily I'd suggest capping the template cache size with something like --max-template-cache-entries 500.

Nuno Marcos

unread,
Feb 22, 2021, 6:38:54 PM2/22/21
to Tom Akehurst, wiremock-user
Thanks @Tom,

Your suggestions solve my problem.

Kudos for you and keep up with the good work,
Nuno Marcos

--
You received this message because you are subscribed to a topic in the Google Groups "wiremock-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wiremock-user/bjcGU8i8RL0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wiremock-use...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wiremock-user/69da579e-111f-43bd-b068-7b008c824cc9n%40googlegroups.com.


--
Cumprimentos,
Nuno Marcos
Reply all
Reply to author
Forward
0 new messages