SpitfireLoad Testing & APMWhat's new

MQTT, RabbitMQ, NATS and AWS SQS

Four messaging protocols: MQTT for IoT and device traffic, RabbitMQ (AMQP 0-9-1) for queue-based services, NATS for events between services and JetStream, and AWS SQS and SNS for Amazon queues. Kafka has its own page: Kafka. How to add a connection, how secrets are stored and how to turn on TLS is on Protocols and connections; this page has only each type's own fields. For no type may the password go in the address; the save is refused.

MQTT

Every VU is its own MQTT client, like a device: it connects on its first call, keeps its subscriptions for the run and reconnects on the next call if the connection is lost. It measures a broker such as Mosquitto, EMQX, HiveMQ or the RabbitMQ MQTT plugin while thousands of devices send telemetry at once.

Creating the connection

  • Brokers (comma-separated): required. tcp://broker:1883, for TLS ssl://broker:8883, over WebSocket ws://broker:8083/mqtt.
  • Client ID: a template, default spitfire-{{__VU}}. Each VU's ID must be unique; when two clients connect with the same ID, the broker drops one of them.
  • Username, Password (a secret), Keep-alive (s) (default 30), Clean session (on by default; when off, the broker keeps the session and persistent subscriptions).
  • MQTT version: 3.1.1 (the default) or 5. MQTT 5 works with tcp:// and ssl:// addresses only.

