I am very new to cloud computing. I have never worked with MySQL outside of 1 instance. I am trying to understand how AWS RDS read replicas work with my application. For example say I have 1 master and 2 read replicas. I then from my application server send the query to AWS:
SELECT * FROM users where username = 'bob';
How does this work now? Do I need to include more into my code to choose a certain read replica or does AWS automatically reroute the request or how does it work?
Amazon does not currently provide any sort of load balancing or other traffic distribution across RDS servers. When you send queries to the primary RDS endpoint, 100% of that traffic goes to the primary RDS server. You would have to architect your system to open connections to each server and distribute the queries across the different database servers.
To do this in a way that is transparent to your application, you could setup an HAProxy instance between your application and the database that manages the traffic distribution.
Use of Elastic Load Balancers to distribute RDS traffic is an often requested feature, but Amazon has given no indication that they are working on this feature at this time.
Related
I'm new to cloud computing so this might be an obvious question. I have a desktop Java application that will connect to an AWS RDS MySQL database using JDBC. Is using the endpoint, username and password for the database the preferred commercial way of connecting to the database?
To encrypt communication I plan to use SSL.
You could open your database instance to the outside, using regular credentials. But, a safer way to proceed might be to create an endpoint in AWS, possibly running in Java, which would expose one or more APIs which in turn would hit the MySQL database running in RDS. That is, you would not expose the RDS instance to the outside world directly, but only internally to this API, also running in AWS. Then, your desktop Java application would talk to this intermediary application when it needs to access the database.
The advantage of this suggestion is that it lessens the risk of your RDS instance being attacked via something like DOS. Of course, the API you create on top of the database could also be attacked. But, Java web application running in a container (and other similar applications in other languages) were designed to be exposed to the outside, much less so database instances.
I'm wondering can we setup SQL Server inside Amazon Lightsail? So I don't need to purchase Amazon RDS Plan. What's the difference if I prefer Amazon RDS as my database instance?
I want to build simple Point of Sales web with node.js and there are only about 10 users which use it.
You can actually have your database hosted a couple of different ways with Lightsail.
Lightsail has a managed database option that is built on top of RDS, so if you don't want to have to install and manage MySQL you can just use the managed offering. It will likely be more expensive than self-hosting, but comes with the benefit of not having to manage the underlying system, optional one-click high availability mode, and automatic backups. Today the managed service only supports MySQL - but we've announced that we're adding Postgres shortly.
If you'd rather pay a little less, you can (as stated above) install just about anything you want into a Lightsail instance. So you could provision a Lightsail instance and install MySQL (or Postgres or Mariadb or whatever).
Now if you want to run MSSQL, there isn't a managed offering, but there is a blue print for SQL express on Windows server available as well.
You can install whatever you want on Amazon Lightsail, as long as it is supported by the operating system. Lightsail is just an environment to launch virtual machines.
Amazon RDS is a managed database service, which means AWS takes care of many things you need to do manually otherwise. With RDS you get managed backups, easy on-demand snapshots, automatic patching, the possibility to scale up and down in a simple way, and advanced monitoring, performance metrics, and alerts. You also get a nice API to control your SQL Server/MySQL instance.
I see a Lightsail managed DB as an inferior option to RDS. Their logging system starts from the top so it is close to useless, so you can only take advantage of backups and snapshots. Also, the free tier of Lightsail only lasts for 3 months, and then you pay 15 USD monthly for 1GB in RAM and 2 vCPU. The free tier of Amazon RDS also gives you 1GB in RAM and 2 vCPU for 1 year, but with much better features and more future-proof.
To connect RDS with Lightsail you can follow these instructions from the AWS blog. The important bit is modifying the inbound configuration of the VPC security to allow Lightsail IPs.
So, based on this, this is how we use databases with lightsail:
We install Postgres or MySQL directly on our dev or testing Lightsail instances, those don't need backups and can be recreated every build, so no need for an extra service or cost. You can SSH into your instance for debugging and monitoring.
We use RDS for production and maybe staging, since this will provides us with backups, good monitoring, etc.
We avoid Lightsail DBs because their logging and monitoring is close to useless and costs the same as RDS.
I have a staging server on AWS where my web application is running.the application uses Dedicated Database server(mysql/linux) from other provider. i would like to spin a new server on a AWS that should act like a proxy server to connect with my Dedicated Database server.
please advise me how can i achieve.
You can proxy the traffic with HAproxy, you can have one DB in active mode and one in passive mode, when ready to cut over you take the active one offline and ha will start sending requests to the other DB server.
Additionally, HAproxy will allow you to send traffic to certain DB servers depending on a variety of criteria, like the source IP. So some web apps send to one DB and others send to another.
HA proxy is very lightweight, we use it and run hundreds of thousands of requests a day without any performance issues.
Take a look at MaxScale from MariaDB. it a DB proxy. the can do all this and more..
https://mariadb.com/products/mariadb-maxscale
We have an ASP.NET MVC 5 web application that reads data locally from within the same server. This server is in Europe. However when trying to read the same data from an AWS server based in Sidney the lag is many times greater. A ping from our local server to the AWS server in Australia takes 5 seconds. The data needs to be located in Australia because of data protection laws issued by the Australian Government. The database is MySQL. We have created a VPN between both servers and made no difference.
What are our options in order to improve the speed between these two servers?
If it is a web application serving content to users over internet you can use CloudFront distribution to reduce your latency issues.
https://aws.amazon.com/cloudfront/
If you are trying to connect your servers from your data center to AWS
Use AWS Direct Connect, this will provide a dedicated link between your on-premise datacenter and to the AWS Servers; Decreasing your latency by a lot.
https://aws.amazon.com/directconnect/
AWS runs your application regardless of which platform(ASP.NET, JAVA, C...) it is, AWS only provisions infrastructure. You don't need to worry about the platform on which your application is running and what database it connects to. You just need to ensure that all the network connections are properly open so that your servers can communicate with AWS servers.
I want a database for my android stock audio store app. I will be storing my audio files on Amazon S3. I need a database for user info and audio meta data, for which I have created a MySQL database on my local pc but I don't know where to host it. Now, I need to know what is the difference between storing it on EC2 and RDS.
On EC2 you have full control over sql instance, have to manage it by yourself, set up replication if needed, and according to shared responsibility model you are responsible for any security issues.
On RDS your control is limited, AWS upgrades and patches the instance, makes backups, can set up replication, and is responsible for security (except if you compromise your passwords, of course).
Also, performance of the local instance may be higher because of no delay to network transfer, but it certainly depends on your ability to configure it and on EC2 instance load.