Scale Magento on AWS Elastic Beanstalk - magento

I have looked in the Magento & AWS Documentation but that didn't really help.
I've installed Magento on Elastic Beanstalk with 1 instance, I proceeded to snapshot the volume and make an AMI and changed the AMI setting in Elastic Beanstalk. Then spun up 2 more instances in the other availability zones. They went back to the Magento installation pages.
How do I fix this? I thought the AMI made from the snapshot would of captured the DB and other files created on installation. Meaning they'd just connect the DB and run.
Cheers to anyone who helps!

You probably don't want your database installed on your EC2 inside the elastic beanstalk. Since elastic beanstalk just removes the instance when there is an error on it and spawns a new one. You then end up loosing data. Besides that you need 1 single database server, not a database server on each of the EC2 instances inside the elastic beanstalk.
You want a separate database server, I personally always use Amazon RDS for this since this is made for this purpose.
When you are getting the install page it probably means Magento cannot locate your app/etc/local.xml. Since AWS normally gets your files from git and it is best practice to not have your local.xml in version control you are probably missing this one?
Hope that I pointed you in the right direction.
Keep in mind that the database is just your first challange, next things you are going to need to handle is:
Sessions (database is a good option but I use AWS ElastiCache with
Redis)
Cache (again, AWS ElastiCache with Redis)
Media Storage (I use S3 with S3FS and CloudFront)
CDN (CloudFront)
Here are some sites that have helped me setting up my first elastic beanstalks with Magento:
http://www.aschroder.com/2013/04/actually-running-magento-on-amazons-elastic-beanstalk-cloud-platform/
http://www.slideshare.net/corleycloud/scale-your-magento-app-with-elastic-beanstalk

Related

How To Stop Data From Getting Deleted On AWS Code Pipeline Having a Laravel Application

I have an elastic beanstalk environment set with code pipeline to my repository which is a Laravel site.
When I push a new change to the master branch it gets changed in the ec2, AND DELETES ALL DATA IN STORAGE.
I can't find a similar question online, so any ideas on how can I fix this issue?
Elastic Beanstalk runs on instances that don't persist data between redeployments by default. You need to re-design app to use one of the available options if you really need stable local storage.
Take a look at Persistent storage section in the doc below.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.concepts.design.html

How to update code on multiple EC2 instances?

I created an Elastic Load Balancer in front of two EC2 instances. However, I discovered an issue that requires me to update the code on both EC2 instances.
I can access each instance individually to update code via github, or I could create an AMI to launch a new instance. It's very unfavorable.
How can I synchronize code between the two EC2 instances?
In situations like this either a code pipeline would be helpful OR better yet switch to Elastic Beanstalk.

Preserve content after elastic beanstalk deployment

I have a Symfony2 website running on Amazon EC2 and Elastic Beanstalk. Each time I deploy a git version of my project immediately lost the contents of a folder ("/web/uploads")
Is there a way to tell to Elastic Beanstalk that this content shouldn´t be overriden?
I was thinking on specify an extra command on container_commands parameter inside my .ebextention file but I´m not sure it is the best way to resolve the problem.
You can't preserve that content. You will need to store it externally in a location such as S3, RDS, DynamoDB, etc. The other thing about Elastic Beanstalk to note is that if it scales up another instance of your app it won't have the content you stored locally and won't have access to it. I know it sounds harsh and limiting, but having an automated config/deploy is less trouble in the long run, IMHO. ;)

Running multiple environments on one AWS EC2 instance (Elastic Beanstalk)

I am very new to the Amazon AWS services. I was wondering if there is a way to run an instance of EC2 (say, Amazon Linux AMI) and then connect two environments to this instance.
Particularly, I'd like to run a PHP and a Tomcat environment on a single EC2 instance.
The problem is, every time I create a new environment in Elastic Beanstalk, it seems to create a new EC2 instance as well. Am I missing something here?
I'd appreciate any hint on this.
AWS Elastic Beanstalk is designed for deploying your running apps in a way that is designed for scalability from the ground-up. Because of this, Elastic Beanstalk will launch one or more EC2 instances, connect them to an Elastic Load Balancer instance, configure CloudWatch monitoring and Auto Scaling triggers.
Also, because of its fundamental design for scalability, Elastic Beanstalk is designed around a one-app-per-environment model (whereby "environment", I mean one of these EC2 + ELB + CloudWatch + AutoScaling clusters).
Since running two separate web servers with two separate apps (PHP & Java) is not a fundamentally scalable design, it's not a use-case that Elastic Beanstalk is optimized for.
You are free to spin-up a standalone EC2 instance and install whatever you'd like on it, but you're right — git aws.push support has not been made available for standalone EC2 instances. If the git support is important to you, you'll need to weigh the pros and cons of each approach.
I would also like to be able to do this, basically from a cost perspective for demos etc.
For example, a single instance with one PHP app and one Java app. Or, a single instance with two Java apps.
However, from what I have read so far in the Elastic Beanstalk developer guide, I have not found anything explicitly stating that multiple applications per environment is supported (or even, multiple environments per EC2 instance - if that even makes sense).
It makes me wonder if this is a feature that is often requested and planned for the future, or alternatively if the single-app-per-environment model is 'by design' for some reason.

Should I use a regular server instead of AWS?

Reading about and using the Amazon Web Services, I'm not really able to grasp how to use it correctly. Sorry about the long question:
I have a EC2 instance which mostly does the work of a web server (apache for file sharing and Tomcat with Play Framework for the web app). As it's a web server, the instance is running 24/7.
It just came to my attention that the data on the EC2 instance is non persistent. This means I lose my database and files if it's stopped. But I guess it also means my server settings and installed applications are lost as they are just files in the same way as the other data.
This means that I will either have to rewrite the whole app to use amazon CloudDB or write some code which stores the db on S3 and make my own AMI with the correct applications installed and configured. Or can this be quick-fixed by using EBS somehow?
My question is 1. is my understanding of aws is correct? and 2. is it's worth it? It could be a possibility to just set up a regular dedicated server where everything is persistent, as you would expect. Would love to have the scaleability of aws though..
If you use an EBS volume with your EC2 instance, you can mount/dismount them to have persistent storage. You can also use Amazon RDS to handle your database too which is handy (but can be slightly on the pricier side.)
So a way to think of it is:
Your EC2 instance: Get the OS set up exactly like you'd like it along with your web application - basically, get your static stuff all in place.
EBS volume: That can be mounted and can be used for things like user uploads.
RDS instance: This is a dedicated database server with no hassles. It's nice - I use a MySQL RDS and it automatically makes two daily backups, and is scalable like EC2 instances.
Amazon Web Service is a better approach at hosting your applications Jon. You have a basic understand of AWS but you need to know that you can also launch an instance that is persistent. Just launch an instance of a persistence AMI. Also you can install you database,webs server on the instance like a regular server. There is probably just minimal differences from running an Ec2 instance and a dedicated server. If you have any other questions you can contact me.

Resources