0

I am running a play framework application and a Postgresql server on a VPS which has 2vCores and 2GB of RAM and I'm having memory issues.

I limited my play application to 1024MB with the parameter :

jvm.memory=-Xmx1024m -XX:MaxPermSize=150m -verbosegc -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError 

Which lets 1024MB of free memory for Postgresql and some system processes but I'm having freezes with some pages of my play application and I don't understand why (these pages usually load a lot of data from the database but the objects themselves are simple and should not use a lot of memory).

When I have these freezes my application is not always using all the memory allocated by the JVM, so I'm wondering if it's not Postgresql who is creating this issue by using too much memory.

Indeed, Postgresql has several processes (more or less 20) and about 5 of them take 6% of the memory each.

When I installed Postgresql I didn't change the default configuration (I'm new to Postgresql).

Could you tell me if my theory of Postgresql making my application freezing seems plausible? If so, how should I change my Postgresql settings (and eventually the play application settings) so that everything is optimized for my 2GB of RAM VPS and I get no more freezes?

6
  • You're probably forgetting that the system needs free RAM for disk cache etc. Try to allow about 500MB RAM free if you can (the optimum actually depends on database size). Also, what's your work_mem and shared_buffers in PostgreSQL set to? Nov 17, 2014 at 2:39
  • I deleted my question on SO, I just wanted to be sure the question was in the appropriate stack. The current work_mem is 1MB, the shared_buffers are 16384 with a unit of 8KB (I don't know what it means) and the max_connections are 100. How should I change these settings for my 2GB RAM VPS ? Nov 17, 2014 at 9:44
  • That's 128MB shared_buffers and 1MB work_mem; that's pretty sensible for a small machine, and I would consider the defaults fairly appropriate. One thing to keep in mind when measuring PostgreSQL's memory use is that most tools do not correctly account for shared meemory, so they'll think PostgreSQL uses more shared memory than it really does by double-counting it. See depesz.com/2012/06/09/how-much-ram-is-postgresql-using Nov 17, 2014 at 9:47
  • Thank you, but then, what's wrong in my VPS? Should I just ask for a VPS with more RAM? Or is there something I can do? My application is freezing (all threads are blocked) when I call a specific action but I don't understand why because the amount of data loaded is not that big Nov 17, 2014 at 10:34
  • Impossible to say without lots of interactive debugging, IMO. You need to find the bottlenecks. If I had to guess with near zero information I'd say it probably has absolutely crap I/O performance, and that's likely being made worse by too many concurrent readers - try a smaller connection pool. Nov 17, 2014 at 11:21

0

You must log in to answer this question.

Browse other questions tagged .