ROS Publishers - what is queue_size and why is it important?

queue_size is the size of the outgoing message queue used for asynchronous publishing.

The queue_size is important because messages are published asynchronously (by default) and are therefore sent to a queue to be processed, first in first out. Without this value being set, synchronous publishing is forced (but not recommended).

You should set a queue_size based on your publishing rate. If you publish faster than your queue size can handle, some messages will be dropped.

Read more in the following reference links: