When building something with docker deployed Prism...
# prisma-whats-new
b
When building something with docker deployed Prisma and graphql-yoga do you generally use subscriptions conservatively? Is performance a big part of that decision to make something available as a subscription or is it more about what would be nice to have on the front end?
d
in my opinion subscriptions are on the contrary something that can save your resources compared to back and forth communication
even the silly thing like a open connection vs sending full request/response payload is not so little gain
also the server can feel bit more relaxed when just waiting for something to happen instead of being constantly bothered by client requesting something
b
That is a good way of thinking about it.
d
unfortunately, subscriptions in Prisma are more like a infant in the crib, still dragging issues from Graphcool and even adding extra issues on top of that 😕
n
I am aware of this issue: https://github.com/graphcool/prisma/issues/1734. This is high on our list, and there is a workaround. What other problems do you see with subscriptions in Prisma, @Daniel K.?
d
well, nested subscriptions ? 🙂
n
What is a nested subscription?
d
sorry, I mean relation subscriptions ... I do remember this was a pain in graphcool with dummy fields updates and it's bit sad to see it's still present in Prisma
I was even asking here recently for some timeline ... https://github.com/graphcool/prisma/issues/146
n
Thanks for the reminder 🙂 It's on my list to respond there.
So with subscription filters and relation subscriptions in place, what would you miss for the super awesome subscription experience you're looking for? 😄
d
I suppose that with those two working it might be a really good experience 🙂 perhaps some more documentation and examples on dealing with those more robustly (not just return ctx.db.subscription) ... it's bit confusing there with AsyncIterator 🙂
l
It's also worth noting that, depending on the query and the need for instant data, polling can be more efficient.
d
hm, I cannot see how can that be true ... unless your poll intervals are in minutes and more ... in that case it's not really a realtime experience 😉
n
Also, sorry for hijacking this thread, @Bro. I think a lot of factors go into the decision whether to use subscriptions or something else for a specific use case. I have found GraphQL subscriptions to be great for use cases like chat or notifications, but polling or using other forms of real-time also has its place.
d
I am working on a game that's very time sensitive so having reliable source of realtime data is essential
l
Then you'll want to do more research
But if you need it this instant, then ws for the win
d
yea, basically every other second something is happening, cannot imagine doing that over polling, especially on mobile platform where you don't have such a good connection
l
Absolutely. Your use case is pretty unique and polling would not work too well
d
btw do you have some good read on why polling is generally efficient? I cannot imagine that establishing full request every time is less resource intensive then waiting for an event
n

https://youtu.be/PsjiL6Yl1ag

d
or video ... thanks 🙂
l
I don't have it on hand. There were a few articles on this last year. But there's overhead in maintaining a persistent connection. I'd also recommend looking at Elixir if you need concurrency with all of the sockets
d
I do have other web projects that will be realtime as well, but not that much, so I am thinking if polling might be a better option there ... maintaining a persistent WS connection is mainly about sending small heartbeat messages, hard to imagine it would be that big overhead instead of responding to a full request (parsing query, authentication, etc..)
l
You'll find out quickly what an idle WS connection cost if you have a lot of users, particularly with Node. When a client is in a game, you can reasonably assume that most connections will be active. But most websites will have 80% of their clients hanging.
d
I see, that's probably true, thanks for the insight
l
It comes down to users vs cost. That's why I recommend at least taking a peek at Elixir. It's built (well, Erlang is built) to handle this problem and it makes the connections negligible. Node with its GC can get very bogged down.
... that said, I'm going to run web sockets with Node. But if I have 5000 concurrent users, it's a wild success that I'm celebrating on my yacht. 🙂
😄 1
d
yea I heard about Elixir, but I don't particularly like Ruby like syntax 😕