How to: remote cloud PostgreSQl database (Azure)

I have been trying to use a remote Azure PostgreSQL database but there is no documentation on this so I had to improvise and tinker, but in the end I got it running. Thought i’d share my experiences.

I have done the following things:

  • Changed the jdbc connection url in dhis.conf to the remote database.
  • Changed Azure PostgreSQL server parameters to dhis2 recommended settings, and max_locks_per_transaction even higher @256.

When starting the Tomcat Web application it starts provisioning the database and this takes a long time.

Initially it never finished an I encountered ‘out of shared memory’ errors in both the Tomcat and PostgreSQL logs and the suggestion to update the PostgreSQL server parameter ‘max_locks_per_transaction’ and set it to a higher level.

I had to make a support request to get a preview version of Azure PostgreSQL to be able to change this setting at all.

The setting of ‘96’, mentioned in the implementation guide still gave me errors, so I made it an arbitrary ‘256’. Now the initial startup and databse creation finished!

The connection url in dhis.conf should be:

jdbc:postgresql://.postgres.database.azure.com/dhis2?sslmode=require

This is when you configure PostgreSQL to require SSL, which you should IMHO.

Caveat for me were other web applications that use “?SSL=True” for this, which was something that didn’t work for dhis2. Different JDBC driver maybe?

I have no idea of performance yet.

[EDIT] performance is horrible (-: Tomcat is running on a Windows VM with 2 cores and 4GB and clicking any menu leads to 100% CPU and time-outs…