Skip to main content
Version: 7.26

Routing Protocol Multi-core Support

RouterOS splits the routing work into tasks that run in separate processes, so that they can use more than one CPU core. One "main" task starts and stops the other tasks and processes the data between them. Each task can allocate "private" memory, which only that task can use, and "shared" memory, which all routing tasks can use.

/routing/stats/process lists the processes, the tasks each one runs, and their memory and CPU time.

Routing tasks​

The routing processes and their tasks, as /routing/stats/process names them (process ID in brackets):

  • routing tables and rib (main): the main task. It keeps the routing tables and calculates the routes.
  • fib (fib): updates the forwarding table (FIB).
  • routing policy configuration (policy): routing policy configuration.
  • configuration and reporting (static): handles the static route configuration and reporting, for example the route print command and SNMP monitoring.
  • BFD service (bfd): BFD protocol handling.
  • ospf, isis, rip (ospf, rip and a numeric ID for IS-IS): OSPF, IS-IS and RIP protocol handling.
  • pimsm (pim): PIM-SM.
  • ldp (mpls): LDP protocol handling.
  • evpn (numeric ID): EVPN handling.
  • fantasy (fantasy): generates dummy routing entries for testing purposes.
  • BGP service (bgp): BGP connection and configuration handling.
  • bgp-IP-<address> and bgp-output-<address> (bgp-remote-<n>): receiving and sending for the BGP session with that peer address. Their placement depends on the BGP affinity settings.

All of them, except the BGP session processes, run also when the protocol is not configured.

With single-process=yes in /routing/settings, the tasks run together in the main process after a reboot. BGP sessions with the default affinity still get processes of their own. The CLI reference row gives the default value.

Monitor the processes​

Print the processes with their tasks, memory use and CPU time. The full list has many columns: on a narrow terminal, print shows only the first ones, and print detail shows all of them.

[admin@MikroTik] > /routing/stats/process/print
Columns: TASKS, PRIVATE-MEM-BLOCKS, SHARED-MEM-BLOCKS, PSS, RSS, VMS, ID, PID, RPID, PROCESS-TIME, KERNEL-TIME, CUR-BUSY, MAX-BUSY, CUR-CALC, MAX-CALC
# TASKS PRIVATE-M SHARED-MEM-BLOCKS PSS RSS VMS ID PID RPID PROCESS-TIME KERNEL-TIME CUR-BUSY MAX-BUSY CUR-CALC MAX-CALC
0 routing tables 1536.0KiB 2048.0KiB 1078.0KiB 4048.0KiB 19.6MiB main 134 0 410ms 230ms 10ms 80ms 10ms 80ms
rib
1 fib 256.0KiB 0 718.0KiB 3660.0KiB 19.6MiB fib 156 1 20ms 90ms 210ms 210ms
2 routing policy configuration 256.0KiB 256.0KiB 689.0KiB 3472.0KiB 19.6MiB policy 161 1 10ms 100ms 100ms
3 configuration and reporting 512.0KiB 768.0KiB 727.0KiB 3600.0KiB 19.6MiB static 165 1 10ms 60ms 60ms
4 BFD service 256.0KiB 0 662.0KiB 3440.0KiB 19.6MiB bfd 166 1 10ms 50ms 50ms
5 ospf 1280.0KiB 512.0KiB 746.0KiB 3532.0KiB 19.6MiB ospf 170 1 50ms 50ms 50ms
6 pimsm 256.0KiB 0 670.0KiB 3448.0KiB 19.6MiB pim 173 1 10ms 40ms 40ms
7 ldp 256.0KiB 256.0KiB 706.0KiB 3572.0KiB 19.6MiB mpls 174 1 10ms 50ms 50ms
8 rip 256.0KiB 0 666.0KiB 3444.0KiB 19.6MiB rip 176 1 10ms 20ms 20ms
9 BGP service 256.0KiB 256.0KiB 764.0KiB 3652.0KiB 19.6MiB bgp 177 1 20ms
10 fantasy 256.0KiB 0 662.0KiB 3436.0KiB 19.6MiB fantasy 178 1 10ms 10ms 10ms
11 isis 256.0KiB 0 666.0KiB 3444.0KiB 19.6MiB 12 172 1 20ms 20ms
12 evpn 256.0KiB 0 666.0KiB 3440.0KiB 19.6MiB 13 175 1 10ms 20ms 20ms
13 bgp-IP-10.99.0.4 512.0KiB 768.0KiB 814.0KiB 3740.0KiB 19.6MiB bgp-remote-1 221 4 10ms 10ms
bgp-output-10.99.0.4
14 bgp-IP-10.99.0.2 512.0KiB 768.0KiB 821.0KiB 3784.0KiB 19.6MiB bgp-remote-2 222 4
bgp-output-10.99.0.2
15 bgp-IP-10.99.0.3 512.0KiB 768.0KiB 824.0KiB 3796.0KiB 19.6MiB bgp-remote-3 223 4
bgp-output-10.99.0.3

