Akash
Akash2w ago

Is it a good idea to use Deno edge functions as a websocket server?

For my app I am sending and receiving audio to and from my server. As I want to closer to my users I want to use an edge server but are deno deploy functions designed to handle websockets (being ephemeral servers)?
3 Replies
raunioroo
raunioroo2w ago
Deploy functions are "short lived", so you can't count on them having any particular lifetime. To my knowledge, in practice the typical lifetime is somewhere between minutes up to an hour or so (?). So you need to design your app in a way that it can easily reconnect to another instance, and assume connections are short-lived (or rather "medium-lived" compared to some other edge services). I think it should be doable given those limitations.
Akash
AkashOP2w ago
Minutes to an hour should be doable for my use case. Bc I am using the websocket only for short-lived bidirectional audio transmission (like a phone call). On the pricing page it says per request a max of 50ms is permitted on the FREE and PRO versions. https://deno.com/deploy/pricing Do you know if there is a way to calculate that and see if I am crossing that limit?
raunioroo
raunioroo2w ago
The 50ms limit is pure CPU time; waiting for IO, network and stuff is not counted towards that limit. I don't know if it can be calulated and/or how that applies to longer websocket connections since the limits are "per request" so is over the whole connection time or what. Hopefully someone else with more deploy experience can chime in.

Did you find this page helpful?