2012-04-06 84 views
0

我們已經在Elastic Beanstalk中部署了一個java web應用,其中最小實例數爲1,最大實例數爲2,用於Autoscaling。我們正在使用的定製AMI是Sun JDK 6的c1.medium。AWS Elastic Beanstalk中的容器選項

環境狀態更改爲黃色,然後變爲紅色。從快照日誌中檢入日誌文件後,我們發現一個異常 - 由以下原因引起:java.lang.OutOfMemoryError:Java堆空間。假設這可能是環境故障的可能原因之一。 我們環境中的集裝箱選項已配置的設置是

初始JVM堆大小(MB) - 256M

最大JVM堆大小(MB) - 512MB 最大堆大小Java虛擬機將永遠消費,使用-Xmx在JVM啓動命令行中指定。

最大JVM持久代的大小(MB) - 512MB

我應該從512米增加堆大小更或者是罰款。

回答

1

我認爲您的最大JVM永久代大小太大。這裏是documentation of AWS

JVM Options

The heap size in the Java Virtual Machine affects how many objects can be created in memory before garbage collection—a process of managing your application’s memory—occurs. You can specify an initial heap size and a maximum heap size. A larger initial heap size allows more objects to be created before garbage collection occurs, but it also means that the garbage collector will take longer to compact the heap. The maximum heap size specifies the maximum amount of memory the JVM can allocate when expanding the heap during heavy activity.

In the Edit Configuration window, you can set the initial and the maximum JVM heap sizes using the Initial JVM Heap Size (MB) and Maximum JVM Heap Size (MB) boxes. The available memory is dependent on the Amazon EC2 instance type. For more information about the Amazon EC2 instance types available for your AWS Elastic Beanstalk environment, go to Instance Families and Types in the Amazon EC2 User Guide.

The permanent generation is a section of the JVM heap that is used to store class definitions and associated metadata. To modify the size of the permanent generation, type the new size in the Maximum JVM Permanent Generation Size (MB) box

我發現這個Rimuhosting how-to article解釋XMX設置相當不錯。