blob: 4100f9aa7cf2550b47d2cd12b9f58687d5beaa5c [file] [log] [blame]
Neale Ranns05cac302019-05-28 11:09:40 +00001.. _scale:
2
3Scale
4-----
5
6The only limiting factor on FIB scale is the amount of memory
Neale Rannsdfd39542020-11-09 10:09:42 +00007allocated to each heap the FIB uses, and there are 2:
Neale Ranns05cac302019-05-28 11:09:40 +00008
Neale Ranns05cac302019-05-28 11:09:40 +00009* The main heap
10* The stats heap
11
12
Neale Rannsdfd39542020-11-09 10:09:42 +000013Main Heap
14^^^^^^^^^
Neale Ranns05cac302019-05-28 11:09:40 +000015
Neale Rannsdfd39542020-11-09 10:09:42 +000016The main heap is used to allocate all memory needed for the FIB
17data-structures. Each table, created by the user, i.e. with;
Neale Ranns05cac302019-05-28 11:09:40 +000018
19.. code-block:: console
20
21 $ ip table add 1
22
23or the default table, comprises 2 *ip4_fib_t* objects.
24The 'non-forwarding' *ip4_fib_t* contains all the entries in the table
25and, the 'forwarding' contains the entries that are matched against in
26the data-plane. The difference between the two sets are the entries
27that should not be matched in the data-plane.
28Each *ip4_fib_t* comprises an mtrie (for fast lookup in the data-plane)
29and a hash table per-prefix length (for lookup in the control plane).
30
31To see the amount of memory consumed by the IPv4 tables use:
32
33.. code-block:: console
34
35 vpp# sh ip fib mem
Neale Rannsdfd39542020-11-09 10:09:42 +000036 ipv4-VRF:0 mtrie:335744 hash:4663
37 ipv4-VRF:1 mtrie:333056 hash:3499
38 totals: mtrie:668800 hash:8162 all:676962
Neale Ranns05cac302019-05-28 11:09:40 +000039
40this output shows two 'empty' (i.e. no added routes) tables. Each
Neale Rannsdfd39542020-11-09 10:09:42 +000041mtrie uses about 150k of memory, so each table about 300k.
Neale Ranns05cac302019-05-28 11:09:40 +000042
43
44Below the output having added 1M, 2M and 4M routes respectively:
45
46.. code-block:: console
47
48 vpp# sh ip fib mem
49 ipv4-VRF:0 mtrie:335744 hash:4695
50 totals: mtrie:335744 hash:4695 all:340439
51
Neale Ranns05cac302019-05-28 11:09:40 +000052.. code-block:: console
53
54 vpp# sh ip fib mem
55 ipv4-VRF:0 mtrie:5414720 hash:41177579
56 totals: mtrie:5414720 hash:41177579 all:46592299
57
Neale Ranns05cac302019-05-28 11:09:40 +000058.. code-block:: console
59
60 vpp# sh ip fib mem
61 ipv4-VRF:0 mtrie:22452608 hash:168544508
62 totals: mtrie:22452608 hash:168544508 all:190997116
63
Neale Ranns05cac302019-05-28 11:09:40 +000064
Neale Rannsdfd39542020-11-09 10:09:42 +000065IPv6 also has the concept of forwarding and non-forwarding entries,
66however for IPv6 all the forwarding entries are stored in a single
67hash table (same goes for the non-forwarding). The key to the hash
68table includes the IPv6 table-id.
Neale Ranns05cac302019-05-28 11:09:40 +000069
70To see the amount of memory consumed by the IPv4 tables use:
71
72.. code-block:: console
73
74 vpp# sh ip6 fib mem
75 IPv6 Non-Forwarding Hash Table:
76 Hash table ip6 FIB non-fwding table
77 7 active elements 7 active buckets
78 1 free lists
79 0 linear search buckets
80 arena: base 7f2fe28bf000, next 803c0
81 used 525248 b (0 Mbytes) of 33554432 b (32 Mbytes)
82
83 IPv6 Forwarding Hash Table:
84 Hash table ip6 FIB fwding table
85 7 active elements 7 active buckets
86 1 free lists
87 0 linear search buckets
88 arena: base 7f2fe48bf000, next 803c0
89 used 525248 b (0 Mbytes) of 33554432 b (32 Mbytes)
90
91as we scale to 128k IPv6 entries:
92
93.. code-block:: console
94
95 vpp# sh ip6 fib mem
96 IPv6 Non-Forwarding Hash Table:
97 Hash table ip6 FIB non-fwding table
98 131079 active elements 32773 active buckets
99 2 free lists
100 [len 1] 2 free elts
101 0 linear search buckets
102 arena: base 7fed7a514000, next 4805c0
103 used 4720064 b (4 Mbytes) of 1073741824 b (1024 Mbytes)
104
105 IPv6 Forwarding Hash Table:
106 Hash table ip6 FIB fwding table
107 131079 active elements 32773 active buckets
108 2 free lists
109 [len 1] 2 free elts
110 0 linear search buckets
111 arena: base 7fedba514000, next 4805c0
112 used 4720064 b (4 Mbytes) of 1073741824 b (1024 Mbytes)
113
114and 256k:
115
116.. code-block:: console
117
118 vpp# sh ip6 fib mem
119 IPv6 Non-Forwarding Hash Table:
120 Hash table ip6 FIB non-fwding table
121 262151 active elements 65536 active buckets
122 2 free lists
123 [len 1] 6 free elts
124 0 linear search buckets
125 arena: base 7fed7a514000, next 880840
126 used 8915008 b (8 Mbytes) of 1073741824 b (1024 Mbytes)
127
128 IPv6 Forwarding Hash Table:
129 Hash table ip6 FIB fwding table
130 262151 active elements 65536 active buckets
131 2 free lists
132 [len 1] 6 free elts
133 0 linear search buckets
134 arena: base 7fedba514000, next 880840
135 used 8915008 b (8 Mbytes) of 1073741824 b (1024 Mbytes)
136
137and 1M:
138
139.. code-block:: console
140
141 vpp# sh ip6 fib mem
142 IPv6 Non-Forwarding Hash Table:
143 Hash table ip6 FIB non-fwding table
144 1048583 active elements 65536 active buckets
145 4 free lists
146 [len 1] 65533 free elts
147 [len 2] 65531 free elts
148 [len 4] 9 free elts
149 0 linear search buckets
150 arena: base 7fed7a514000, next 3882740
151 used 59254592 b (56 Mbytes) of 1073741824 b (1024 Mbytes)
152
153 IPv6 Forwarding Hash Table:
154 Hash table ip6 FIB fwding table
155 1048583 active elements 65536 active buckets
156 4 free lists
157 [len 1] 65533 free elts
158 [len 2] 65531 free elts
159 [len 4] 9 free elts
160 0 linear search buckets
161 arena: base 7fedba514000, next 3882740
162 used 59254592 b (56 Mbytes) of 1073741824 b (1024 Mbytes)
163
Neale Rannsdfd39542020-11-09 10:09:42 +0000164as can be seen from the output the IPv6 hash-table in this case was scaled
Neale Ranns05cac302019-05-28 11:09:40 +0000165to 1GB and 1million prefixes has used 56MB of it.
166
Neale Rannsdfd39542020-11-09 10:09:42 +0000167The main heap is also used to allocate objects that represent the FIB
Neale Ranns05cac302019-05-28 11:09:40 +0000168entries in the control and data plane (see :ref:`controlplane` and
169:ref:`dataplane`) such as *fib_entry_t* and *load_balance_t*. These come
170from the main heap because they are not protocol specific
171(i.e. they are used to represent either IPv4, IPv6 or MPLS
172entries).
173
174With 1M prefixes allocated the memory usage is:
175
176.. code-block:: console
177
178 vpp# sh fib mem
179 FIB memory
180 Tables:
181 SAFI Number Bytes
182 IPv4 unicast 1 33619968
183 IPv6 unicast 2 118502784
184 MPLS 0 0
185 IPv4 multicast 1 1175
186 IPv6 multicast 1 525312
187 Nodes:
188 Name Size in-use /allocated totals
189 Entry 72 1048589/ 1048589 75498408/75498408
190 Entry Source 40 1048589/ 1048589 41943560/41943560
191 Entry Path-Extensions 76 0 / 0 0/0
192 multicast-Entry 192 6 / 6 1152/1152
193 Path-list 40 18 / 18 720/720
194 uRPF-list 16 14 / 14 224/224
195 Path 72 22 / 22 1584/1584
196 Node-list elements 20 1048602/ 1048602 20972040/20972040
197 Node-list heads 8 24 / 24 192/192
198
199and with 2M
200
201.. code-block:: console
202
203 vpp# sh fib mem
204 FIB memory
205 Tables:
206 SAFI Number Bytes
207 IPv4 unicast 1 33619968
208 IPv6 unicast 2 252743040
209 MPLS 0 0
210 IPv4 multicast 1 1175
211 IPv6 multicast 1 525312
212 Nodes:
213 Name Size in-use /allocated totals
214 Entry 72 2097165/ 2097165 150995880/150995880
215 Entry Source 40 2097165/ 2097165 83886600/83886600
216 Entry Path-Extensions 76 0 / 0 0/0
217 multicast-Entry 192 6 / 6 1152/1152
218 Path-list 40 18 / 19 720/760
219 uRPF-list 16 18 / 18 288/288
220 Path 72 22 / 23 1584/1656
221 Node-list elements 20 2097178/ 2097178 41943560/41943560
222 Node-list heads 8 24 / 24 192/192
223
224However, the situation is not a simple as that. All of the 1M prefixes
225added above were reachable via the same next-hop, so the path-list
226(and path) they use is shared. As prefixes are added that use
227different (sets of) next-hops, the number of path-lists and paths
228requires will increase.
229
230
231Stats Heap
Neale Rannsdfd39542020-11-09 10:09:42 +0000232^^^^^^^^^^
Neale Ranns05cac302019-05-28 11:09:40 +0000233
234VPP collects statistics for each route. For each route VPP collects
235byte and packet counters for packets sent to the prefix (i.e. the
236route was matched in the data-plane) and packets sent via the prefix (i.e. the
237matching prefix is reachable through it - like a BGP peer). This
238requires 4 counters per route in the stats segment.
239
240Below shows the size of the stats segment with 1M, 2M and 4M routes.
241
242.. code-block:: console
243
244 total: 1023.99M, used: 127.89M, free: 896.10M, trimmable: 830.94M
245 total: 1023.99M, used: 234.14M, free: 789.85M, trimmable: 668.15M
246 total: 1023.99M, used: 456.83M, free: 567.17M, trimmable: 388.91M
247