建立在EC2上微实例上的弹性魔豆部署一个交换文件/驱动器 [英] creating a swap file/drive on ec2 micro instance on elastic beanstalk deploy

查看:158
本文介绍了建立在EC2上微实例上的弹性魔豆部署一个交换文件/驱动器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我的应用程序安装只要我把它放在一个实例大于微观部署好的。

当我部署在微作曲时尝试安装,我得到一个PHP错误有关无法分配足够的内存。所以我做了一些谷歌搜索,似乎你可以创建一个交换文件/磁盘上的启动/创建实例这里有两个教程的 之一的

这些可能是过时所以第一个问题是可这仍然不能做到?

第二个问题是如何创建一个.ebextensions文件来实现这一目标上部署?

下面是我的尝试,但它不工作不出所料不够,因为我还不是很了解这一点。

 命令:
命令:日若= /交换文件BS = /开发/零= 1M数= 3072
命令:再用mkswap /交换文件
命令:swapon命令/交换文件
 

解决方案

一台机器上运行Composer需要相当多的资源,尤其是内存。

据我了解,这是适得其反使用在EC2微型实例交换空间,因为)它是缓慢交换空间和b)用它计算对IO这也给支付,允许一个意想不到的法案下个月

要部署使用作曲什么正确的方法是安装所有的依赖部署code上机前,然后同步就一气呵成。这样,你是独立于实例的资源有限,因为你可以使用一些功能强大的部署机(我敢打赌,你的dev的机器可以做到这一点)。您也prevent结束与一个破碎的网站,因为一些必要的库的主机是向下(经历过Github的停机时间?),因为你会发现这个部署服务器,而不是活的机器上。此外,下载,这也可能会超过对微实例有限的资源作曲家将缓存任何东西 - 或者至少用它的东西非生产性

So my application installs and deploys fine as long as I put it on an instance bigger than micro.

when I deploy on micro when composer tries to install I get a php error about not being able to allocate enough memory. so I did some googling and it seems that you can create a swap file/disk on boot/ creating of the instance here are two tutorials one two

these might be dated so first question is can this still be done?

Second question is how do I create a .ebextensions file to make this happen on deploy?

Here is my attempt but its not working unsurprisingly enough as I know very little about this.

commands:
command:dd if=/dev/zero of=/swapfile bs=1M count=3072
command:mkswap /swapfile
command:swapon /swapfile

解决方案

Running Composer on a machine requires quite a bit of resources, especially RAM.

I have learned that it is counterproductive to use swap space on a EC2 micro instance because a) it is slow swap space and b) using it counts against IO which has also to be paid, allowing for an unexpected bill the next month.

The correct way to deploy anything that uses Composer is to install all dependencies prior to deploying the code onto the machine, then sync it in one go. That way you are independent from the limited resources of the instance because you can use some powerful deployment machine (I bet your dev machine can do it). You also prevent ending up with a broken site because some required library's hosting is down (ever experienced Github downtimes?), because you'd detect this on the deploying server, not the live machine. Additionally, Composer will cache anything downloaded, which also might exceed the limited resources on a micro instance - or at least use it for something non-productive.

这篇关于建立在EC2上微实例上的弹性魔豆部署一个交换文件/驱动器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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