SpitfireLoad Testing & APMWhat's new

Redis and MongoDB

Adding a connection, secrets and TLS are on Protocols and connections; this page has the two types' own fields and steps.

Redis

A Redis step runs one command per iteration (GET, SET, HGETALL, ZADD, INCR…). It imitates the application's cache read/write pattern and measures the latency and connection pool of your cache layer, session store or counters under load. It works with standalone, cluster and sentinel setups.

Creating the connection

  • Addresses (comma-separated): required, e.g. redis:6379; several addresses for cluster or sentinel.
  • Mode: standalone (default), cluster or sentinel. Sentinel needs Master name (sentinel).
  • Username (Redis 6+ ACL) and Password (a secret).
  • DB number: default 0, not used in cluster mode.
  • Pool size: the connection pool per runner, 50 when empty.

Write the command in the step's Command field, e.g. SET "user:{{__VU}}" "{{$uuid}}" EX 60. Quote values with spaces; every argument may contain {{variables}}. In JSON the command is an array: the first item is the command name, the rest are its arguments.

json
[
  {"id": "get", "name": "Product cache", "protocol": "redis", "connection": "cache",
   "redis": {"command": ["GET", "product:{{$randInt 1 1000}}"]}},
  {"id": "set", "name": "Write session", "protocol": "redis", "connection": "cache",
   "redis": {"command": ["SET", "session:{{__VU}}", "{{$uuid}}", "EX", "60"]}}
]

req_duration is the command's round trip. The reply goes to checks and extraction as JSON; when the key does not exist the status is nil, which a Status check tells apart.

Dangerous commands

Commands on a key namespace such as SET/DEL are normal load traffic and need no approval. These commands, which affect or block a shared server, need an explicit approval on the step ("allowWrite": true):

FLUSHALL, FLUSHDB, SHUTDOWN, CONFIG, DEBUG, SWAPDB, SCRIPT, FUNCTION, CLUSTER, REPLICAOF, SLAVEOF, MIGRATE, KEYS, MONITOR, SAVE, BGSAVE, BGREWRITEAOF, ACL, MODULE.

When you write one, an I approve the … command checkbox appears under it. Without it, saving fails with: KEYS is dangerous on a shared server; tick the approval to allow it. A test with an approved dangerous command asks again for the data-change confirmation at the start of every run.

Tip

Use SCAN instead of KEYS *. On a large database KEYS blocks Redis and stops real traffic; it is the most common Redis accident.

MongoDB

A MongoDB step runs one operation on a collection: a read (find, findOne, aggregate, countDocuments, distinct) or a write (insertOne, insertMany, updateOne, updateMany, replaceOne, deleteOne, deleteMany). It reproduces your application's query pattern (filter, sort, limit, aggregation pipeline) and shows how indexes and the connection pool behave under load.

Creating the connection

  • URI (without password): required, e.g. mongodb://mongo:27017 or mongodb+srv://cluster0.example.net.
  • Username and Password (a secret).
  • Auth source: the database the user is defined in, often admin.
  • Database / service: the default used when a step names none.
  • Max pool size: the connection pool per runner, 50 when empty.

The step's Operation list is grouped into Read and Write. Type the Collection; with Database empty, the connection default is used. Depending on the operation, fill Filter (JSON), Projection, Sort, Limit, Document (JSON) (a JSON array for insertMany), Update (JSON), Pipeline (JSON array) or Field (distinct). A read says A read operation; no data is changed.; a write needs … modifies data, I approve ticked. An aggregate whose pipeline has $out or $merge also counts as a write.

json
[
  {"id": "find", "name": "Find products", "protocol": "mongo", "connection": "catalog-mongo",
   "mongo": {"collection": "products", "operation": "find",
     "filter": "{\"category\": \"books\"}", "sort": "{\"price\": 1}", "limit": 20},
   "checks": [{"type": "rowCount", "op": "gt", "value": 0}]},
  {"id": "insert", "name": "Add review", "protocol": "mongo", "connection": "catalog-mongo",
   "mongo": {"collection": "reviews", "operation": "insertOne",
     "document": "{\"product\": \"{{$uuid}}\", \"stars\": 5}", "allowWrite": true}}
]

The Row count check uses the number of documents returned or affected. When findOne finds nothing, the status is not_found. For installation admins, schema suggestions work on MongoDB too.

Bulk add

Bulk add on the MongoDB step adds many commands at once; no command runs.

  1. On the Commands / file tab paste commands or choose a .js/.json file, one command per line: mongosh form (db.orders.find({ status: "open" }).limit(20)) or step JSON ({"operation": "find", "collection": "orders", "filter": {...}}). On the CSV tab the query column holds the command; name and weight are optional.
  2. Click Split. The commands come selected; insert/update/replace are marked amber, delete/drop and $out/$merge red, with counts per kind at the top.
  3. Click Add (N); each command becomes a MongoDB step. If the selection writes, a warning and consent come first (SQL write protection); a test with writing Mongo steps also needs that consent before it runs.

Common problems

The general table of refused connections, auth and TLS errors: Protocols and connections.

Symptom Cause Fix
Redis NOAUTH Authentication required or WRONGPASS Missing or wrong password or ACL user. Type the Password again and save; with Redis 6+ ACLs also fill Username.
Redis MOVED / CROSSSLOT The server is a cluster but the connection is standalone; or one command touches keys in different slots. Set Mode to cluster; use hash tags ({user}:a, {user}:b) in multi-key commands.
MongoDB Authentication failed The user is defined in another database. Set Auth source to the database the user was created in (often admin).
MongoDB server selection error / context deadline exceeded The host names the replica set members advertise do not resolve from the controller or the runners, or TLS is required. Check access to the members' host names; for services such as Atlas tick Use TLS and add the controller and runners to the IP access list.
Saving fails: … modifies data; tick "modifies data" to allow it A write (or an aggregate with $out/$merge) without approval. Make sure you write to a test environment, then tick the approval.