1

Imagine two cases:

  1. I have web server running in an EC2 instance and it is connected to the database in the RDS, the managed database service.
  2. I have web server and database running in the same EC2 instance.

Is my database in RDS going to be slower to access because it's not in the same machine?

How many milliseconds, approximately, does it add to your latency between the two?

Does this become bottleneck?

What about other managed database services like Azure, GCP, Digital Ocean, etc? Do they behave the same?

2
  • Have you tested it yourself? What happens when you need to scale out either the web server or your DB? Apr 29, 2021 at 18:51
  • Your latency across the AWS network will obviously be higher than latency within the machine, but I guess the latency would be in the order of 1-2ms, maybe less. Unless you're doing a lot of database requests for each user request I doubt this would be significant. You could test this or search for "RDS network latency" if you want to try it. This kind of separation is often necessary for scaling.
    – Tim
    May 4, 2021 at 22:57

1 Answer 1

1

Managed databases are supposed to be accessed via network. And yes it is true that your system will have latency if your database is on a network. But this latency depends on provider and network you're working on. When you use services from different providers, the latency is high. When you are using the services by single provider (say aws), it reduces. Best results are achieved when the servers are physically as close as possible say in single region. You need to benchmark these and see for yourself if the latency works for you.

On the other note, I've never encountered this latency affecting performance of my application. I've been using RDS instances since fairly long time to say I never had second thoughts about having db in same EC2 instance. With Go under the hood and Postgers RDS instance, my health check http requests fall under 20ms response time. Let me tell you that this is health check is also checking a SELECT 1 query success on db.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .