Is it possibly for a client to connect to a particular instance

Usecase:
Assume a game server which is keeping some local state (in memory). If users joining the same room/game are connected to the instance that holds this state, things will be much faster, else if they connect to a new instance, they will have to somehow sync state from a
persistent datastore.

In case of multiplayer games, it is quite possible for players to be joining from very different geos. Usually a single game server closest to the largest cluster of user is selected to run the game logic.

Hi there,

Would it be acceptable if sending a special header like fly-instance-id to your http requests would only route to a specific instance?

I’m assuming you’re using the “http” handler for your app. If not, then adding this feature might be a lot more difficult.

Isn’t this already possible via IPv6 if the external_port feature flag is on? Or does the question relate to IPv4 only? Since this is a game IPv6 might be possible, no?

@hi.kanily We’ve now added a functionality where if you add fly-force-instance-id header to your request, with a value containing an instance id, we will forward the request to that instance only. This should also work with websockets and upgrades if the original request was made with the aforementioned header.

This is a bit of a footgun: we will not try other instances when you provide that header. If the instance is down, the connection will probably hang for a little bit and then close.

2 Likes

@sudhir.j it is possible with the external ports feature, but a shocking number of game clients don’t have IPv6. This’ll let people do gameservers through a single IPv4, we should setup a demo app with: https://colyseus.io/

interesting. I haven’t really deployed anything yet, but was trying to evaluate how to use Fly. Thanks for the quick support!

@jerome, would it be possible to do something like fly-prefer-instance-id instead of fly-force-instance-id. That would be more graceful and send the redirect to another instance if the one requested is dead. Or is that a technical difficulty you mean?

@sudhir.j, will look into IPv6 - but I admit I am ignorant about it, and it’s adoption. So off topic question - do all mobile service providers typically support IPv6 on their 3g/4g networks? Is it possible that some clients may not be able to connect at all as they are on some ‘older’ network?

1 Like

Is there any documentation about how we can reach a specific instance with the external_port feature? I too am interested in setting up geo replicated databases.

There aren’t really docs, but there are rough instructions.

Let us know what you’re thinking and where you get with geo replication! We have some features coming that should help with that, but we’re still trying to learn the best way to attach databases to apps that run all over.

1 Like

@kurt My “master” database is actually going to be hosted on GCP because I’m using Cloud SQL. So what I’m thinking for my persistent data is to use badger, which is a simple key/value database. From here I’ll probably just set up a cron job to retrieve the data.

Rather than opening up another thread for this, can you tell me how persistent storage works and what kind of limits I might face? I’m deploying a ~20mb docker container so my starting point is pretty low. If you want me to open a new thread let me know.