I have use case query regarding scaling that I have a PHP Magento application running inside a Docker container on AWS Elastic Beanstalk backed by a AWS RDS (t2.micro) instance.
Now when I use Apache JMeter for load testing, I throw just 100 users in 10 seconds and my RDS instance goes down but Beanstalk instance remains fine. My question is how do I scale the RDS when an huge number of traffic comes?
Some said to me that you should use a at least medium instance for your RDS but how can we use the autoscale feature? Whether it exists in the case of RDS or not?
Some also said to use AWS RDS Read Replicas! I did not work with Read Replicas before but how do I load balance the traffic between different RDS read replicas, what are different ways and what if we need some low database operations? Will it scale in?
Any appropriate guidance will be appreciable. :)
Related
Im developing a django website.
On the devops side, im considering using aws with an autoscaling. I still hesitate to contenerize my config, so I would use either beanstalk (without container) or container service (with docker). The database will be on aurora on a separate server.
I am new to aws and the help they provide online by expert is not free so here is my question :
When i compare with other hosting providers, their prices depend on the hardware configuration of the server.
I guess (because i dont yet have access to cost explorer) that it is the same with ec2 instances on amazon: you pay more for more powerful servers (cpu and ram and/or storage).
So im wondering how elastic beanstalk or elastic container instanciate new ec2 servers : do they invoke more powerful hardware configurations(scaling up) based on the demand on my website or does it depend on my manual configuration ? Or do they only replicate ec2 instances (scaling out) with the same config i manually set at the init?
Can i manually change the cpu,ram and storage of an ec2 instance of benstalk or ecs without re-configuring it all?
Can i fine tune the autoscaling out and autoscaling up and which scaling is better and cheaper (best choice)?
thanks a lot!
Auto Scaling groups scales out horizontally, means spawn new instances like defined in the launch template/launch configuration. Auto Scaling group cannot scale vertically. You can change the launch cofiguration and edit the instance type and size, which will replace your instances in the Auto Scaling Group.
https://docs.aws.amazon.com/autoscaling/ec2/userguide/create-asg-launch-template.html
With ECS, you have to option Fargate or ECS on EC2. With Fargate (serverless) you can easily define how much resource RAM/CPU you want to allocate to the "task" to run. With ECS EC2, you need to first create the ECS Cluster (need to allocate EC2 for running the cluster), then create a seperate task and then allocate RAM and CPU to it.
https://docs.aws.amazon.com/AmazonECS/latest/userguide/task_definition_parameters.html
Using Beanstalk you can easily define how much resources RAM/CPU want to use in the configuration. (Easier than just running plain autoscaling groups with a load balancer). It has a very easy interface to play around and adjust the resources.
We have an AWS account with multiple EC2 instances and an RDS instance. These have been running since before VPCs were introduced. Now I need to upgrade the RDS instance class and the new class can only be established in a VPC. So if our RDS instance is modified (converted) into the new class and the new RDS instance is in a VPC will the EC2 instances that use this RDS need to be moved into the VPC at the same time or can this be a separate process?
RDS and EC2 security groups are not cross-compatible between classic and vpc EC2. If you have an RDS with an EC2 sec group reference you will not be able to add a classic ec2 sec group to your vpc RDS sec group.
Differences Between Security Groups for EC2-Classic and EC2-VPC
Your best bet is to migrate your EC2 infrastructure to VPC along with your RDS. You can of course grant global access to your RDS if you want to separate the process and then lock it back down when you've migrated your EC2 infrastructure but this is a big no no (huge security risk).
This is a non trivial process and I feel your pain. The least complex thing is to incur downtime during migration so that you don't have divergence between RDS instances. But that's not ideal especially when you have a large RDS storage-wise. BTW, you will want to test how long the process takes to snapshot and restore the RDS since it might take a while.
An alternative if you can manage it is to force your app to use read-only replicas while you migrate the RDS. That way your app can still function (kind of) and you won't have to worry about reconciliation between RDS instances post-migration. But obviously your app needs to be aware that it's in read-only mode or you'll end up with erratic behavior.
Forgot to mention there is something called classic-link which might help here but I've personally never used classic-link. Check it out in an AWS whitepaper write up here:
Move Amazon RDS MySQL
Databases to Amazon VPC
using Amazon EC2
ClassicLink and Read
Replicas
Sorry, I had a few basic questions. I'm planning to use an AWS EC2 instance.
1) Is an EC2 instance a single virtual machine image or is it a
single physical machine? Documentation from Amazon states that it is
a "virtual server", but I wanted to clarify if it is an image
embedded inside one server or if it is an single physical server
itself.
2) Is an Elastic Load Balancer a single EC2 instance that handles
all requests from all users and simply forwards the request to the
least loaded EC2 instances?
3) When Auto-Scaling is enabled for an EC2 instance, does it simply
exactly replicate the original EC2 instance when it needs to scale
up?
An EC2 instance is a VM that gets some percentage of the underlying physical host's RAM, CPU, disk, and network i/o. That percentage could theoretically be 100% for certain instance types, including bare-metal instances, but is typically some fraction depending on which instance type you choose.
ELB is a service, not a single EC2 instance. It will scale on your behalf. It routes by round robin for TCP, and routes on fewest outstanding requests for HTTP and HTTPS.
Auto Scaling is "scale out" (it adds new EC2 instances), not "scale up" (resizing an existing EC2 instance). It launches a new instance from a template called an AMI.
It is a virtual server, a VM, as stated in the documentation.
It's a little more complicated that that, based on the way AWS might scale the load balancer, or create a version in each availability zone, etc. It also provides more features such as auto-scaling integration, health checks, SSL termination. I suggest you read the documentation.
It uses a machine image that you specify when you create the auto-scaling group (when you create the Launch Configuration used by the Auto-scaling group to be more precise). A common practice is to configure a machine image that will download any updates and launch the latest version of your application on startup.
You might also be interested in Elastic Beanstalk which is a PaaS that manages much of the AWS infrastructure for you. There are also third-party PaaS offerings such as OpenShift and Heroku that also manage AWS resources for you.
I'm currently using RDS MultiAZ from Amazon Web Services on my project, and I was hoping to use ElastiCache to improve the speed of my queries. However I noticed that on ElastiCache I have to define which zone I'm interesting in using.
Just to check if I got it right: MultiAZ means that I have 2 database servers on 2 zones (I'm using South America region): on zone A I have a read and write server (Master) and on zone B I have a read server (Slave). If for any reason zone A goes down, zone B becomes the Master until Zone A returns.
Now how do use ElastiCache (I'm using Memcache) in this case? I can't create a cache cluster with a single endpoint to connect, and 2 nodes (one in each zone). I need to have 1 cache cluster for each zone, and 2 codes for my application so they'll connect to the correct zone?
Already asked that on AWS forums a month ago, but had no response.
Thanks!
Amazon ElastiCache clusters are per-AZ and there is no Multi-AZ for ElastiCache as there is for RDS (you are right, that is master/slave replication). So you would need to design around that. This is very context dependent, but here are three ideas:
Failure Recovery: monitor your cache cluster and, in the event of a failure, spin a new one in another AZ.
Master/Slave: have a standby cache cluster and, in the event of a failure, reroute and scale to the slave.
Multi master: have per-AZ cache clusters always up under a Elastic Load Balancer.
EDIT
This answer considers ElasticCache for Memcached. For Redis there is Multi-AZ (master/slave) support.
I am tying to deploy galera cluster on aws. Is it a good idea to use VPC or making a cluster with 2-3 open ec2 instances. What are pros and cons.
Also, Is there any extra billing for VPC? Any help will be great!!
I am not sure of the variation of the installation of the GALERA on AWS VPC with EC2 instances.
One suggestion which I would add is the consideration of the RDS - Database as a service from AWS; I don't whether that would solve your need to use GALERA.
Regarding the pricing for the VPC, it is free; you only pay for the underlying EC2 instances running, Elastic IP - Data Transfer, Out Bandwidth etc. If you are going to connect your local data center to VPC using VPC/VPN gateway - that would be charged
No there is no extra cost for a VPC [but only for the resources used in it]
With Galera you can have a multi-master architecture [I have not implemented it] but with RDS you cannot. I have setup a Disaster Recovery plan with RDS where a multi-master architecture would be eliminating the downtime , but instead set it up with the use of Read Replica which would be promoted in a master. That's the way AWS RDS works.