hey, quick question about running Prisma in Server...
# orm-help
l
hey, quick question about running Prisma in Serverless functions: I have an IoT pipeline that currently feeds events and states through a Cloud Function based on PubSub publications. Each function spins up Prisma to read and write data coming down the pipeline. However, sometimes I get a huge amount of data all at once and then i've noticed data getting lost due to an uncaught error:
Copy code
Error 429: Quota exceeded for quota metric 'Queries' and limit 'Queries per minute per user' of service 'sqladmin.googleapis.com' for consumer
I assume this has something do with Prisma connections or maybe just the way that prisma connects into CloudSQL. I've got a work around at the moment that retries the functions after 60sec to sort the bottleneck, but maybe if someone has experience with a Cloud Function > Prisma > CloudSQL stack then they might have run into the same issue?
👀 1
a
Hello Lloyd, can you describe your current stack? Are you using Cloud Functions -> Prisma ORM -> Google Cloud SQL? Are you using the data proxy, by chance?
@Lloyd Richards I googled for that error and came across this Stackoverflow post. It seems the issue key is here (see screenshot). I am not very familiar with GCP but the user seems to have been able to resolve the issue by using a VPC connection that does not rely on that rate-limited endpoint. Another option I can suggest is to try using our Data Proxy. The Data Proxy should reduce the number of connections opened to your database. It can be used from GCP without issues - you’ll have to use the static IP feature. For now we only support us-east-1 and eu-central-1, so if your deployment is far from that you might experience higher latencies in your requests. We welcome requests for new cloud providers/regions in this form.
I am on the product team at Prisma. If you are up for a call, I’d love to learn more about your use case. Feel free to book some time with me here: https://calendly.com/alberto-prisma/pdp-45-min-zoom-call
l
Thanks, i had seen the same stackoverflow as well but since i don't have as much control over the containers with Cloud Functions, i wasn't able to do much with their suggestions. I hadnt looked at Data Proxy, but will check it out and see. At the moment everything is european-east1, but i'll first have a look at DataProxy before making any requests incase its not a fit. My thought at the moment is because Prisma is signing in with a single user, even when the Cloud Function scales each instance is technically the same user which is causing the rate limit. I might have to move things over to Cloud Run like the Stackoverflow so i can better control containers, but i don't think thats a long term solution. Right now we have around 1-5k events happening on the system over 40 devices. Later when we have thousands of devices, this really won't scale. Stack Pipeline: PubSub -> Cloud Function -> Prisma -> CloudSQL Backend: CloudSQL -> Prisma -> Nexus -> GraphQL -> ApolloServer Frontend: ApolloClient -> Next.js -> Firebase Would love a chat, so have filled out a time slot :)