1

Consider a scenario, a web request makes N database requests. If I know that all or majority of the requests can be sent to db-readers. With Vitess's architecture, when there are multiple readers setup, wouldn't those N db requests get distributed to different db-readers?

When different readers have different replication lag, it is possible that N db requests result in inconsistent results.

Does Vitess have special ways of handling this? Or how should an application deal with such situation?

Bibek Shrestha
  • 32,848
  • 7
  • 31
  • 34

1 Answers1

1

Vitess now supports replica transactions. So, that's what I'd recommend you use if you want consistent reads from replicas. There's a longer answer below if you don't want to use transactions.

The general idea of a replica read is that it's a dirty read. Even if you hit the same replica, the data could have changed from the previous read. The only difference is that time moves forward if you went back to the same replica.

In reality, this is not very different from cases where you read older data from a different replica. Essentially, you have to deal with the fact that two pieces of data you read are potentially inconsistent with each other. In other words, if you wrote the application to tolerate inconsistency between two reads, that code would likely tolerate reads that go back in time also. But it all depends on the situation.

Sugu Sougoumarane
  • 406
  • 1
  • 3
  • 7