SFQ Queuing & Minimising Buffer Bloat

A simple queuing method to reduce buffer bloat and ensure a fair service to all devices taking service from your router. This is as close to a Ubiquiti Smart Queue Management (fq_codel) as you can get currently. Employing an SFQ with a small bucket will often improve the efficiency of your internet service by ensuring that no one device or connection hogs the full bandwidth allowance.

MikroTik define the SFQ process as follows;
Stochastic Fairness Queuing (SFQ) is ensured by hashing and round-robin algorithms. A traffic flow may be uniquely identified by a 4 options(src-address, dst-address, src-port and dst-port), so these parameters are used by SFQ hashing algorithm to classify packets into one of 1024 possible sub-streams. Then round-robin algorithm will start to distribute available bandwidth to all sub-streams, on each round giving sfq-allot bytes of traffic. The whole SFQ queue can contain 128 packets and there are 1024 sub-streams available.


SFQ is called “Stochastic” because it does not really allocate a queue for each flow, it has an algorithm which divides traffic over a limited number of queues (1024) using a hashing algorithm.

Using SFQ on your router

Firstly you are going to want to be logged in to your router, open up a terminal and paste in the following. This creates you a “default-sfq” so we can be clear what we are using. Other pre-made queues already use SFQ however have differing names and are not clear so we can make one for simplicity.

/queue type
add kind=sfq name=default-sfq sfq-perturb=5

Now we need to create a simple queue to apply SFQ on. You will need to change both the max-limit=D/U and the target to match your current configuration.

For the max-limit I recommend finding the “true” speed values then knocking a little off so the queue restricts you by a slight amount. This will ensure the queue is always applied. My connection is roughly 58/16 so I opt for a 55/15.

For target this is your WAN interface, this would usually be something like pppoe_client1 or ether1, ether10 or similar but essentially whatever your WAN connection is you want to improve.

Edit the following to suit you, paste it into the MikroTik terminal and then hit enter.

/queue simple
add max-limit=55M/15M name=WAN_limiter queue=default-sfq/default-sfq target=WAN-Interface

What SFQ won’t do

  • SFQ won’t prioritise traffic, it’s a round robin algorithm so should be more or less perfectly fair.
  • It has a limit of 1024 queues so extremely heavy networks may suffer.
  • SFQ done in the manner above can’t be used with queue trees.