Dynamic resource allocation in network device
A method of operating a network device includes: monitoring, by a controller of the network device, utilization of memory resources of the network device; sending, by the controller, information regarding the utilization of the memory resources to a remote server, where the remote server is connected to the network device through a network connection; receiving, by the controller, a first request from the remote server to change memory allocation for a first memory region of the memory resources, where the first memory region is used by a software feature of the network device; and in response to the first request, adjusting, by the controller, a size of the first memory region without restarting the network device.
1 . A method of operating a network device, the method comprising:
monitoring, by a controller of the network device, utilization of memory resources of the network device;
storing, by the controller, a hash table in a first memory region of the memory resources, wherein the first memory region is a logic memory region that includes one or more physical memory regions of the memory resources, wherein entries of the hash table are stored in at least one of the one or more physical memory regions;
sending, by the controller, information regarding the utilization of the memory resources to a remote server, wherein the remote server is connected to the network device through a network connection;
receiving, by the controller, a first request from the remote server to reduce a size of the first memory region by a first amount; and
in response to the first request, adjusting, by the controller, the size of the first memory region without restarting the network device, wherein the controller is configured to, in response to the first request, reduce the size of the first memory region by:
determining sizes of the one or more physical memory regions and numbers of the entries of the hash table stored in the one or more physical memory regions; and
in response to determining that a physical memory region of the first memory region has a memory size no less than the first amount and stores no entry of the hash table, releasing the physical memory region from the first memory region.
2 . The method of claim 1 , wherein the network device is a router or a switch, wherein the controller comprises a processor.
3 . The method of claim 1 , wherein the controller is further configured to, in response to the first request, reduce the size of the first memory region by:
after releasing the physical memory region, sending, by the controller, a message to the remote server to update the information regarding the utilization of the memory resources.
4 . The method of claim 1 , wherein the controller is further configured to, in response to the first request, reduce the size of the first memory region by:
in response to determining that the sizes of the one or more physical memory regions are smaller than the first amount, or that the entries of the hash table are stored in all of the one or more physical memory regions, reporting, by the controller, a failure of reducing the size of the first memory region by sending a message to the remote server.
5 . The method of claim 1 , wherein the first memory region includes a first physical memory region and a second physical memory region, wherein the entries of the hash table include first entries stored in a first portion of the first physical memory region, and include second entries stored in a second portion of the second physical memory region, wherein the method further comprises:
receiving, by the controller, a second request from the remote server to reduce the size of the first memory region; and
in response to the second request, reducing, by the controller, the size of the first memory region without restarting the network device, wherein the controller is configured to, in response to the second request, reduce the size of the first memory region by:
moving the second entries of the hash table from the second physical memory region to the first physical memory region; and
after moving the second entries of the hash table, releasing the second physical memory region from the first memory region.
6 . The method of claim 5 , wherein the controller is further configured to, in response to the second request, reduce the size of the first memory region by:
after releasing the second physical memory region, sending, by the controller, a message to the remote server to update the information regarding the utilization of the memory resources.
7 . The method of claim 5 , wherein the method further comprises:
storing an aging table corresponding to the hash table in the first memory region, wherein entries of the aging table include first entries stored in the first portion of the first physical memory region, and include second entries stored in the second portion of the second physical memory region, wherein the controller is configured to, in response to the second request, reduce the size of the first memory region by:
moving the second entries of the hash table and corresponding second entries of the aging table from the second physical memory region to the first physical memory region; and
after moving the second entries of the hash table and the corresponding second entries of the aging table, releasing the second physical memory region from the first memory region.
8 . The method of claim 1 , wherein the method further comprises:
receiving, by the controller, a second request from the remote server to increase the size of the first memory region by a second amount; and
in response to the second request, increasing, by the controller, the size of the first memory region without restarting the network device, wherein the controller is configured to, in response to the second request, increase the size of the first memory region by:
determining whether one or more unallocated physical memory regions of the memory resources having a total memory size no less than the second amount are available;
in response to determining that the one or more unallocated physical memory regions are available, allocating the one or more unallocated physical memory regions to the first memory region; and
updating the information regarding the utilization of the memory resources by sending a message to the remote server.
9 . The method of claim 8 , wherein the controller is further configured to, in response to the second request, increase the size of the first memory region by:
in response to determining that the one or more unallocated physical memory regions are not available, reporting a failure of increasing the size of the first memory region by sending another message to the remote server.
10 . The method of claim 1 , wherein the first memory region is used by a software feature of the network device.
11 . The method of claim 10 , further comprising, performing, by the controller, a routing function for the software feature using the hash table.
12 . A method of operating a network device, the method comprising:
assigning, by a controller of the network device, a first memory region of memory resources of the network device to a first software feature of the network device, wherein a hash table comprising a plurality of entries is configured to be stored in the first memory region, wherein the first memory region is a logic memory region that includes one or more physical memory regions of the memory resources, wherein the entries of the hash table are configured to be stored in various portions of the one or more physical memory regions;
receiving, by the controller, a first request from a server to reduce a size of the first memory region by a first amount, wherein the server is connected to the network device through a network connection; and
in response to the first request, reducing, by the controller, the size of the first memory region while the network device stays powered on, wherein the controller is configured to, in response to the first request, reduce the size of the first memory region by:
determining sizes of the one or more physical memory regions and determining numbers of the entries of the hash table stored in the one or more physical memory regions; and
in response to determining that a physical memory region of the first memory region has a memory size no less than the first amount and stores no entry of the hash table, releasing the physical memory region from the first memory region for use by other software features.
13 . The method of claim 12 , wherein the first memory region includes a first physical memory region and a second physical memory region of the memory resources, wherein the entries of the hash table include first entries stored in a first portion of the first physical memory region, and include second entries stored in a second portion of the second physical memory region, wherein the method further comprises:
receiving, by the controller, a second request from the server to reduce the size of the first memory region; and
in response to the second request, reducing, by the controller, the size of the first memory region while the network device stays powered on, wherein the controller is configured to, in response to the second request, reduce the size of the first memory region by:
moving the second entries of the hash table from the second physical memory region to the first physical memory region; and
after moving the second entries of the hash table, releasing the second physical memory region from the first memory region for use by the other software features.
14 . The method of claim 12 , wherein the method further comprises:
receiving, by the controller, a second request to increase the size of the first memory region by a second amount; and
in response to the second request, increasing, by the controller, the size of the first memory region while the network device stays powered on, wherein the controller is configured to, in response to the second request, increase the size of the first memory region by:
determining whether one or more unallocated physical memory regions having a total memory size no less than the second amount are available in the memory resources; and
in response to determining that the one or more unallocated physical memory regions are available, allocating the one or more unallocated physical memory regions to the first memory region.
15 . The method of claim 12 , wherein the first software feature of the network device uses the hash table for performing functions used for routing data packets.
16 . A network device comprising:
a controller comprising one or more processors;
memory resources comprising a plurality of memory regions; and
a non-transitory computer-readable medium comprising instructions executable by the one or more processors to:
monitor utilization of the memory resources;
send information regarding the utilization of the memory resources to a remote server, wherein the remote server is connected to the network device through a network connection;
receive a first request from the remote server to reduce a size of a first memory region of the memory resources by a first amount, wherein the first memory region is configured to store a hash table, wherein the hash table comprises a plurality of entries, wherein the first memory region is a logic memory region that includes one or more physical memory regions of the memory resources, wherein the entries of the hash table are configured to be stored in various portions of the one or more physical memory regions; and
in response to the first request, reduce the size of the first memory region without restarting the network device, comprising:
determining sizes of the one or more physical memory regions and determining numbers of the entries of the hash table stored in the one or more physical memory regions; and
in response to determining that a physical memory region of the first memory region has a memory size no less than the first amount and stores no entry of the hash table, releasing the physical memory region from the first memory region.
17 . The network device of claim 16 , wherein the first memory region includes a first physical memory region and a second physical memory region of the memory resources, wherein the entries of the hash table include first entries stored in a first portion of the first physical memory region, and include second entries stored in a second portion of the second physical memory region, wherein the non-transitory computer-readable medium further comprises instructions executable by the one or more processors to:
receive a second request from the remote server to reduce the size of the first memory region; and
in response to the second request, reduce the size of the first memory region while the network device stays powered on, comprising:
moving the second entries of the hash table from the second physical memory region to the first physical memory region; and
after moving the second entries of the hash table, releasing the second physical memory region from the first memory region for use by the other software features of the network device.
18 . The network device of claim 16 , wherein the first memory region is used by a software feature of the network device.
19 . The network device of claim 18 , wherein the controller is configured to perform a routing function using the hash table.
20 . A system comprising:
the network device of claim 16 ; and
the remote server, wherein the remote server is configured to:
detect an under-utilization condition for the first memory region based on the information regarding the utilization of the memory resources; and
in response to detecting the under-utilization condition, send the first request to the network device to reduce the size of the first memory region.