从主机使用Java共享堆空间 [英] Using Java from Host to share Heapspace

查看:43
本文介绍了从主机使用Java共享堆空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过共享堆空间从主机系统挂载jre目录来减少ram内存使用?还是会引起一些问题?

Can mounting jre directory from host system reduce ram memory usage by sharing heapspace? Or will this cause some problems?

我内部有很多运行Java服务的容器.问题是,有时当服务具有非常大的工作负载时,(如果有)堆空间(最终),它们会需要很多.当我为每个容器分配(例如)-Xmx2g时,我的主机系统上的RAM很快就会耗尽.不幸的是,一旦Java分配了堆,它将不再可用(对于容器RAM,主机RAM).重新启动容器将为高峰使用的堆空间释放分配的内存,但是对于内部装有solr的容器,(可能)将花费几个小时才能再次为所有数据建立索引,这使得停机仅在周末发生.

I have a lot of containers running java service inside. The problem is, that sometimes when the services have very strong workload, they need (eventually) a lot if heapspace. When i assign for each container (for example) -Xmx2g, then im pretty fast running out of RAM on my host system. Unfortunately once java allocated heap, it will not be free anymore (for the container RAM, host RAM). Restarting the container will free the allocated memory for the heapspace used in the peak, but for container with solr inside it will (probably) take several hours to index all the data again, what makes the downtime only possible on the weekend.

这个想法是在主机系统中使用通用的jre在单个服务之间共享堆空间.可能我可以为-Xmx分配以下值(仅作为示例):250m乘以若干服务,再加上3g的工作量峰值.这样,由于服务共享堆空间,因此我将使用更少的内存.

The idea is to using common jre in the host system to share the heapspace between single services. Probably i can assign -Xmx the following value (only an example): 250m times a number of services plus 3g for the workload peaks. This way i will using much less memory, because the services sharing the heap space.

我的想法有误吗,或者真的值得吗?

Is there an error in my idea or can it really be worth?

也许有人已经遇到了这样的问题,并可能以其他方式解决了这个问题?

Maybe someone is already faced such a problem and and probably solved it in another way?

推荐答案

我已经在这里找到了一个解决方案(压缩Java堆空间): https://stackoverflow.com/a/4952645/2893873

I already found a solution here (schrinking java heapspace): https://stackoverflow.com/a/4952645/2893873

我认为缩小java堆空间是不可能的,但是有可能.我认为这将是一个更好的解决方案,而不是在容器之间共享JVM.

I assumed that shrinking java heap space is not possible, but it is. I think it will be a better solution instead of sharing the JVM between the container.

这篇关于从主机使用Java共享堆空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