denoland / deployctl

Command line tool for Deno Deploy
https://deno.com/deploy
MIT License
352 stars 58 forks source link

Is there a way to specify a single region for deployment? #345

Open nicolaefilat opened 3 weeks ago

nicolaefilat commented 3 weeks ago

I do not want to deal with a distributed database. I just want to store some dictionary in memory on the server to act as a simple in memory db. However, this does not work because the code gets deployed on 12 regions and the state of the dictionary is not distributed to all regions. I would like to deploy to a single region if possible.

magurotuna commented 3 weeks ago

No, there is no way to specify a particular region to deploy to. Also keep in mind that even if we supported single-region deployment, it would still not be guaranteed that your dictionary saved in the local memory is sharable and kept in sync, because the execution unit, which we call "isolate", can be spawned multiple times or evicted at any point in time.

For your use case, have you considered Deno KV? It's built-in on Deno Deploy so you can use it without any setup. This provides you with globally distributed key-value store, which I believe suits your needs.

nicolaefilat commented 3 weeks ago

I think that Deno KV is an overkill for my use case.

magurotuna commented 3 weeks ago

Can you elaborate a little bit more on your use case, so that we can give more concrete suggestions?

Like I mentioned, because Deno Deploy is designed to be scalable even in one particular region, we (as Deno Deploy users) cannot really control not only when a new isolate is spawned but also when an isolate is evicted by the hypervisor. Given this nature, any data stored on the local memory in an isolate (such as top-level declared variable like let myMap = new Map()) is ephemeral and volatile. So I guess in order to satisfy your needs, some way of data persistence is required. In Deno Deploy, Deno KV is the easiest way to achieve data persistency.

nicolaefilat commented 3 weeks ago

I ended up self deploying on my own server with a top level declared map as let data = {} and it worked fine. I did not want to use Deno KV because I felt that is a bit too much for what I actually need. I just needed to store some data for a short period of time to cache it and then I would remove that data. Using a distributed database for such a task in my opinion shouldn't be required.

I guess that your deploy setup makes it difficult to guarantee that a process will not be killed / restarted in the meantime.

I have used Heroku before as a deployment service and I did not run into issues when using global variables to store data in RAM.

I really like Deno and Deno deploy. However I think that there should be a way to just keep some global state in RAM on a single region.

My use case of Deno Deploy is not really for scalability or performance, I want to have a simple free deployment without much configuration.