jeudi 22 mai 2014

php - créer un fichier/disque remplaçable sur ec2 instance micro sur haricot magique élastique déployer - Stack Overflow


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.




Haven't attempted creating a swap, so I'm unable to answer your first question. But be advised that the .ebextensions file is a YAML-file. That means that spaces and syntax is extremely important for things to work properly...


The syntax of your example is a bit off. Should be something along the lines of (see here):


commands:
000_dd:
command: dd if=/dev/zero of=/swapfile bs=1M count=3072
001_mkswap:
command: mkswap /swapfile
002_swapon:
command: swapon /swapfile

Commands are executed in alphabetical order, so prefixing them with a number is a good idea.


Ensure that you're able to log on to your EC2 instance, and keep an eye on the /var/log/cfn-init.log file. This will tell you what happens. And what didn't work as intended... ;-)


Good luck!



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.



Haven't attempted creating a swap, so I'm unable to answer your first question. But be advised that the .ebextensions file is a YAML-file. That means that spaces and syntax is extremely important for things to work properly...


The syntax of your example is a bit off. Should be something along the lines of (see here):


commands:
000_dd:
command: dd if=/dev/zero of=/swapfile bs=1M count=3072
001_mkswap:
command: mkswap /swapfile
002_swapon:
command: swapon /swapfile

Commands are executed in alphabetical order, so prefixing them with a number is a good idea.


Ensure that you're able to log on to your EC2 instance, and keep an eye on the /var/log/cfn-init.log file. This will tell you what happens. And what didn't work as intended... ;-)


Good luck!


0 commentaires:

Enregistrer un commentaire