A step has three Action values. Publish sends a message to a topic; the time is the send with QoS 0 and until the broker acknowledges with QoS 1/2. With Wait for a message (subscribe) the VU subscribes once and every iteration waits for the next message. Request/reply subscribes to the Response topic, publishes the message and waits for the reply; the time is the round trip. Wildcards (+, #) are only valid for subscribing; on publish the save fails with wildcards (+ #) are only valid for subscribe. QoS is 0, 1 or 2, with retain if needed. Wait defaults to 10s.

json
[
  {"id": "telemetry", "name": "Telemetry", "protocol": "mqtt", "connection": "iot-broker",
   "mqtt": {"action": "publish", "topic": "devices/{{__VU}}/telemetry",
     "payload": "{\"temp\": {{$randInt 18 30}}}", "qos": 1}},
  {"id": "command", "name": "Wait for command", "protocol": "mqtt", "connection": "iot-broker",
   "mqtt": {"action": "subscribe", "topic": "devices/{{__VU}}/commands", "qos": 1, "wait": "10s"}}
]
Tip

To connect like a new device on every iteration, tick Close connections between iterations in the Options tab; it applies to MQTT clients too. That is how you measure the cost of connecting.

MQTT 5

When the connection's MQTT version is 5, publish and request steps also have:

  • User properties: key/value pairs sent with the message (tenant = {{tenant}}). An incoming message's user properties reach checks and extractors as headers.
  • Content type and Message expiry: when it runs out, the broker no longer delivers the message.
  • Request/reply carries fresh correlation data on every call; only the reply with that correlation data is accepted. On 3.1.1 the first message on the response topic is taken, so a late reply to an old request can count as the answer to a new one.

RabbitMQ (AMQP)

Publishes a message to an exchange, takes a message from a queue, or does request/reply (RPC). Every publish waits for its publisher confirm; the measured time is the broker's.

Creating the connection

  • URL: required. amqp://rabbit:5672/, with a vhost amqp://rabbit:5672/orders, for the TLS port usually amqps://rabbit:5671/.
  • Username, Password (a secret).
  • Separate connection per VU: each VU opens its own TCP connection (to imitate many clients). Default: one connection per runner, a channel per VU.

A step's Action: Publish (Exchange, empty means the (default) exchange, plus the Routing key; a message no queue receives is a failure), Consume from queue (the Queue must exist; each iteration takes one message and acks it) or RPC (request/reply) (sent with direct reply-to, the matching reply is awaited). Persistent message keeps the message across a broker restart. Wait (default 10s) is for consume and RPC.

json
[
  {"id": "publish", "name": "Order event", "protocol": "amqp", "connection": "rabbit",
   "amqp": {"action": "publish", "exchange": "orders", "routingKey": "orders.created",
     "body": "{\"id\": \"{{$uuid}}\"}", "contentType": "application/json", "persistent": true}},
  {"id": "take", "name": "Take from queue", "protocol": "amqp", "connection": "rabbit",
   "amqp": {"action": "consume", "queue": "orders.created", "wait": "10s"}},
  {"id": "rpc", "name": "Ask price", "protocol": "amqp", "connection": "rabbit",
   "amqp": {"action": "rpc", "routingKey": "pricing.rpc", "body": "{\"sku\": \"A-1\"}", "wait": "5s"}}
]
Warning

Consume from queue takes the message from a real queue and acks it; that message no longer reaches your real consumer. Don't use it on production queues; bind a separate queue for testing.

NATS

Core NATS and JetStream steps. The VUs of a runner share a few connections, because NATS carries a lot over one connection.

Creating the connection

  • Servers (comma-separated): required. nats://nats:4222; for TLS tls://nats:4222 or the TLS section.
  • Fill in only one way to authenticate: Username + Password, Token, NKey seed or .creds file (JWT + seed; paste the content). All are stored encrypted.
  • JetStream domain: only with leaf nodes / domains.
  • Shared connections (per runner): 4 by default. Separate connection per VU is for trying the server's connection limit.

A step has five Action values:

  • Publish: no acknowledgement; the time is writing the message to the client's buffer.
  • Wait for a message (subscribe): the VU subscribes to the Subject once (wildcards: orders.*, orders.>). With a Queue group, messages are shared among the VUs in the group.
  • Request/reply: the time is the round trip. With nobody listening the error is no_responders.
  • Publish to JetStream: the time is to the stream's acknowledgement (PubAck). With no stream covering the subject the error is no_stream.
  • Consume from JetStream (pull): Stream is required. Consumer is spitfire by default; when it does not exist, a durable consumer is created that starts from new messages, acks explicitly and filters on the subject. An existing consumer's settings are left alone.

Wildcards only work when waiting for messages and consuming from JetStream. Wait defaults to 10s.

json
[
  {"id": "place", "name": "Order", "protocol": "nats", "connection": "bus",
   "nats": {"action": "jsPublish", "subject": "orders.{{__VU}}", "payload": "{\"vu\": {{__VU}}}"}},
  {"id": "handle", "name": "Handle the order", "protocol": "nats", "connection": "bus",
   "nats": {"action": "jsConsume", "subject": "orders.>", "stream": "ORDERS", "consumer": "spitfire", "wait": "5s"}},
  {"id": "price", "name": "Ask the price", "protocol": "nats", "connection": "bus",
   "nats": {"action": "request", "subject": "price.get", "payload": "{{sku}}", "wait": "2s"}}
]

On work-queue streams an acknowledged message is deleted; don't use a real service's consumer name, or Spitfire takes and acks that service's messages.

Publishes are stamped with a Spitfire-Ts header (Don't stamp turns it off). Wait for a message and Consume from JetStream measure nats_e2e_latency for messages published in the same run by the same runner, as with Kafka (How end-to-end latency is measured). Threshold example: p(95)<50 on nats_e2e_latency.

AWS SQS and SNS

Sends messages to an SQS queue, receives and deletes messages from it, and publishes to an SNS topic. It also works with LocalStack and ElasticMQ.

Creating the connection

  • Region: required, e.g. eu-central-1.
  • Access key ID and Secret access key (encrypted); Session token for temporary credentials.
  • Or Use the machine's credentials: the controller and every runner use their own environment, profile or IAM role (EC2, ECS, EKS), and no key is stored. Since everyone who uses the connection acts with the installation's AWS identity, only an installation admin can change this and such a connection's Endpoint.
  • Endpoint: only for LocalStack (http://localstack:4566), ElasticMQ or a VPC endpoint.

Test tries to list queues; when listing is not allowed, accepted credentials still count as success. Least privilege: sqs:SendMessage, sqs:ReceiveMessage, sqs:DeleteMessage, sqs:GetQueueUrl on the queue; sns:Publish on the topic.

A step's Action: Send (SendMessage), Receive and delete (ReceiveMessage) or Publish to SNS (Publish). Queue is the queue's name or URL; for SNS the SNS topic ARN. Receiving waits with long polling (in polls of up to 20s) until Wait (default 10s) runs out; with Don't delete the message the message returns to the queue after the visibility timeout. FIFO needs Message group ID and Deduplication ID (e.g. {{$uuid}}; empty with content-based deduplication). Delay is 0–15 minutes.

json
[
  {"id": "queue", "name": "Queue the order", "protocol": "sqs", "connection": "aws-prod",
   "sqs": {"action": "send", "queue": "orders", "body": "{\"orderId\": {{__ITER}}}"}},
  {"id": "take", "name": "Handle the order", "protocol": "sqs", "connection": "aws-prod",
   "sqs": {"action": "receive", "queue": "orders", "wait": "10s"}}
]

The receive step deletes the message; don't receive from a queue a real service works on. SQS charges per request, so a load test shows up on your bill. That is why we suggest a short run on LocalStack first, then the real queue.

Sent messages get a spitfire-ts attribute (Don't stamp turns it off); Receive and delete measures sqs_e2e_latency for messages sent by the same runner. For SNS → SQS, with raw message delivery on for the subscribed queue the latency is measured too. Error types: not_found (no such queue), auth (credentials or permission), throttled (AWS throttling), timeout.

Common problems

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

Symptom Cause Fix
MQTT VUs keep disconnecting and reconnecting Client IDs collide; the broker drops the older connection with the same ID. Use {{__VU}} in the Client ID (default spitfire-{{__VU}}).
Wait for a message times out every time No message arrives, or the topic/wildcard is wrong. Check the topic, add a publish step to the same test, raise Wait.
RabbitMQ ACCESS_REFUSED - Login was refused Wrong password, or the user has no access to the vhost. Give the user permissions on the vhost in the URL.
publish: unroutable: 312 NO_ROUTE No queue bound to the exchange matches the routing key. Check the exchange name and routing key; create the binding.
Consume from queue fails with NOT_FOUND - no queue The queue does not exist; Spitfire does not create queues. Create the queue in RabbitMQ beforehand.
NATS no_responders Nothing listens on the request subject. Check the subject, that the service is up, and the queue group name if any.
Publish to JetStream fails with no_stream No stream covers the subject. Create the stream (nats stream add) or match the subject to the stream.
Consume from JetStream times out every time The consumer starts from new messages and nothing is published in the test, or the filter does not match. Add a Publish to JetStream step, or create the consumer beforehand (--deliver all) and write its name in Consumer.
SQS not_found Wrong queue name, or the queue is in another region or account. Check Region; for a queue in another account write its URL.
SQS or SNS auth The key is wrong or expired, or IAM does not allow the action. Add the action named in the error (e.g. sqs:DeleteMessage) to the policy.