Version: 0.21.0This documentation is for Spitfire 0.21.0.
Redis and MongoDB
Redis
What it does
A Redis step runs one Redis command per iteration (GET, SET, HGETALL, ZADD, INCR…). It measures the latency of your cache layer, session store or counters under load. It works with standalone, cluster and sentinel setups.
When to use it
- To imitate the application's cache read/write pattern and see Redis latency and the connection pool.
- To find out whether Redis is the bottleneck under a service's load.
Creating the connection
- Connections → Add connection, Type: Redis.
- Addresses (comma-separated):
redis:6379; several addresses for cluster or sentinel. Required. - Mode:
standalone(default),clusterorsentinel. 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; empty means the driver's default.
- TLS section for TLS (e.g. a cloud provider's TLS Redis).
- Save, Test.
Adding a step
- Add step → Protocol: Redis → pick the Connection.
- Write the command in Command, for example
SET "user:{{__VU}}" "{{$uuid}}" EX 60. Quote values with spaces; every argument may contain{{variables}}. - If you wrote a dangerous command, an I approve the … command checkbox appears under it; the test cannot be saved until you tick it.
[
{"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"]}}
]In JSON the command is an array: the first item is the command name, the rest are its arguments.
Dangerous commands
Ordinary commands on a key namespace such as SET/DEL are normal load-test 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.
Without the approval, 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 every time a run starts.
Use SCAN instead of KEYS *; on a large database KEYS blocks Redis and stops real traffic.
Metrics it produces
req_duration (the command's round trip), req_failed, reqs. The reply goes to checks and extraction as JSON; when the key does not exist the status is nil (you can tell it apart with a Status check).
MongoDB
What it does
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). Reads change no data; writes need an explicit approval.
When to use it
To reproduce your application's query pattern (filter, sort, limit, aggregation pipeline) and see how MongoDB, its indexes and its connection pool behave under load.
Creating the connection
- Connections → Add connection, Type: MongoDB.
- URI (without password):
mongodb://mongo:27017ormongodb+srv://cluster0.example.net. Required; don't put the password in the URI, the save is refused. - Username and Password (a secret).
- Auth source: the database the user is defined in, often
admin. - Database: the default used when a step does not name one.
- Max pool size: the connection pool per runner.
- TLS section for TLS.
- Save, Test.
Adding a step
- Add step → Protocol: MongoDB → pick the Connection.
- Pick the Operation (the list is grouped into Read and Write).
- Type the Collection. With Database empty, the connection default is used.
- Fill the fields the operation needs: Filter (JSON), Projection, Sort, Limit, Document (JSON) (insert/replace; a JSON array for
insertMany), Update (JSON), Pipeline (JSON array), Field (distinct). - For reads it says A read operation; no data is changed. For writes you must tick … modifies data, I approve.
[
{"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}}
]An aggregate whose pipeline has $out or $merge also counts as a write and needs approval (aggregate modifies data; tick "modifies data" to allow it).
Metrics it produces
req_duration, req_failed, reqs, and the row count the Row count check uses (documents returned or affected). When findOne finds nothing, the status is not_found.
Common problems
Symptom: Redis NOAUTH Authentication required or WRONGPASS.
Cause: Missing or wrong password (or ACL user).
Fix: Type the Password again and save; with Redis 6+ ACLs also fill Username.
Symptom: Redis MOVED / CROSSSLOT errors.
Cause: The server is a cluster but the connection is in standalone mode; or one command touches keys in different slots.
Fix: Set Mode to cluster; use hash tags ({user}:a, {user}:b) in multi-key commands.
Symptom: Saving a Redis step shows … is dangerous on a shared server. Cause: The command is on the approval list. Fix: If you really need it, tick the approval; otherwise use a safer command.
Symptom: MongoDB Authentication failed.
Cause: The user is defined in another database.
Fix: Set Auth source to the database the user was created in (often admin).
Symptom: MongoDB server selection error / context deadline exceeded.
Cause: The host names the replica set members advertise do not resolve from the controller or the runners, or TLS is required.
Fix: Make sure the members' host names are reachable; for services such as Atlas tick Use TLS and add the controller and runners to the IP access list.
Symptom: Saving fails: … modifies data; tick "modifies data" to allow it. Cause: A write operation without approval. Fix: Make sure you write to a test environment, then tick the approval.