We are using GeoServer with a geoserver cache for some layers. Most of our layer updates frequently and therefore we do not want to setup a cache for them (they do have in memory cache though).

First, we use different workspaces for different types/actions we want to perform and want to keep the different workspaces/layers separate, however they all connect to the same PostGIS database.

Now I am facing a problem where we have 15+ workspaces, each workspace has a connection pool (default 10) to the same PostGIS DB. So that means that our GeoServer instance is taking more connections that PostGIS has (100), also we do have other applications running on the same database.

The connection pool for each store has a max connections = 10, min connections=1, connection timeout = 10, evictor run periodcity = 30, max connection idle time = 30, evictor tests per run = 3.

I noticed that PostGIS has a lot of connections on idle and does not close them. What is the best way of connection GeoServer to a PostGIS database with the minimum connections? How can I force the idle connections to close without changing the max connections?

  • you need to go into the backend and explicitly terminate these idle connections you speak of
    – ziggy
    Dec 2 '19 at 19:23
  • @ziggy, thanks for the reply. Currently I do this, however, this is not maintainable as I cannot manually end these idle connections on a daily basis Dec 3 '19 at 8:25

The easiest answer is to increase the number of connections at the PostGIS end.

If you want to limit the number of connections used by GeoServer specifically, then you have two options:

  1. Reduce the max number of collections on each of your data stores. This will probably increase the load time for your layers.

  2. Introduce a single pool for all of the servlets in tomcat, to do this set up a JNDI connection pool in your tomcat server. You can then use this shared pool in all of your datastores.

  • As I understand with the JNDI connection pool is that your database should be a PostGIS JNDI database, I only have a PostGIS database, this database is also in the cloud so I do not have an SSH connection to the database. I thought of using a single pool (moving all the layers into a single workspace. But if I do this then I do not have the control on how much connections a particular "workspace" (in this case a layer) can use, so if we view one layer that layer will receive most connections and it won't be distributed evenly? Dec 3 '19 at 10:36
  • JNDI just describes how the connections are handled - there is no difference at the server end
    – Ian Turton
    Dec 3 '19 at 10:44
  • Ok Cool will try this out, thanks Dec 3 '19 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.