⏳TimescaleDB
Find all the information about how to set up your TimescaleDB instance for Speculare. It will be the core of the whole infrastructure for Speculare.
Speculare is built on top of TimescaleDB which is itself built on top of PostgreSQL and is an extremely performant Relational / Timeseries Database.
As we need to use some advanced PostgreSQL functionality and to ease the development of our project, we rely on some features of PostgreSQL that need to be enabled as well as some plugins. We'll cover here the configuration needed to be able to run Speculare correctly.
In this document (and the others) I might refer to PostgreSQL for TimescaleDB as they are both pretty much the same thing but with the tweak that TimescaleDB is more like an add-on on top of PostgreSQL.
Setup
We strongly recommend you to use the v13+ even if in theory any version above v10 should work just fine.
Install TimescaleDB 13 on Ubuntu
You can refer to this link from Timescale for installation on your system: docs of Timescale. Their docs are really well written ! 👏
Upon successful installation of TimescaleDB, I suggest you to install timescaledb-tools
as this will allow you to run:
The above command will offer you to apply certain settings to your PostgreSQL instance (in order to "optimize" it).
You can then verify that PostgreSQL has been installed correctly by running:
Install wal2json (required)
Speculare rely on one more PostgreSQL plugin, which is wal2json. As a basic explanation of what it does: wal2json convert the events passing through the WAL of PostgreSQL into a JSON structure
You can install it easily by running (or by checking their docs):
Enable wal2json (required)
You now need to enable both plugins (wal2json & timescaledb) otherwise installing them would be useless. For that you have to edit /etc/postgresql/{version}/main/postgresql.conf
to add wal2json & timescaledb
to the shared_preload_libraries
variable.
Set up logical replication
As you probably know, PostgreSQL doesn't offer a real-time API to listen to change over a Web-socket or such. Because of that we had to develop a Change Data Capture service which listen to the WAL output.
This feature allow us to get a stream of changes made within PostgreSQL which is then filtered and broadcasted over Web-socket to subscribed clients. This is done though Speculare-PGCDC.
Logical replication can be enabled by changing a few line in /etc/postgresql/{version}/main/postgresql.conf
:
After all those changes, you will need to restart PostgreSQL for changes to take effect.
An important point to note is that those are "default" settings and may not be suitable for production use.
And you should now be ready to use PostgreSQL.
If something is missing in this guide, don't hesitate to open an issue on Github.
Last updated