This router runs OSPF and has three BGP sessions, with the peers 10.99.0.2, 10.99.0.3 and 10.99.0.4. Each BGP session has a process of its own (bgp-remote-1 to bgp-remote-3) that runs both its input and its output task. The /routing/stats/memory menu shows the memory of each process by object type: reserved, used and free memory.

BGP sessions and affinity​

The input (receiving) and output (sending) of a BGP session can run in a process of their own or in a shared process. The input.affinity and output.affinity parameters of the connection or the template decide where they run:

  • When both are not set, each session gets one process that runs its input and its output.
  • input.affinity=alone runs the input of each session in a process of its own. Most likely this is the best option for a router with many cores and many peers.
  • input.affinity=main runs the input in the main process.
  • input.affinity set to remote-as, instance, afi or vrf tries to run the input of a new session in a process with sessions that have the same remote AS, instance, address family or VRF.
  • output.affinity takes the same values. output.affinity=input runs the output in the same process as the input, which is also what happens when output.affinity is not set.

A change of the affinity restarts the session. /routing/bgp/session shows the process of each session as a number in input.procid and output.procid. Number 1 is the main process.

On devices with few cores, adjusting affinity values can boost performance, because sharing data between tasks is slightly slower than processing the same data within a single task. For example, on single-core or dual-core devices, running input and output in the main process (input.affinity=main) can improve performance.

BGP uses up to 100 processes for its sessions. When all of them are in use, new sessions share the existing session processes.

Example: separate the output of each session​

Run the output of every BGP session in a process of its own. The command restarts all BGP sessions:

/routing/bgp/connection
set [find] output.affinity=alone

Each session now has one process for its input and one for its output:

[admin@MikroTik] > /routing/stats/process/print proplist=tasks,id,pid where id~"bgp"
Columns: TASKS, ID, PID
# TASKS ID PID
9 BGP service bgp 177
13 bgp-IP-10.99.0.2 bgp-remote-1 221
14 bgp-output-10.99.0.2 bgp-remote-2 222
15 bgp-IP-10.99.0.3 bgp-remote-3 223
16 bgp-output-10.99.0.3 bgp-remote-4 224
17 bgp-IP-10.99.0.4 bgp-remote-5 225
18 bgp-output-10.99.0.4 bgp-remote-6 226

Example: run BGP in the main process​

Run the input and output of every BGP session in the main process, and remove the output setting of the previous example:

/routing/bgp/connection
set [find] input.affinity=main
unset [find] output.affinity

The input and output tasks of the sessions now run in the main process (routing tables):

[admin@MikroTik] > /routing/stats/process/print proplist=tasks,id,pid where id=main or id~"bgp"
Columns: TASKS, ID, PID
# TASKS ID PID
0 routing tables main 134
rib
bgp-IP-10.99.0.4
bgp-output-10.99.0.4
bgp-IP-10.99.0.2
bgp-output-10.99.0.2
bgp-IP-10.99.0.3
bgp-output-10.99.0.3
9 BGP service bgp 177

Routing table update mechanism​

The illustration shows how the routing table update mechanism works.

Seven numbered panels of the routing table update: updated routes, current routes with protocol outputs, route calculation, publishing and cleanup

Routing protocols continuously loop through the following procedures:

  • The "main" process waits for updates from other sub-tasks (1).
  • "main" starts calculating new routes (2-4) if:
    • an update from a sub-task is received;
    • the protocol has not published all routes;
    • the configuration or link state has changed.
  • During new route calculation (5), the following events occur:
    • all received updates are applied to the routes;
    • gateway reachability is determined;
    • recursive routes are resolved.
  • The "publish" event runs, publishing "current" routes. During this phase, "current" routes do not change, but protocols can still receive and send updates (6).
  • Perform cleanup and free unused memory (7). At this step, anything no longer used in the new "current" table is removed (routes, attributes and other data).

Consider "updated" and "current" as two copies of the routing table. The "current" table (2) is used at the moment, while "updated" (1) is the table of candidate routes to be published in the next publish event (3 and 4). This method prevents protocols from filling memory with buffered updates while the "main" process performs "publish". Instead, protocols send the newest updates directly to the main process, which then copies the new updates into the "updated" table. OSPF is slightly more complicated: it internally has a similar process to select current OSPF routes, which are then sent to the "main" for further processing.