TeamCity On-Premises 2026.3 Help

Distributed Multinode Cache

In a multinode setup, TeamCity nodes can share cached data through an external Redis-compatible server. With a distributed cache, a value that is expensive to compute or to read from the database is calculated once by one node and then reused by all other nodes. This lowers the load on the database and lets nodes learn about changed data faster.

For the list of supported cache servers, see Distributed Cache.

Common caching concepts

Whenever a TeamCity node needs a value, it looks for it in the following sources (in order):

  1. A local in-memory cache on the node

  2. A shared cache on the Redis-compatible server, available to all nodes

  3. A database or manual calculation of a required value

Adding the shared cache layer brings the following benefits:

  • Required values are obtained faster. A node does need to compute a value or retrieve it from a database, if this value is already stored in cache. If it's not, a node will perform this expensive operation and put the calculated/retrieved value in a shared cache for other nodes to use.

  • Faster value invalidation. Without a distributed cache, nodes rely on periodically polling the database to learn about values changes. A cache server speeds up this process by explicitly notifying nodes about changes in cached data, which causes them to drop their outdated local copies.

Key principles of a shared cache

When planning a shared cache setup, keep in mind the following key points:

  • The database remains the source of truth. The cache only stores copies of data that TeamCity can always recalculate. Entries may be evicted at any moment, and losing the entire cache content does not cause any data loss in TeamCity. Redis persistence (RDB or AOF) is therefore not required.

  • Cache errors do not break the server. If the cache server becomes unavailable while TeamCity is running, nodes log the errors and fall back to calculating values manually. TeamCity server maintains normal operations, with the only downside being a higher load on the database and nodes.

  • Cached values are not encrypted. TeamCity stores cached values as JSON: small values as plain text, large values compressed. Anyone with access to the cache server can read these values. TeamCity does not cache secrets, but caches can still store sensitive information about your projects and builds. Restrict network access to the cache server, enable authentication, and connect over TLS to mitigate the security risks.

Recommended setup

Follow the recommendations below to set up a shared cache for your multi-node TeamCity servers.

Use a dedicated Redis-compatible server or cluster for each TeamCity installation

All TeamCity keys share the same prefix, so two installations connected to the same shared cache server will overwrite each other's data.

Prioritize a cluster for production

A cluster keeps the cache available when one of its nodes fails. A standalone shared cache server is suitable for evaluation and small installations.

Place the cache server close to the TeamCity nodes

Every cache miss on a node results in a network round trip to a cache server, so placing it in the same network and data center as TeamCity nodes is optimal.

Limit memory and enable key eviction

Always set a memory limit for the cache server and enable an eviction policy so that the server removes old keys instead of running out of memory. For example, add the following lines to the server configuration file:

maxmemory 16gb maxmemory-policy allkeys-lru

Configure the cache connection

The connection to the cache server is configured similarly to the database connection: in the database.properties file or via environment variables. All TeamCity nodes must use the same settings.

Properties file

Add the following properties to the <TeamCity Data Directory>/config/database.properties file and restart all TeamCity nodes to apply the changes.

Property

Description

redisUrl

Address of the Redis-compatible server in the host:port format. If the port is omitted, the default 6379 port is used.

The format of the value defines the client type:

  • A single host:port pair connects to a standalone server, for example: redis.example.com:6379

  • A comma-separated list of host:port pairs connects to a cluster, for example: redis-1.example.com:6379,redis-2.example.com:6379,redis-3.example.com:6379

  • A single host:port pair with the cluster@ prefix also connects to a cluster. Use it when the cluster is available via a single address, for example: cluster@redis-cluster.example.com:6379

An optional scheme at the start of the value defines whether the connection is encrypted:

  • rediss:// connects over TLS. See TLS Connection.

  • redis:// or no scheme connects without encryption.

The scheme goes before the cluster@ prefix, for example: rediss://cluster@redis-cluster.example.com:6379

The value must not contain anything else. Specify credentials in the redisProperties.user and redisProperties.password properties: a URL with a user:password@ part or a database index such as /0 is rejected as a failed connection (see Startup failure).

redisProperties.user

Username for connecting to the cache server. Can be omitted if no authentication is required.

redisProperties.password

Password for connecting to the cache server. Can be omitted no authentication is required.

For example:

redisUrl=rediss://cluster@redis-cluster.example.com:6379 redisProperties.user=teamcity redisProperties.password=<password>

Environment variables

The cache connection settings can also be defined by setting environment variables in the environment of every TeamCity node. This is useful, for example, to avoid storing the cache server password in the database.properties file.

Variable

Description

TEAMCITY_REDIS_URL

Address of the Redis-compatible server. Overrides redisUrl.

TEAMCITY_REDIS_USER

Username for connecting to the cache server. Overrides redisProperties.user.

TEAMCITY_REDIS_PASSWORD

Password for connecting to the cache server. Overrides redisProperties.password.

TLS connection

We recommend encrypting the connection to the shared cache server, especially if it carries the server password or crosses networks that you do not fully control. To connect over TLS:

  1. Enable TLS on the cache server. On Amazon ElastiCache, this option is called encryption in transit.
    For a self-hosted cluster, also set cluster-announce-hostname and cluster-preferred-endpoint-type hostname on every cluster node, so that the nodes announce host names matching their certificates instead of IP addresses. Amazon ElastiCache already does this.

  2. Make sure the JVM running each TeamCity node trusts the cache server certificate. TeamCity verifies the certificate against the default trust store of the JVM and checks that the host name of each cache node matches its certificate. This verification is mandatory and cannot be disabled.

    • Certificates issued by a well-known certificate authority are usually trusted by default.

    • For a self-signed certificate or a certificate issued by your organization's certificate authority, import the CA certificate into the JVM trust store on every node, as described in Configuring client JVM for trusting server certificate. Certificates uploaded to TeamCity are not used for this connection.

  3. Add the rediss:// scheme to redisUrl (or TEAMCITY_REDIS_URL) on all nodes, for example: rediss://redis.example.com:6379.

  4. Restart all TeamCity nodes.

If the certificate is not trusted or the host name does not match, the node is unable to connect to the cache server refuses to start. See the Startup failure for more information.

Startup failure

If the cache connection is configured but a node cannot connect to the required cache server on startup, it refuses to start. This behavior is implemented as a safety measure to ensure a simple misconfiguration does not cause TeamCity nodes to silently run without the shared cache.

To override this behavior and force a node to start without the cache, set the teamcity.redis.ignoreBootstrapError=true internal property.

Monitor the cache

Cache statistics, such as hits, misses, errors, and load times, are reported as server metrics. A growing number of errors usually indicates connection problems with the cache server.

Limitations and special notes

Caches let nodes get values quickly without reading them from the database. TeamCity normally keeps the shared cache in sync with the database, including when you restore data from a backup. However, if the database is changed directly while the TeamCity server is down, the cache may hold stale values. This can happen, for example, when you run a restore procedure with the server_property table excluded, or use third-party tools to roll the database back to an earlier state. In these cases, clear the shared cache to avoid data mismatches:

redis-cli flushall # or valkey-cli flushall
12 November 2026