AWS Data Transfer charges when using Heroku Rails app with Amazon RDS backend - ruby-on-rails

I have a Ruby on Rails app hosted on Heroku that has a PostgreSQL database that I have hosted outside of Heroku, in my own AWS account as an RDS instance. So Heroku manages my compute/app, and AWS directly manages my RDS. (The reason for this is because the cost is lower than buying the database on Heroku.) However, on my AWS bill, in addition to the RDS charges, I am seeing Data Transfer charges for bandwidth in the us-east-1 region. Heroku's EC2 instances and my RDS instance are both in the same us-east-1 region. I am wondering why I am seeing these Data Transfer charges, and if there is a way to mitigate them without having to stop using Heroku?
Thanks in advance.

If your instances / services are located in the same region but in different availability zones, there will be data transfer charges. This is called a regional data transfer and is charged $.01 per GB. There are variations and exceptions. Best to consult Amazon's web site to determine your exact pricing.
Pricing

Related

How to make a multi-regional web application architecture?

My server is in Sweden (DB, ruby on rails web app, nginx). Sometimes people from South Africa and Southeast Asia come to my site.
For these people, the site is very stupid. Ping from Southeast Asia about 200ms. I want to solve this problem. I have no experience with such situations.
CDN will not help because it is only for static information.
I thought I need to make three servers for each region (1 server 1 nginx 1 webapp 1 base 1 region) and configure replication between databases. But I was told it was bad. How then? Maybe Amazon Cloud with RDS?
If you're on AWS could use a Load Balancer with your service running on multiple availability zones.
This is the same on AWS or Google Cloud
There are however a few things to take into consideration, for instance:
where is your db?
is it distributed?
is your service DB hungry?
Every scenario is easy to solve on AWS just by clicking around; meaning adding your service to multiple availability zones is as easy as making your db available across multiple regions as well.
If your server provides a RESTful interface and you want to use AWS for any reason, I would recommend API Gateway, just because it already has an edge-optimization feature: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-basic-concept.html
"Edge-optimized API endpoint: The default host name of an API Gateway API that is deployed to the specified region while using a CloudFront distribution to facilitate client access typically from across AWS regions. API requests are routed to the nearest CloudFront Point of Presence (POP) which typically improves connection time for geographically diverse clients. An API is edge-optimized if you do not explicitly specify its endpoint type when creating the API."

Getting started with AWS backend for iOS

I've been coding on iOS for awhile. I'm getting started to use AWS as a cloud backend to store my user's data for my iOS app as well as a server that can handle real time event in multiplayer mode. I understand that there are many services like Amazon Cognito that allows user login via public providers, Dynamo DB that provides noSQL storage, EC2 that help me create server instances. However, I'm really confuse on how I can actually get started.
Here's some stuff that I really need help on:
I don't really want to use public providers like facebook for my users to sign in/sign up. I'd really prefer it if there could be relational database that is similar to how I cache data on local sqlite files using core data.
And I also need some help on getting my ID tokens for those services if I choose not to use cognito, or must I?
I would really appreciate it if you guys can give me some clues on how I can get started on these. Thank you so much! :D
Depending on how you expect your app to evolve there are several approaches you can take.
Option 1: Minimal scalability / low cost
All you really need is a single free EC2 micro instance. On the instance you can build a full LAMP stack in seconds. Once you have built it you can start writing an application to handle your app in your preferred language. Ruby is a la mode but any language will work. Your database will be stored on the actual instance. If you go with this route, one thing you should do is use an elastic IP address so that if your server ever goes down you can point the elastic IP to another instance. You should also periodically backup your server.
Option 2: Maximum scalability / variable cost
Use RDS to store your database. This will mean that any EC2 instance will be able to reach your data so you can have an unlimited number of servers. Then build an EC2 instance just like in option 1 but point your application to the RDS instance. Use a load balancer in front of your EC2 instance to scale up in response to changes in utilisation. And the elastic IP address should point to the load balancer.
Building a LAMP stack on EC2
Open the EC2 console
Select launch instance
Pick the Linux AMI offered by Amazon and a micro instance
Create a .pem key (keep is safe on your system or you will not be able to access your instance)
Select the default security group
Open your terminal window and type: ssh -i path_to_pem ec2-user#your_instance_public_address
In the EC2 instance type sudo yum update
Then type sudo yum install httpd24 php55 php55-mysqlnd mysql55
sudo apachectl start
You now can navigate to the public address of your instance in safari and assuming I did not forget any steps you should see the apache welcome page.

Heroku Hosting Rails

So I host with company X and have my domain on there. I deployed my app to heroku and pointed my domain at it. I can't wrap my head around if I am hosting my site on heroku now or if I am hosting it on company X's servers.
I would assume I'm hosting on herokus server because that is the most logical, but just keep having this brainfart.
Could someone please explain this to me?
Your application is on Heroku's server. All company X has done is perform the DNS magic necessary to map the friendly URL (www.yoursite.com) to your Heroku deployment.
Amazon
You should also be aware that Heroku doesn't actually "store" the app on its own servers - it uses Amazon's ec2 cloud to create instances of your app
So although you have your domain with company X, your app handled through heroku, it will actually be running in one of Amazon's data centers
Keep that in mind when you start to grow (you may find benefits of using Amazon directly)

What plan(s) are needed to get Rails set up on AWS?

I'm new to Amazon's cloud though I have used other cloud provides like Rackspace, Windows Azure and Heroku. I want to deploy my Ruby on Rails 4 application on Amazon but I am overwhelmed with all of the services Amazon offers. AWS, EC2, EBS, S3, SimpleDB, Elastic Beanstalk.... argh!!
My site is a relatively simple Rails app with a Postres database. There will not be much traffic at launch but we obviously hope it will grow and need to scale up.
What is a simple, no-frills plan that Amazon offers to get my app out there? I feel like I need to read 100 pages of documentation just to understand what it is that Amazon is offering.
First of all, there are no plans. You sign-up for an AWS account, and you have access to whichever services you want to use.
Secondly, I can wholeheartedly recommend a single-instance Elastic Beanstalk environment to get started. It only uses 1 EC2 virtual server behind the scenes, but you get much better deployment options.
I can't speak to other services like Heroku.

Amazon SimpleDB vs Amazon RDS

I work at a small ecommerce site and we're looking to move to all Amazon hosted services and I'm unsure the exact difference in RDS and SimpleDB. RDS can use MySQL, can SimpleDB not?
Simply put, I would assume that because your business model is e-commerce that you need transactional consistency in your data solution. Because of this, you should choose one of the RDS options (these are MySQL, Oracle or SQL Server).
AWS SimpleDB is a non-relational data store (or NoSQL), so what you get is flexibility (i.e. schema-less or schema-light) and scalability, but what you don't get is immediate (transactional) consistency and also the query pattern will not use joins.
RDS is basically a relational database in the SQL vein, whereas SDB is a non-relational database. I'd recommend reading through all the info on the Amazon Web Services (AWS) site, as they answer all the questions you might have.
From the AWS FAQs:
Q: When would I use Amazon RDS vs. Amazon EC2 Relational Database AMIs vs. Amazon SimpleDB?
Amazon Web Services provides a number of database alternatives for developers. Amazon RDS enables you to run a fully featured relational database while offloading database administration; Amazon SimpleDB provides simple index and query capabilities with seamless scalability; and using one of our many relational database AMIs on Amazon EC2 and Amazon EBS allows you to operate your own relational database in the cloud. There are important differences between these alternatives that may make one more appropriate for your use case.
More information about AWS database options

Resources