D
Deno

help

How are deno processes/isolates managed in Deploy?

PHPatrick (he/him)5/26/2023
Hi, I'm writing a multiplayer game in Deno and currently all of the game state is kept in module-scoped objects, there's no database or any other form of persistence, yet. It all works as expected when I'm developing locally, but sometimes when testing in Deno Deploy, it's as if there's multiple instances of the game running and which one I'm connecting to is random (using the same URL.) Does Deploy create multiple simultaneous isolates for the same deployment? Is the only solution to implement external storage and make that the source of truth?
ABTAndreu Botella (they/them)5/26/2023
My understanding is that Deploy creates one isolate per edge server at a time, and it can kill them when they haven't been used for some time if you need to persist state, you would need to use some external database, or Deno KV
PHPatrick (he/him)5/26/2023
well to clarify, it’s fine if it looses state after a certain period of inactivity. That’s more of a feature than a bug for me. What I’m describing happens within a short interval.
ABTAndreu Botella (they/them)5/26/2023
well, that "some time" I mentioned could be as low as one minute apparently
PHPatrick (he/him)5/26/2023
hmm yeah I guess that could be it. Though it doesn’t explain how the sometimes the state is reset, then on a subsequent page reload the old state is back. It seems to alternate between different instances also I think this window is more like a few seconds max
ABTAndreu Botella (they/them)5/26/2023
maybe it could be that you're about halfway between two isolate regions, such that sometimes your requests go to one edge server and sometimes to a different one idk
PHPatrick (he/him)5/26/2023
hmm that’s a compelling explanation. Seems like I need persistence
ABTAndreu Botella (they/them)5/26/2023
also, even if your requests usually end up consistently on some edge server, they will be routed to a different one if that one is down so even then you can't rely on isolate-local state
PHPatrick (he/him)5/26/2023
for anyone interested, this seems really useful and relevant for keeping the various region/isolates in sync https://deno.com/deploy/docs/runtime-broadcast-channel e.g. https://github.com/denoland/tic-tac-toe/blob/953417adef97e7c232ea4ddb4d9de0fba3392e76/utils/db.ts#L3
GitHub
tic-tac-toe/db.ts at 953417adef97e7c232ea4ddb4d9de0fba3392e76 · den...
A global, real-time multiplayer TicTacToe game for Deno 🦕 - tic-tac-toe/db.ts at 953417adef97e7c232ea4ddb4d9de0fba3392e76 · denoland/tic-tac-toe
PHPatrick (he/him)5/26/2023
ok, this seems like a smoking gun to me. At least I can't think of any way to explain this other than that Deploy is running multiple instances of the app in the same region and routing between them randomly (or by some method I don't have any awareness or control over). The logs show info about clients connecting and disconnecting, along with the region and the timestamp. Each client is assigned a monotonically increasing identifier but yet I'm seeing a count that jumps from the 50s to 0 and back into the 50s.
IioB5/27/2023
Deploy is running multiple instances of the app in the same region and routing between them randomly
yes?
PHPatrick (he/him)5/27/2023
I guess I just wanted to confirm that this is normal
IioB5/27/2023
Ah okay sorry, I was confused on the intention of your message I realize I should have read the rest of the thread 😅
PHPatrick (he/him)5/28/2023
continuing this train of thought, as a half-baked idea: https://discord.com/channels/684898665143206084/1112472416854216835

Looking for more? Join the community!

Recommended Posts
Cannot access web server from other network devices when compiledHello. Im kinda new to deno and i just compiled my first bigger project with deno, but when the taskHow to use chrome devtools / inspector with Deno?Hello all! I'd like to profile my game server written in Deno to identify the hot spots. I see thaClear local KV storeHow do I delete/clear the local database?Deno.Command not working for applicationHello. Im trying to start an application using Deno.Command, but it for some reason doesnt work. TheUint8Array or Float32ArrayIs there any significant difference between using a Float32Array and using a Uint8Array from the samSending proper Content-Type depending on file sentHello. Im new to Deno and TypeScript and i wanted to convert one of my older projects (NodeJs and JaReclaim an already registered module?Is it possible to reclaim an already registered third party module? For example if the module that iDeno.readDir on current script even if used like an http package.Hello !! I would like to do Deno.readDir and readFiles on files relative to the script that execute Top level awaits for `import()`How come to top-level awaits for `import()` not work? I found an issue on GitHub https://github.com/How to auto import on save?This doesn't work: { "deno.enable": true, "deno.lint": true, "deno.unstable": true, "editorRemove sink from streamIs it at all possible to "undo" adding a sink on a stream? I am trying to make it so that once the wHTTPS w/ client certificate – works in Node.js, not in DenoI am making an HTTPS call with a client certificate. It works great in Node.js, but when I try to doUsing encrypted private keys with DenoSo it seems to me that Deno doesn't provide any helpers for making HTTPS requests with encrypted priError when using readline.question()I get this error with the following code ```ts import process from 'node:process' import readline fjsx in denoHi, I have simple code that takes use of jsx. Based on deno docs, the jsx support should be ootb. IsExpress pt2 tutorial links to itselfAt the very start of the tutorial, it mentions that part 1 got up and running, but the link points tonboard is infiniteSeems like the onboarding process is broken and won't stop repeating itself You need to be a new memDeno mobile app?Anyone has made a mobile app using deno? I was planning to use Fresh and https://capacitorjs.com/ tWhat is the best way to count values with Deno.Kv?I want to show the total values in the database. It seems that the only way is with `kv.list()` and Does kv delete recursively?For example, if I have entries with keys: `['users', 1]`, `['users', 2]`, will `kv.delete(['users'])