Prisma1: Prisma RAM usage

Created on 13 Nov 2018  路  23Comments  路  Source: prisma/prisma1

Describe the bug
It seems that Prisma is quite resource hungry. I've just deployed a Prisma server to Heroku, and I'm being flooded with R14 errors, with memory usage being around 600MB.

I believe Prisma runs on Java, which might explain the high RAM usage, but is there any way of reducing this? It effectively means that one needs a quite large container instance to run it, starting, for example, at a whopping $50 on Heroku for a machine that can actually handle Prisma without resorting to memory swapping.

To Reproduce
Steps to reproduce the behavior:

  1. Host Prisma server on Heroku
  2. Do something on it
  3. Watch the R14 errors flood the server logs

Expected behavior
That Prisma could at least suffice with sub 512mb ram, as that seems to be the RAM limit for a lot of provider's pricing breakpoints

Versions (please complete the following information):

  • prisma 1.19.3
bu2-confirmed areserver kinbug

Most helpful comment

We are currently rewriting Prisma in Rust which will mitigate all of the RAM usage issues.

See: https://github.com/prisma/prisma/blob/master/ROADMAP.md#implementation-phase

All 23 comments

I had the same problem using prisma 1.20.1.

Encountering the same issue on 1.21.0

@jhalborg At least the problem was solved upgrading Heroku dyno plan? I am worried because I have this error and my application is not even live yet...

I resolved my issue by upgrading from a $5/mo digital ocean plan (1GB RAM, 1vCPU) to a $20/mo plan (4 GB RAM, 2 vCPUs). And yes my application is not live yet either, this is just from my own testing usage.

The usage was bad enough that it was causing issues even connecting to the server (ECONNREFUSED errors). These have gone away after upgrading my resources

I just had the same issue with Linode. Prisma runs on Java and it collapsed my 1GB RAM server.

I resized my Linode to 2GB but the support guy (thanks Pat 馃憢) told me it was a temporary fix as it seemed Prisma runs some very memory intensive tasks.

Are there any plans to improve memory consumption?

Has anyone confirmed that Prisma actually needs this much memory to run or is the JVM just taking this much and Prisma happily uses it? ie. can we configure the JVM to run within 512MB and Prisma still does just fine?

I haven't dove deep enough into Prisma's docker image to start messing with the JVM settings but maybe someone else has?

I restricted the mem_limit in docker-compose.yml to test if Prisma or its JVM looks at available memory of the container and constrains itself accordingly. It does not. Even for a tiny test site Prisma dies with anything less than 650MB.

For me this is Prisma's only major drawback. I can't use it for very small cost-constrained sites without extra pains.

Well, this, and the lack of proper migration up and down support. And the quite involved setup needed to perform horizontal scaling.

But the pros still outweigh the cons in my opinion :)

I resolved my issue by upgrading from a $5/mo digital ocean plan (1GB RAM, 1vCPU) to a $20/mo plan (4 GB RAM, 2 vCPUs). And yes my application is not live yet either, this is just from my own testing usage.

The usage was bad enough that it was causing issues even connecting to the server (ECONNREFUSED errors). These have gone away after upgrading my resources

Same here. I'm the only one uses the backend now and whole database is probably less than 512KB!
Even with such a simple data, it uses 400MB of RAM at the moment and I sometimes see it goes up to 1GB. It runs mysql too and in total, it doesn't suffice to use $5 machine even for testing.

I'm quite skeptic if I should continue to use Prisma for a production app. Would like to hear from the team!

I'm running a production instance for a small project on Heroku and it's constantly using ~700 MB of RAM. This is ok-ish for now as Prisma runs stable but the flood of R14 warrnigs is worrying me.
I've tried limiting the JVM heap size to 300MB (JAVA_OPTS=-Xmx300m) but it doesn't help.
image

i just deployed prisma version 1.23 on aws elastic beanstalk

i'm using a t3.micro ec2 instance

screenshot from 2019-02-03 07-37-37

using docker stats to fetch info about memory usage

prisma use about 350 mb in idle state and i set a limit for it to 600

in the picture
the first row is for application itself
second row for prisma server
third is for aws-agent (related to ealstic beanstalk)

We are currently rewriting Prisma in Rust which will mitigate all of the RAM usage issues.

See: https://github.com/prisma/prisma/blob/master/ROADMAP.md#implementation-phase

Very excited for the Rust implementation. This would allow me to use Prisma in a lot more projects. I do a lot of remaking old software by virutalization/cloudifying the same functionality. This requires a lot of horizontal scaling of small instances. Prisma currently sucks at this because each instance is minimum $20/month.

is there a way to limit the RAM in the configuration ?

Any workaround besides scaling up on memory? if not, I think this should be stated somewhere in the docs (happy to help). Basically just say "If you plan to use prisma in production don't use less than 2gb of memory". Would've helped to know this before building it into a production app that I assumed only needed a $5/month droplet.

We are currently rewriting Prisma in Rust which will mitigate all of the RAM usage issues.

See: https://github.com/prisma/prisma/blob/master/ROADMAP.md#implementation-phase

is this still being worked on?

@MaxAst

See the increasing amount of Rust code in the repository 馃憖

I noticed that this was removed from the roadmap. Does that mean that it is finished or that it is not happening?

https://github.com/prisma/prisma/commit/e33a36b9775a7f4027ad5dea0fbe47f62919da1e#diff-38574c080d4e2eb38c49b86e6588ad98L43

@respectTheCode Sorry for the confusion! We're indeed still working on the Rust rewrite (and are making great progress). The bullet on the roadmap was a bit redundant with the point of making "Prisma available as a standalone library". I just re-added the point to the roadmap for clarification, thanks for pointing it out 馃憤

I solved this problem by migrating to Prisma2.

I have a very small project with Prisma but ends up over $20+ with aws Fargate (the project was not even put online yet, just a few queries). This is absolutely a pain. Before I replace Prisma with Restful API, I just installed Prisma2. After inspecting the db, manually alter the generated schema to fix some issues, and alter the resolvers, everything just worked!

If you don't want to pay a bill for prisma server or switching back to restful API, this is the tip for you.

Thank you @tylerstar.

I've planned to migrate to Prisma2 when the prod release will be available.

Great to know that migrating is fixing this issue thought

Is there any way to tell the JVM that it should respect the limits and does not hog memory? There are few parameters for JVM suggested everywhere, including these two,

-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap

I have searched it within the repo and could not find it anywhere. Can anyone help me applying these parameters to contain the prisma server within 100-500MB ram limit and not go wild upto 3GB.

Prisma1 is super slow when there is a large amount of data. And I'm not moving to Prisma2 either so that I won't run into the same problem. I wish the team would have some response with Prisma1 performance rather than just forcing us to move to Prisma2. Prisma2 is great, but when a project is large enough, we can't just migrate it easily. The migration would take more time than rewriting the app.

EDIT:

Hopefully, we won't be forced to migrate from Prisma2 to Prisma3 in the future.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marktani picture marktani  路  48Comments

sorenbs picture sorenbs  路  52Comments

marktani picture marktani  路  35Comments

blocka picture blocka  路  74Comments

marktani picture marktani  路  34Comments