How can I make sure route53 route traffic to two targets evenly? - amazon-web-services

I deployed two A records in host zone in route53.
One A record is an alias to AWS hosted application load balance which is located in Sydney region.
The other record is an A record points to an IP address hosted by load balance from GCP in Melbourne region.
And I am using Weighted routing policy that each has 200 weight. When I send requests from a laptop in Melbourne, all the traffic is routed to GCP load balance. It only route traffics to AWS when I bring down the application in GCP.
My question is how I can make sure route53 route traffic roughly evenly (not exact even) cross the two targets. Why does route53 route all traffic to GCP (Melbourne region)?

Related

Improving latency times for EC2 from different geographic areas

We have an EC2 instance in US East, and our latency for users in the UK + AU is about 1-2 seconds higher. We are only dealing with text data and an RDS server in the same zone. Provided we want to go the route of creating another image instance of the primary EC2. How does the process work in lowering latency? Per our understanding:
Create a replica from the image in AU/UK zones
Add the external IP's of these two servers to the domain nameserver which will automatically generally help route the user to the closest server?
Or does it involve creating some sort of load balancer with a geographic rule, and the load balancer IP is what our NS will be?
TLDR: How do we route UK users to the UK EC2 server, what does the setup look like?
I recommend that you use Latency-based routing - Amazon Route 53:
If your application is hosted in multiple AWS Regions, you can improve performance for your users by serving their requests from the AWS Region that provides the lowest latency.
You would configure one DNS Name to route to multiple IP addresses. Route 53 will examine the location of the incoming request and route the traffic to the destination with the lowest latency.
This is not quite the same as geographic routing because some countries have better Internet connectivity and traffic will be routed according to latency rather than distance.
Alternatively, you can use AWS Global Accelerator, which routes traffic across the AWS global network. It uses a single IP address that exists in multiple locations (known as anycast) to redirect traffic to the closest (fewest-hop) endpoint of the AWS global network, then sends traffic over that network to the closest AWS location where you have provisioned services. This can achieve lower latency than routing across the Internet, but incurs a per GB cost for traffic.

How does amazon ec2 work in regards to routing a domain name to an instance using load balancers?

How does amazon ec2 work in regards to routing a domain name to an instance using load balancers?
What is the flow of a request from the domain name to the ec2 instance?
There is documentation regarding this on AWS, you can check the page Routing traffic to an ELB load balancer - Amazon Route 53 which contains the details.
Moreover in the above document there are links to other pages like how to use Route 53 etc., you will get full coverage of what you are looking for.
The flow of traffic is as shown below.
Hosted zone => Load balancer => Target group => EC2 Instance.
So when you make a request to a domain name the request is routed following the "rules" that are in its hosted zone.
A hosted zone is a container for records, and records contain
information about how you want to route traffic for a specific domain,
such as example.com, and its subdomains (acme.example.com,
zenith.example.com). A hosted zone and the corresponding domain have
the same name.
In one of the rules that you set in the hosted zone there should be a rule(a record) that directs traffic from your domain name to the load balancer. The record is of 'A type'.The load balancer then routes the traffic to the target group.
A load balancer distributes incoming application traffic across
multiple EC2 instances in multiple Availability Zones. ... Elastic
Load Balancing detects unhealthy instances and routes traffic only to
healthy instances. Your load balancer serves as a single point of
contact for clients.
The target group then has records called targets. This targets store information like EC2 instance id, port, health status among others. The target info informs how traffic is routed. If the health status is unhealthy traffic is routed to a target with a healthy status or an error is returned as a response.
A target group tells a load balancer where to direct traffic to : EC2
instances, fixed IP addresses; or AWS Lambda functions, amongst
others. When creating a load balancer, you create one or more
listeners and configure listener rules to direct the traffic to one
target group.
When traffic is routed from the target group to a healthy target it goes to the EC2 instance that the EC2 instance id belongs to. In the EC2 instance there should be a server running that takes the request and gives back the appropriate response.
An Amazon EC2 instance is a virtual server in Amazon's Elastic Compute
Cloud (EC2) for running applications on the Amazon Web Services (AWS)
infrastructure.

Connect AWS Hosted Zone To Registered domains

