postgresql

I am actually doing a side project which you will heard of very soon. For this project I am using Play! Framework v2 with the server side being developed in Scala. To efficiently push this new application to production, I am using the Heroku platform

While my initial thoughts were using MySQL as my relational backend, the default stack provided by Heroku made me switch to postgresql that I have barely used in the past. I attempted to set it up on my machine, but with no luck, Mountain Lion is bundling an old version (8.4) whereas I wanted the same as on the Heroku platform. My first attempt with Homebrew was quite a disaster, I never managed to correctly connect my newly created user.

After a few hours mumbling, I looked for an alternative to the Homebrew version. Luckily, the guys at Heroku provide a neat application Postgres.app to drop that allows to quickly start/stop a postgresql server. My problem was I didn't had enough connections to allow my application to start, I was always getting this message : remaining connection slots are reserved for non-replication superuser connections.

I edited the configuration file

vim "~/Library/Application Support/Postgres/var/postgresql.conf"
to bump the number of connections to a lot more (20 instead of 10) but it prevented my server to start. With a lot of file editing and restarts, I found that the limit for my machine was 11 connections.

The solution to this problem resides in a special setup of the mac os kernel which defines the amount of shared memory a process can allocate. To get rid of this, you can edit your /etc/sysctl.conf file (root required) and put the following lines (it will persist across reboots)

kern.sysv.shmall=65536
kern.sysv.shmmax=16777216

Credits for this tip comes from http://ruby.zigzo.com/2012/07/07/postgresql-postgres-app-and-a-gotcha-on-mac-osx-lion/

I came across this link representing a visualization of programming languages usage based on a hashtag collect : http://www.ioncannon.net/projects/code2012/

Although this method can be criticized, it provides interesting data : JavaScript is the clear winner with Java just behind. We can see Scala is a growing language too, it has been used more than PHP last year (according to this study).

If you find another study on this topic don't hesitate to comment this blog post to let me know.