RB5009 Cake / SQM issue

Hi, this is my first Mikrotik device and I am trying to SQM a 1 Gb GPON WAN via SFP.
How would I apply these shaping rules directly to an interface, rather than using a simple queue or a queue tree?

/queue type
add cake-flowmode=dual-srchost cake-nat=yes kind=cake name=cake-upload
add cake-flowmode=dual-dsthost cake-nat=yes kind=cake name=cake-download
/queue tree
add bucket-size=0.01 max-limit=950M name=download packet-mark=no-mark parent=bridge-lan queue=cake-download
add bucket-size=0.01 max-limit=950M name=upload packet-mark=no-mark parent=ether1-ISP queue=cake-upload

/queue type
add cake-atm=ptm cake-diffserv=besteffort cake-mpu=88 cake-overhead=40 kind=cake name=cake-defaults
add cake-ack-filter=filter cake-atm=ptm cake-bandwidth=940.0Mbps cake-diffserv=besteffort cake-mpu=88 cake-nat=yes cake-overhead=40 kind=cake name=cake-upload
add cake-atm=ptm cake-bandwidth=940.0Mbps cake-diffserv=besteffort cake-mpu=88 cake-nat=yes cake-overhead=40 cake-wash=yes kind=cake name=cake-download

/queue simple
add bucket-size=0.001/0.001 name=CAKE-QOS queue=cake-download/cake-upload target=sfp1-ISP total-queue=cake-defaults

The following three configurations all "worked" in my tests, the first one used the most CPU resources, the second one the least CPU resources, and the third one seemed to be the most correct way but Mikrotik tells us that you cannot configure bandwidth parameters on non-interface queues. You can not attach cake queue direct to a virtual interface such as bridge or pppoe client. Whitch make cake shaper useless in most case.I've seen very odd configurations such as use cake in simple queue with fast track enable and the tester said it "works". Mikrotik just let them to "guess" and never tells the user the correct way to configure cake.

/queue type
add cake-ack-filter=filter cake-diffserv=diffserv4 cake-mpu=84 cake-nat=yes cake-overhead=44 kind=cake name=CAKE_UP
add cake-diffserv=diffserv4 cake-mpu=84 cake-overhead=44 kind=cake name=CAKE_DOWN
/queue simple
add bucket-size=0.001/0.001 disabled=yes max-limit=960M/55M name=CAKE queue=CAKE_DOWN/CAKE_UP target=pppoe-ADSL

/queue type
add cake-ack-filter=filter cake-diffserv=diffserv4 cake-mpu=84 cake-nat=yes cake-overhead=44 kind=cake name=CAKE_UP
add cake-diffserv=diffserv4 cake-mpu=84 cake-overhead=44 kind=cake name=CAKE_DOWN
/queue tree
add bucket-size=0.001 disabled=yes limit-at=55M max-limit=55M name=UP packet-mark=no-mark parent=pppoe-ADSL priority=3 queue=CAKE_UP
add bucket-size=0.001 disabled=yes limit-at=940M max-limit=940M name=DOWN packet-mark=no-mark parent=SWITCH priority=4 queue=CAKE_DOWN

/queue type
add cake-bandwidth=940.0Mbps cake-diffserv=diffserv4 cake-mpu=84 cake-nat=yes cake-overhead=44 kind=cake name=CAKE_DL
add cake-ack-filter=filter cake-bandwidth=55.0Mbps cake-diffserv=diffserv4 cake-mpu=84 cake-nat=yes cake-overhead=44 kind=cake name=CAKE_UL
/queue simple

CAKE type with bandwidth setting detected, configure traffic limits within queue itself

add bucket-size=0.001/0.001 disabled=yes name=CAKE_SHAPE queue=CAKE_DL/CAKE_UL target=pppoe-ADSL

Yeah… there are some super interesting threads with @dthat and others here on setting up cake and fq_codel. With all disclaimers that I have no real idea what I’m doing, I think that I think the following after trying to follow queue discussions that are way above my pay grade:

You can change your wan to use fq_codel or even cake directly on the wan interface, but this seems to work only in one direction… egress?.. and I think it’s at the cost of not being able to set a max-limit. I think this may require the development/addition of bql to provide back pressure to allow these queue types to work better at line rate, as opposed to having a max-limit set… something… something. It’s unclear to me exactly what fq_codel or cake might do when attached to an interface without max-limit set, but it does seem that routeros is moving toward defaulting some interfaces to fq_codel (wifi? unclear), rather than hardware-only queue types, so perhaps fq_codel at least can provide some benefits without a max-limit set on Mikrotik. Perhaps it still divides things up and tries to service them fairly even without knowing the actual speed limits? I think you’re out of luck using this for the download direction, however, as I don’t think you can attach a queue type to the bridge without using queue trees.

If you search the forum for @anserk and others, you’ll see reference to a queue tree solution where you attach cake or fq_codel to your wan and your bridge through queue trees. This allows you to keep FastTrack enabled while using cake or fq_codel, but I think it also may potentially limit your bridge to less than line rate depending on your max_limit settings unless you do some mangle finagling? Not sure… just throwing it out there in case that’s a concern.

You say you don’t want to use a simple queue, but if your router can handle the processing demands without FastTrack enabled, putting cake or fq_codel on your wan works well and is easy to set up this way. If in doubt, go with all the default settings for fq_codel when adding it as a queue type. If in doubt, go with all the default settings for cake when adding it as a queue type EXCEPT you might want to check on NAT if your router is handling DNS lookups. As detailed above, be super careful setting the bandwidth limit in the cake queue itself (as opposed to in the simple queue settings), as this can make your… or at least my… router unresponsive and require at least a hard reset to get back to working. Either setting the bandwidth limit directly in the cake queue type is unsupported on Mikrotiks, or something I’ve done in the past trying this approach was just incorrect.