I want to connect my domain (in AWS Registered Domains) to the IP address of my Ec2 instance in my AWS account; so that I can type www.my-domain.com in any browser and open my website.
I transferred a domain name from my old AWS account to a new one. Usually AWS creates a hosted zone for the domain automatically, but it didn't.
So I created my own hosted zone and and added and two A records (www.a.com and a.com) with value connected to the IP address of my Ec2 instance but the browsers didn't recognize the domain.
So I tried:
Updating the Name servers of the hosted zone to be the same as the domain name NS But same result
Updating the Name servers of the domain name to be the same as the hosted zone NS But same result
What can I do?
Thanks.
As long as the domain registrar is AWS (you can validate this by running whois against your domain) the setup should be quite simple.
Firstly it might be worth creating a new hosted zone if you've modified the NS records for it. It is important that these values are the original domains that AWS entered against the values. Also ensure the hosted zone is a public hosted zone.
Copy each of the nameserver values from your public hosted zone (there should be 4 in total). Then on your registered domain in the Route 53 console, edit the nameservers replacing the values with the values that were taken from your hosted zone. Once you have done this the new public hosted zone will be used by your domain.
Depending on any TTL caching you might find it can take a little time for clients to use this nameserver but you can test it by using a DIG command to find the NS value using an external server or the web service offered by google.
I don't know if this could count as and answer but this is what I did to fix the problem:
I created and Application Load Balancer
With Security Group with Inbound rules: HTTP TCP 80 0.0.0.0/0, ::/0
And Target Group TCP 80 Set to Ec2 instance.
Connect the A record to the ALB
This fixed my problem

My sub domain is not working with Route53

I have a domain (ex: example.com) which is configured and working fine with AWS Route 53 as below configuration
I have A record point to a AWS ELB for 2 EC2 instances (such as A and B which have tomcat 7 installed and configured).
Now I want to setup a subdomain like java.example.com which is pointing to another EC instance such as C but so far is not luck
What I have tried so far is
Try 1. Create another hosted zone such as java.example.com and then create A record which point to the IP of C ==> not working
Try 2. Create A record under hosted zone example.com with name as java.example.com and value is IP of C => not working
Please advice what I'm missing.
What you can do is create a CNAME record named java.example.com and point that to the EC2 instance.
If you want to use A record then create a Load Balancer, put your EC2 behind the load balancer and then use the DNSName of the load balancer as the value for your A record
Check here for more details https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/resource-record-sets-choosing-alias-non-alias.html
Extract from above page is as follows
When Route 53 receives a DNS query for an alias record, Route 53 responds with the applicable value for that resource:
An Amazon API Gateway custom regional API or edge-optimized API –
Route 53 responds with one or more IP addresses for your API.
An Amazon VPC interface endpoint – Route 53 responds with one or more IP addresses for your interface endpoint.
A CloudFront distribution – Route 53 responds with one or more IP addresses for CloudFront edge servers that can serve your content.
An Elastic Beanstalk environment – Route 53 responds with one or more IP addresses for the environment.
An ELB load balancer – Route 53 responds with one or more IP addresses for the load balancer.
An Amazon S3 bucket that is configured as a static website – Route 53 responds with one IP address for the Amazon S3 bucket.
Another Route 53 record in the same hosted zone – Route 53 responds as if the query is for the record that is referenced by the alias record.

Can I use AWS Route53 registered domain in another AWS account?

Haven't seen something like this (Hosted zone transfer maybe?), so I'll try here.
I have a pretty straightforward question, so I am hoping that someone can answer it or has any experience with the same case.
I have registered the domain using Route53 DNS service on one AWS account. I would like to use that registered domain on another AWS account, using it primarily for creating CNAME records for the load balancers. I have updated the NS records for the domain to match the second AWS account NS records and I am able to use and created hosted zone in that second account, but the CNAME or # records are not resolvable.
This can sometimes be tricky so I am going to cover the initial steps.
You create a new hosted zone in Account B
You add that hosted zones NS record in Account A. This is a new NS record in the master record (mydomain.com)
You then add an alias for your load balancer on your hosted zone in Account B.
It looks like you are doing all of this so a few other things you can check:
The security group associated with your ELB allow port 80 or 443.
The public subnets associated with your ELB have routes to the internet gateway.
The NACLs on your subnets allow port 80 or 443.