我可以在AWS Elastic Beanstalk上配置Linux交换空间吗? [英] Can I configure Linux swap space on AWS Elastic Beanstalk?

查看:92
本文介绍了我可以在AWS Elastic Beanstalk上配置Linux交换空间吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以为AWS Elastic Beanstalk环境配置Linux交换空间吗?

Can I configure Linux swap space for an AWS Elastic Beanstalk environment?

我在控制台中看不到该选项.尽管Inactive值很高,但在我的环境MemAvailable中正在运行的实例上查看/proc/meminfo看起来却很低.我怀疑有一些休眠的后台进程对分页不会有任何危害,并且会释放我正在使用的t2.nano上有限的物理内存中的重要部分.

I don't see an option for it in the console. From looking at /proc/meminfo on my running instances in my environment MemAvailable is looking quite low despite there being quite high Inactive values. I suspect there are a few dormant background processes that it would do no harm to page out, and would free up a non-trivial portion of the limited physical memory on the t2.nano I'm using.

推荐答案

我想出了如何使用Tomcat Web应用程序中的.ebextensions config文件夹执行此操作.

I figured out how to do this using the .ebextensions config folder in my Tomcat web app.

添加文件.ebextensions/swap.config:

container_commands:
  add-swap-space:
    command: "/bin/bash .ebextensions/scripts/add-swap-space.sh"
    ignoreErrors: true

添加文件.ebextensions/scripts/add-swap-space.sh:

#!/bin/bash

set -o xtrace
set -e

if grep -E 'SwapTotal:\s+0+\s+kB' /proc/meminfo; then
    echo "Positively identified no swap space, creating some."
    dd if=/dev/zero of=/var/swapfile bs=1M count=512
    /sbin/mkswap /var/swapfile
    chmod 000 /var/swapfile
    /sbin/swapon /var/swapfile
else
    echo "Did not confirm zero swap space, doing nothing."
fi

更多文档: http://docs.aws .amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html

运行一段时间后,这允许在我的t2.nano实例上换出150MiB,该实例运行带有默认堆选项的Elastic Beanstalk Java Tomcat平台.从我可以看到,应用程序运行时没有正在进行的分页.看起来有些休眠数据已被推送以进行交换,并且页面缓存要大得多(从30MiB到180MiB).

After a while running this allowed 150MiB to be swapped out on my t2.nano instance which runs the Elastic Beanstalk Java Tomcat platform with default heap options. From what I can see there is no ongoing paging while the application runs. It looks like some dormant data has been pushed to swap and the page cache is significantly larger (up from 30MiB to 180MiB).

这篇关于我可以在AWS Elastic Beanstalk上配置Linux交换空间吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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