CockroachDB + GeoServer = Horizontally Scalable Spatial Apps
In this brief tutorial, learn how to integrate CockroachDB and GeoServer.
CockroachDB is a relational database that looks very much like PostgreSQL but with the added benefits of horizontal scalability, zero-downtime upgrades, and the ability to survive the loss of a node, an availability zone, or even an entire cloud region. With its recently added spatial capabilities, which are very closely aligned with PostGIS, developers of spatial applications now have an option for when they need a scale out data store. GeoServer is a popular open-source server that allows users to edit and display spatial data. GeoServer is OGC compliant and interoperable with commonly used mapping software such as OpenLayers, Leaflet.js, MapBox, and Google Earth.
If you're curious about how to integrate these two technologies, please read on. The process is very much like adding PostgreSQL as a vector data source, with the exception of the two details I'll elaborate on below. First, you need to log into the CockroachDB instance via a SQL client as a user with "admin" credentials, then make the following change:
SET CLUSTER SETTING sql.spatial.experimental_box2d_comparison_operators.enabled = on;
Second, in GeoServer's "New Vector Data Source" view, you'll select “PRESERVETOPOLOGY” on the “Method used to simplify geometries” drop-down control, as shown in the figure below.
With that out of the way, CockroachDB and GeoServer are integrated. From here, working with your spatial data would look very much like it does today if you're using PostgreSQL/PostGIS. Here's an example of importing a Shapefile into CockroachDB, which you could then publish as a layer in GeoServer.
That's about it — pretty easy to combine these two amazing technologies. Happy mapping!
Update: The CockroachDB docs now include a section on using GeoServer with CockroachDB