NodeJs data-store persists only on one machine.

I have an express application that makes API requests to square services on behalf of theEcomerceSite.com. I’m using a data-store to store Access Tokens in my express applications. When logging the accessToken stored in the data-store it is only on one machine. How do I persist and use the same data-store for both machines?

So the VMs are not going to persist any in-memory or on disk storage.

To persist on one machine, you could mount a volume, and write to disk.

But volumes for Fly.io are 1:1 meaning on machine, gets 1 volume.

So to sync my SQLite DB across many volumes, I use LiteFS, and back it up with LiteFS Cloud.

You can also use Upstash Redis which fly offers with a free tier. As well as the semi-managed Postgres fly offers.

But you will need to store the data somewhere else besides that individual machine, since any restarts or scaling will wipe the memory, or anything written to a non-volume.

There are plenty of other solutions available, it depends on what you’re trying to do. Often these data stores have connectors to different technologies. For example, if it had a Redis connector, you may only need to provide a Redis DSN, and specify that connector, after running the command to spin up a Redis instance.

Hope that helps.

1 Like