whats the frequency of the letter r in:
q: how to get a static ip for an ec instance? or, how to use i am just setting our rails app on amazon aws. we have 2 ec2 instances, one for the rails app, the second one for redis. and then amazon rds for mysql.
when i connect our rails app with redis, i need to set the redis url, which contains ip address. however, if i restart the redis instance, its ip address will change and the redis url ip i entered to the rails app for redis will not work (because after restarting the redis instance was generated a new ip).
how to handle this behavior? how to avoid loosing ec2 instance when restarting it?
the same probably goes for amazon rds - this is how i set the host in database.yml:
  host: myapp-production.cg4mxcg62ca0.us-west-2.rds.amazonaws.com

thank you in advance.

a: issue 1:
elastic ip addresses should not be used to preserve the address of a back-end server. there are 2 reasons:


*

*usually, you do not want back-end servers to be exposed to the internet and elastic ip addresses only work from the internet into your ec2 instance.

*if you connect from one ec2 instance to another ec2 instance by its elastic ip address, then the connection leaves your vpc and re-enters the vpc. this makes security harder and will incur data traffic charges.


instead, you should reference your back-end server by its private ip address. stopping and restarting an ec2 instance will not change the private ip address. only when an ec2 instance is terminated will the internal ip address be released. and when you launch an ec2 instance, you can optionally choose its private ip address.
you can create a dns entry (route 53 private hosted zones) for your back-end server.
another thing you can do, but its not required, is to create a network interface with your private ip address. then attach that network interface to the ec2 instance. if you need a new back-end server, then just move the network interface to the new instance and the private ip address will move with it.
issue 2:
rds instance endpoints do not change over time.
also, rds instances cannot be stopped. they can only be deleted. but, even if you delete an rds instance and re-create it, if it has the same rds instance id, then its endpoint will remain consistent.
so its safe, and best-practice, to reference your rds instance by its hostname myapp-production.cg4mxcg62ca0.us-west-2.rds.amazonaws.com.
final thoughts:
put your redis server and your rds instance in private subnets in your vpc. there is no reason why the public needs access to them. your rails app instance should be in a public subnet because the public will access your app through that instance.

user
I found 141 "r"s in the provided passage.
assistant