- Tyk Dashboard, Tyk MDCB and Tyk Pump connect to the same PostgreSQL instance as part of the Core Platform’s shared persistent database.
- Tyk Developer Portal maintains its own, separate database - see Install Developer Portal for how that fits into a Portal deployment.
Supported Versions
Core Platform
You can also use the following as a drop in replacement for PostgreSQL:
Sqlite support was previously offered for development and testing only. It reached End of Life and is no longer supported from Tyk 5.7.0 onward. Use PostgreSQL, MongoDB, or another listed compatible alternative instead.
Developer Portal
You can also use the following as a drop in replacement for PostgreSQL:
Configuration Reference
Each component configures SQL storage differently - see Configuration Examples below for each component’s own fields. A few options are worth explaining up front, since they apply across more than one component.Connection String
A connection string combines the address Tyk uses to reach your database (host and port), access credentials, and the database name.
PostgreSQL uses space-separated
key=value pairs:
username:password@tcp(host:port)/dbname:
- Tyk Dashboard can take advantage of this by pointing writes and reads at two different connection strings instead of one.
- Tyk MDCB and Tyk Pump only write to the persistent storage, and so would not benefit from separate read and write connections.
- Tyk Developer Portal also uses a single connection string.
Table Sharding
Unlike MongoDB, SQL has no built-in way to expire old data automatically. Left alone, a table such astyk_analytics (Logs) or tyk_aggregated (Aggregate Analytics) just grows forever, and deleting old rows from a huge table with a plain DELETE gets slower as the table grows.
When enabled, table sharding solves this by creating a new table per day instead of a single large table. Each table uses a common name as a prefix, adding the date to generate a unique table name, for example tyk_analytics_20230327. Deleting a day’s data then just means dropping that one table, instead of running a slow DELETE against everything.
- Tyk Dashboard, Tyk MDCB, and Tyk Pump can be configured to use sharded tables.
- Tyk Developer Portal does not expose this option.
Maintaining Consistency
When the component writing a sharded category starts up, it checks that day’s table against the current schema and adds any missing columns, for example after an upgrade that extends the schema; it never drops or renames existing columns. By default, this only happens for the current day’s table - older dated tables are left exactly as they were when created. Tyk Pump’smigrate_sharded_tables setting extends this to every table matching its prefix, not just today’s, scanning the whole set on startup and updating any that are out of date. Tyk MDCB has no equivalent setting, so it only ever updates the current day’s table.
TLS
TLS encrypts the connection between Tyk and your database, and can optionally authenticate Tyk to the database using a client certificate (mutual TLS) rather than just a password. Many managed database providers require it, or a compliance policy may. TLS is configured by adding extra parameters to the connection string. These parameters depend on the SQL engine:
PostgreSQL:
tls=true encrypts the connection and verifies the server’s certificate against your system’s trusted root CAs - this covers the common case of a certificate signed by a public CA, as most managed cloud database providers use. For a private or self-signed certificate, tls=skip-verify encrypts the connection without verifying the server’s identity; limit this to development or temporary testing. Avoid tls=preferred in production: it can silently fall back to an unencrypted connection if TLS negotiation fails.
Connection Pool Management
Each component maintains one or more pools of connections to the database:
Sizing Guidance
For Tyk Dashboard and Tyk Developer Portal, the two components with configurable pools, size
max_open_connections against your database’s own maximum connection limit: divide that limit by the number of instances you’re running, and by however many pools each instance opens (one for Tyk Developer Portal, eight for Tyk Dashboard), to find a safe per-pool ceiling that keeps every instance’s connections within the database’s own limit.
Tyk Dashboard
Tyk Dashboard’s pools are configured per category, understorage.<category>.postgres (or the equivalent environment variables):
These settings apply per connection pool, and Tyk Dashboard maintains eight of them - one read and one write pool for each of its four categories of data. Setting
max_open_connections to 10 for main permits up to 20 open connections for that category alone (10 for reads, 10 for writes), not 10 across the whole Dashboard.Tyk Developer Portal
Tyk Developer Portal’s pool is controlled in theDatabase block (or via environment variables):
For example, with a database allowing 60 connections across two Developer Portal instances:
MaxOpenConnections of 30 and MaxIdleConnections of 15 per instance can handle around 90 active users, based on Tyk’s own performance testing.
Tyk Developer Portal does not currently have an equivalent to Tyk Dashboard’s
connection_max_idle_time.Configuration Examples
Tyk Dashboard
Tyk Dashboard uses astorage.<category> block per category of data, in tyk_analytics.conf (or via environment variables). <category> is one of main, analytics, logs, or uptime - each of the four categories of data is configured independently, though all four normally point at the same database instance.
Tyk Dashboard uses the
main category’s configuration when no corresponding configuration is available for logs, uptime or analytics.Tyk MDCB
Tyk MDCB uses a top-levelanalytics block, in tyk_sink.conf (or via environment variables):
Tyk Pump
Tyk Pump connects to SQL through its SQL pump types, each declared inpump.conf (or using equivalent environment variables).
For full details of the SQL pump types and their configuration see Control Plane Pumps.
Tyk Developer Portal
Tyk Developer Portal uses aDatabase block, in portal.conf (or via environment variables):
Migrating Tyk Dashboard from MongoDB to SQL
Tyk Dashboard provides a migration command to move data from an existing MongoDB instance to a SQL platform. This migrates all data from themain category (APIs, Policies, Users, UserGroups, Webhooks, Certificates, Portal Settings, Portal Catalogs, Portal Pages, Portal CSS, etc.).
The migration tool will not migrate any Traffic Logs, Aggregate Analytics, or Uptime Test Results data.
- Make sure your new SQL platform and the existing MongoDB instance are both running.
- Configure the
mainpart of thestoragesection of yourtyk-analytics.conf:
- Run the following command:
Migrating 'tyk_apis' collection. Records found: 7.
- You can now remove your MongoDB configuration from
tyk-analytics.conf. - Restart your Tyk Dashboard.