I made a mistake with my litefs setup and the noe GET requests were trying to be preformed by the replica instead of the primary. I believe that I needed to add the following to my litefs.yml file:
# This section defines settings for the option HTTP proxy.
# This proxy can handle primary forwarding & replica consistency
# for applications that use a single SQLite database.
proxy:
addr: ":8080"
target: "0.0.0.0:8081"
db: "db.sqlite"
passthrough:
- "*.ico"
- "*.png"
The problem im facing is that the load balancer is always bringing me to the primary region verus the replica region. Is there any way i can force this without taking the primary down?
Hey Ben, I am in Vancouver, so I believe the closest region would be sea (Seattle) which is my replica and my primary is in Chicago (ord). I would assume that it would connect me to Seattle but it does not. I was wondering if there was a way to force this just for testing purposes, I can’t submit the app again if it’s going to have the same load balancing errors. Thanks!
This may be a dumb question but if the region is preferred, can requests can still go to a sever that is not preferred? In this case, I want to protect against writes being allowed to be performed at all on the server due to the obvious error. Is there a way that I can handle this?
@gilboBaggins You can’t force requests to go to a specific region from the client side, however, you could update your server so that it returns a fly-replay response header and that’ll force the region.
I saw this written in WAL Mode in LiteFS on the Fly.io blog:
In the next release, we’ll be focused on making LiteFS easier to integrate into your application by adding support for write forwarding. That will let you write to your database from any node and have LiteFS automatically forward those writes to the primary instead of having your application redirect writes.