Skip to content

How We Engineered a Distributed Database Agent Architecture

How we built SQL Cockpit to manage databases across private networks with outbound HTTPS, centralised coordination and execution inside each environment.

SQL Cockpit | | 8 min read

In this article

When we started designing SQL Cockpit, we had to account for where databases actually live. An organisation might run SQL Server at head office, PostgreSQL on a private cloud subnet and MySQL in a separate application network. Its database team still needs one place to find objects, inspect health and coordinate work across those environments.

Giving a central application a network route to every database would make remote database management depend on maintaining firewall rules, routing and database listeners at every site. We built a distributed database agent architecture around a different requirement. Each site should keep control of database reachability while the team coordinates work from one workspace.

Start with the networks your databases already use

Consider three sites run by one team. Head office has an internal SQL Server. A distribution centre uses SQL Server and PostgreSQL on a separate network. A cloud application uses MySQL on a private subnet. A direct-connect design would need to join those networks to the central application and keep those routes working as the estate changes.

We place an Agent where it can already reach the databases it serves. The distribution centre can operate its own Agent, and the cloud team can run another inside its private network. A saved connection profile routes its work to the paired Agent. When that Agent is unavailable, the central platform leaves the request within that boundary.

Why the Agent initiates the HTTPS connection

Each Agent opens its own outbound HTTPS connection to the central SQL Cockpit services. It uses that connection to identify itself, check for work, report health and return results. The server delivers work in response to an Agent request, so the customer does not need a public Agent listener or inbound access from SQL Cockpit to the database subnet.

Who initiates each connection?
Who initiates each connection?The workspace connects to SQL Cockpit Server. An Agent inside the customer network initiates outbound HTTPS to the same Server and separately opens a local connection to a private database.SQL CockpitworkspacePaired Agent inthe customernetworkSQL CockpitServerPrivate database

There are two different paths to check during deployment. The Agent host needs HTTPS egress to SQL Cockpit. It also needs a route and the appropriate database credentials for the local target. A working heartbeat tells us the first path is healthy. A connection test through the assigned Agent checks the second.

Where coordination ends and database execution begins

SQL Cockpit Server
Tracks paired Agents and their health, coordinates work and records progress and results for the workspace.
SQL Cockpit Agent
Runs in the background inside the customer network, requests authorised work and opens the database connection locally.
SQL Cockpit Engine
Handles the database execution and synchronisation work assigned to it within the applicable execution boundary.
Service Control
Manages installation, settings and the operating-system service lifecycle for components. A service can run without a signed-in user keeping a desktop window open.

For a supported SQL Server synchronisation workflow, a user configures work and reviews its progress in the workspace. The database execution stays inside the applicable environment. Keeping those responsibilities separate lets us improve progress reporting and history independently of how the database work runs.

How an Agent picks up work

Browsing database metadata is an interactive request. The workspace needs a response within a short deadline. A background task can use a queued job, with progress and completion reported separately. An expired interactive request ends with its deadline. Queued jobs have a separate recovery policy based on whether the operation can safely run again.

Lifecycle of a queued job
Lifecycle of a queued jobSQL Cockpit makes authorised work available to the paired Agent. The Agent leases the job over outbound HTTPS, records the start, runs the operation locally and sends the result back to SQL Cockpit.SQL Cockpit queues authorised workPaired Agent claims the job over HTTPSAgent records the start and runslocallyAgent reports progress and outcome

We use a lease to grant an Agent a time-limited claim on a job. The Agent records that execution has started before doing the database work. That marker helps the Server distinguish a job that was claimed but never started from one that may already have changed something. Lease-aware reports also let the Server reject a result from an attempt that has since been replaced.

What pairing authorises

We treat network reachability, Agent identity and permission to run an operation as separate checks. An administrator pairs an Agent using a one-time invitation with an explicit capability grant. Subsequent requests authenticate as that Agent. Registration ties the Agent to a tenant and environment even if someone later renames the host.

The Agent can use a capability when its installation supports it and the administrator has granted it. For example, an Agent paired for metadata discovery can report its health and perform its granted discovery work. A newer version reporting support for a service restart does not extend the original grant.

For saved SQL-authentication profiles, shared app state keeps a credential reference. The paired Agent resolves the actual password through its local secret store. With Windows integrated authentication, SQL Server sees the identity under which the Agent service runs. A DBA’s successful desktop connection therefore tests a different identity from the one a background operation uses.

Keep development, test and production separate

A team may need separate instances for development, test and production on the same host. We reuse the Agent implementation across those environments. Each configured instance has its own identity, settings, credentials, logs and writable state. Administrators can restart one instance independently.

One Agent implementation, isolated environments

Development

  • Development Agent identity
  • Development credentials and state

Test

  • Test Agent identity
  • Test credentials and state

Production

  • Production Agent identity
  • Production credentials and state

The registration boundary carries through to the hosted side. A test Agent pairs with its corresponding environment. An identity change goes through the registration lifecycle so the environment and credentials remain aligned. Service Control handles the installation and service management side of that separation.

What happens when a connection drops

A distribution centre can lose internet access while its SQL Server remains healthy. The local service manager can tell an operator whether the Agent process is running. SQL Cockpit uses the last heartbeat and work status to tell them whether the Agent has recently reached the Server.

Claimed, with no recorded start. The job can return to the queue while retry attempts remain.

Started, with a retry-safe capability. A read-only operation such as supported metadata discovery can be queued again within the retry limit.

Started, with a possible side effect. SQL Cockpit records that the Agent was lost and skips the automatic rerun. An operator can check the outcome before deciding whether to retry.

Consider a SQL Server service restart where the Agent loses contact after the restart begins. The missing completion leaves open the possibility that SQL Server restarted successfully. Repeating the restart automatically could interrupt the recovered service. If the original attempt later reports a valid completion, SQL Cockpit can record its actual outcome.

Use the same connection model across database engines

SQL Server, PostgreSQL, MySQL, MariaDB, Oracle and SQLite share this Agent model for supported discovery and management workflows. The local connection differs by technology. A client-server engine needs a reachable database service and matching driver and credentials. SQLite discovery reads a file the Agent is permitted to access. Availability also varies by engine and deployment.

Keeping those details at the local execution boundary lets us extend engine support through database-specific providers. The process of pairing an Agent, assigning authorised work and reporting results remains familiar across environments.

What to verify before adding a site

  1. Place the Agent on a host that can reach the intended database and confirm outbound HTTPS to SQL Cockpit.
  2. Pair it with the intended tenant and environment, and grant the capabilities the team needs for that site.
  3. Run a connection test through the paired Agent to check the database path and the credentials the Agent service actually uses.
  4. Start with a supported read-only operation and check that the expected Agent reports the result in the workspace.

Those checks verify both sides of outbound database connectivity. The Server can coordinate work across the estate, and each site can control which databases its Agent can reach and which work it can perform.

Explore the architecture