Prisma 1 Forum

Using Prisma / Yoga subscriptions with horizontal scaling?

I’ve really been enjoying Prisma for my app’s CRUD operations. However, subscriptions are a little bit fuzzy for me.

A requirement for my client is horizontal scalability. I’m planning on using Kubernetes to achieve this, and, as I understand, we simply need to host a RabbitMQ server and point Prisma to its url. I’ve read that more docs are coming soon for that topic, so that’s all great!

Now, my next question is more general. If I have a public facing Yoga instance, and we need to be able to scale that horizontally as well, how do I ensure subscriptions will work properly? It seems like this opens up a can of worms, as users would need to be routed through not only the same Yoga instance but also the same Prisma instance in order for the websocket subscriptions to work. Am I correct in this assumption?

Is there any recommended way to deal with this problem? I could spin up a separate service for the real-time functionality and have those containers be backed by redis or rabbitMQ, then simply talk to it with basic websockets from the client, but we’d rather keep everything in one place, and - more importantly - using GraphQL.

What do you guys recommend? :slight_smile:

Hi! I’m also interested in this topic.

I guess if you setup horizontal scaling with RabbitMQ in the Prisma layer then all your Yoga/Node instances could, theoretically, subscribe to database changes and forward the necessary events to the clients. This way, an extra PubSub is not required if the data comes from the database. Not sure if it’s possible/easy since I don’t know too much about GraphQL subscriptions yet :confused:

I’d like to do horizontal scaling for my Prisma server in Zeit Now but I fear it might not be possible due to Prisma’s management API requirements :thinking:

This thread is over a year old. I am interested in this topic also, as well as horizontal scaling. I am trying to deploy prisma to GCP GKE and use a CloudSQL (Postgres) DB and am struggling to find information on how to get this set up successfully.