Backlog and Smart Pipelining
AMPS queues are designed for high-volume applications that need minimal latency and overhead. One of the features that helps performance is the subscription backlog feature, which allows applications to receive multiple messages at a time. The subscription backlog sets the maximum number of unacknowledged messages that AMPS will provide to the subscription.
When the subscription backlog is larger than 1
, AMPS delivers
additional messages to a subscriber before the subscriber has
acknowledged the first message received. This technique allows
subscribers to process messages as fast as possible, without ever having
to wait for messages to be delivered. The technique of providing a
consistent flow of messages to the application is called smart
pipelining.
Subscription Backlog
The AMPS server determines the backlog for each subscription. An
application can set the maximum backlog that it is willing to accept
with the max_backlog
option. Depending on the configuration of the
queue (or queues) specified in the subscription, AMPS may assign a
smaller backlog to the subscription. If no max_backlog
option is
specified, AMPS uses a max_backlog
of 1
for that subscription.
In general, applications that have a constant flow of messages perform
better with a max_backlog
setting higher than 1
. The reason for
this is that, with a backlog greater than 1
, the application can
always have a message waiting when the previous message is processed.
Setting the optimum max_backlog
is a matter of understanding the
messaging pattern of your application and how quickly your application
can process messages.
To request a max_backlog
for a subscription, you explicitly set the
option on the subscribe command, as shown below:
const command = new Command('subscribe')
.topic('my-queue')
.options('max_backlog=10');