Akri
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Constraining Akri Containers' Resource Usage Currently, Akri's components (Controller, Agent, Discovery Handlers) do not have specified compute resource (Memory/CPU) requests or limits. This means there is no clarity on the maximum amount of resources Akri uses. > Note: brokers have been excluded from the analysis, since a user can provide any broker image; however, the ability to set broker resource limits and requests should be added to Akri's Helm charts. This documentation investigates Akri's components resource usage and defines requests and limits for each component based on the results. It walks through the steps described in [Daz Wilkin's blog](https://pretired.dazwilkin.com/posts/210305/) that investigated Akri resource usage using Virtical Pod Autoscaler (VPA). After the first round of investigation, the VPA recommended the [default minimum](https://github.com/FairwindsOps/charts/tree/master/stable/vpa) CPU (15m) and memory (100Mi) for all of Akri's components as lower bounds, targets, and uncapped targets. In response, the minimum values were set to 0 in the VPA to obtain the resulting subsequent values. > Note: Minimums were set by passing the following values into the [VPA](https://github.com/FairwindsOps/charts/tree/master/stable/vpa) Helm chart maintained by the Fairwinds team: > ```yaml > recommender: > extraArgs: > pod-recommendation-min-cpu-millicores: 0 > pod-recommendation-min-memory-mb: 0 > ``` ## Vertical Pod Autoscaler's resource recommendations ### Summary The Controller and Agent required slightly more compute resources than Discovery Handlers. Controller: ```yaml resources: requests: memory: "11Mi" cpu: "10m" limits: memory: "100Mi" cpu: "26m" ``` Agent: ```yaml resources: requests: memory: "11Mi" cpu: "10m" limits: memory: "79Mi" cpu: "26m" ``` All Discovery Handlers: ```yaml resources: requests: memory: "11Mi" cpu: "10m" limits: memory: "24Mi" cpu: "24m" ``` > Note: the udev Discovery Handler's upper bound required one less CPU unit; however, for consistency for the time being, all Discovery Handlers will get the same requests and limits. ### Change in recommendations over time The upper bound of all of the recommendations dropped overtime, starting high and then lowering as time passed. After letting Akri run overnight on a 2 node cluster with all Discovery Handlers and Configurations, the recommendations dropped with the upper bound dropping significantly. For example, at first the Controller's upper bound was ```yaml "upperBound": { "cpu": "2226m", "memory": "2327583916" } ``` By the next day, as the VPA gathered more information about usage trends, it dropped to the following: ```yaml "upperBound": { "cpu": "26m", "memory": "104857600" } ``` **VPA Memory Recommendations for Controller** ![VPA Memory Recommendations for Controller](https://i.imgur.com/GIP5Ggl.png) **VPA Memory Recommendations for Controller after Initial Spike** ![VPA Memory Recommendations for Controller after Initial Spike](https://i.imgur.com/1IkmK3P.png) The CPU upper bound recommendations also start extremely high, which may be skewing the final target and lower bounds if they take into account the upper bound, as they are consistently in the 0-3 range, jumping with each restart of the controller: ![VPA CPU Recommendations for Controller](https://i.imgur.com/8AtSrU5.png) > Note: the controller appeared to be restarting due to bubbled up connection errors to the Kubernetes API; however, the Controller can cleanly handle restarts. The bounds that the components settled at by the next day are what will be used; however, using Grafana to chart out the change in bounds overtime and as devices and nodes are added to the system could lead to a more accurate choice of bounds. All resource requests and limits will be customizable via Helm values. The VPA's, after running for 16 hours, settled on similar recommendations for all of Akri's components (Agent, Controller, Udev Discovery Handler, ONVIF Discovery Handler, OPC UA Discovery Handler, and debug echo Discovery Handler). They are as follows. ### Akri Controller Bounds ```yaml Container Recommendations: Container Name: akri-controller Lower Bound: Cpu: 10m Memory: 11120035 Target: Cpu: 11m Memory: 23574998 Uncapped Target: Cpu: 11m Memory: 23574998 Upper Bound: Cpu: 26m Memory: 104857600 ``` The recommendation suggests a request of 10m [Kubernetes CPU units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu), which is the equivalent of asking for 0.010 vCPUs/Cores, and a little under 11Mi of memory. The recommendations correlate with the following addition to the Agent DaemonSet YAML: ```yaml resources: requests: memory: "11Mi" cpu: "10m" limits: memory: "100Mi" cpu: "26m" ``` ### Akri Agent Bounds ```yaml Container Recommendations: Container Name: akri-agent Lower Bound: Cpu: 10m Memory: 11318184 Target: Cpu: 11m Memory: 23574998 Uncapped Target: Cpu: 11m Memory: 23574998 Upper Bound: Cpu: 26m Memory: 82840000 ``` The source of the memory values can be seen on the following graph. Note that actual usage was always below all recommendation types: ![VPA Memory Recommendations for Controller](https://i.imgur.com/aEaTogj.png) The actual CPU usage is also lower than all recommendations: ![VPA CPU Recommendations for Agent](https://i.imgur.com/VcYWR9y.png) The recommendation suggests a limit of 10m [Kubernetes CPU units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu), which is the equivalent of asking for 0.010 vCPUs/Cores, and ~11Mi of memory. The recommendations correlate with the following addition to the Agent DaemonSet YAML: ```yaml resources: requests: memory: "11Mi" cpu: "10m" limits: memory: "79Mi" cpu: "26m" ``` ### Akri Discovery Handlers #### Udev ```yaml Container Recommendations: Container Name: akri-udev-discovery Lower Bound: Cpu: 10m Memory: 11572964 Target: Cpu: 11m Memory: 11500000 Uncapped Target: Cpu: 11m Memory: 11500000 Upper Bound: Cpu: 23m Memory: 25041396 ``` The source of the memory values can be seen on the following graph. Note that actual usage was always below all recommendation types: ![VPA Memory Recommendations for Udev Discovery Handler](https://i.imgur.com/1mvCbef.png) The actual CPU usage is also lower than all recommendations: ![VPA CPU Recommendations for Udev Discovery Handler](https://i.imgur.com/uJ6o6b5.png) The recommendation suggests a limit of 10m [Kubernetes CPU units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu), which is the equivalent of asking for 0.010 vCPUs/Cores, and ~11Mi of memory. The recommendations correlate with the following addition to the Udev Discovery Handler DaemonSet YAML: ```yaml resources: requests: memory: "11Mi" cpu: "10m" limits: memory: "24Mi" cpu: "23m" ``` #### ONVIF ```yaml Container Recommendations: Container Name: akri-onvif-discovery Lower Bound: Cpu: 10m Memory: 11473094 Target: Cpu: 11m Memory: 11500000 Uncapped Target: Cpu: 11m Memory: 11500000 Upper Bound: Cpu: 24m Memory: 24976379 ``` The source of the memory values can be seen on the following graph. Note that actual usage was always below all recommendation types: ![VPA Memory Recommendations for ONVIF Discovery Handler](https://i.imgur.com/c1Kbuwl.png) The actual CPU usage is also lower than all recommendations: ![VPA CPU Recommendations for ONVIF Discovery Handler](https://i.imgur.com/HdDsrQd.png) The recommendation suggests a limit of 10m [Kubernetes CPU units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu), which is the equivalent of asking for 0.010 vCPUs/Cores, and ~11Mi of memory. The recommendations correlate with the following addition to the ONVIF Discovery Handler DaemonSet YAML: ```yaml resources: requests: memory: "11Mi" cpu: "10m" limits: memory: "24Mi" cpu: "24m" ``` #### OPC UA ```yaml Container Recommendations: Container Name: akri-opcua-discovery Lower Bound: Cpu: 10m Memory: 11472167 Target: Cpu: 11m Memory: 11500000 Uncapped Target: Cpu: 11m Memory: 11500000 Upper Bound: Cpu: 24m Memory: 25441349 ``` The source of the memory values can be seen on the following graph. Note that actual usage was always below all recommendation types: ![VPA Memory Recommendations for OPC UA Discovery Handler](https://i.imgur.com/OG7XswY.png) The actual CPU usage is also lower than all recommendations: ![VPA CPU Recommendations for OPC UA Discovery Handler](https://i.imgur.com/m7IaLha.png) The recommendation suggests a limit of 10m [Kubernetes CPU units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu), which is the equivalent of asking for 0.010 vCPUs/Cores, and ~11Mi of memory. The recommendations correlate with the following addition to the OPC UA Discovery Handler DaemonSet YAML: ```yaml resources: requests: memory: "11Mi" cpu: "10m" limits: memory: "24Mi" cpu: "24m" ``` #### Debug Echo ```yaml Container Recommendations: Container Name: akri-debug-echo-discovery Lower Bound: Cpu: 10m Memory: 11472285 Target: Cpu: 11m Memory: 11500000 Uncapped Target: Cpu: 11m Memory: 11500000 Upper Bound: Cpu: 24m Memory: 25382523 ``` The source of the memory values can be seen on the following graph. Note that actual usage was always below all recommendation types: ![VPA Memory Recommendations for Debug Echo Discovery Handler](https://i.imgur.com/6trDBB7.png) The actual CPU usage is also lower than all recommendations: ![VPA CPU Recommendations for Debug Echo Discovery Handler]![](https://i.imgur.com/4gSYQT6.png) The recommendation suggests a limit of 10m [Kubernetes CPU units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu), which is the equivalent of asking for 0.010 vCPUs/Cores, and ~11Mi of memory. The recommendations correlate with the following addition to the Debug Echo Discovery Handler DaemonSet YAML: ```yaml resources: requests: memory: "11Mi" cpu: "10m" limits: memory: "24Mi" cpu: "24m" ``` ### Akri Sample Brokers #### Kubectl top Current usage of the brokers ```shell NAME CPU(cores) MEMORY(bytes) debug-echo-broker-deployment-84bfc77467-86gc5 0m 8Mi debug-echo-broker-deployment-84bfc77467-cplpj 0m 8Mi debug-echo-broker-deployment-84bfc77467-f698d 0m 8Mi onvif-broker-deployment-86685869b6-426bb 898m 111Mi onvif-broker-deployment-86685869b6-cnvw9 897m 117Mi onvif-broker-deployment-86685869b6-wht77 900m 119Mi opcua-broker-deployment-64d8647f7-6hp4r 3m 72Mi opcua-broker-deployment-64d8647f7-9bqdb 2m 72Mi opcua-broker-deployment-64d8647f7-zcfs5 2m 72Mi udev-broker-deployment-599c8665bf-6hxkj 0m 2Mi udev-broker-deployment-599c8665bf-pdq4g 0m 2Mi udev-broker-deployment-599c8665bf-sqpkb 0m 2Mi ``` ![Broker Pod VPA Analysis Grafana Dashboard](https://i.imgur.com/Uoyc8bh.png) > Note: The OPC UA broker was deployed long after the others ## Kubectl top To check current usage of resources, use `kubectl top`. For example, `kubectl top pods` shows: ```shell NAME CPU(cores) MEMORY(bytes) akri-agent-daemonset-7p9p5 0m 6Mi akri-agent-daemonset-8hsrg 3m 10Mi akri-controller-deployment-85f76c5c8b-gn54p 0m 5Mi akri-debug-echo-discovery-daemonset-4ttsd 0m 2Mi akri-debug-echo-discovery-daemonset-nfsch 0m 2Mi akri-onvif-discovery-daemonset-fghzr 0m 4Mi akri-onvif-discovery-daemonset-xlt2f 0m 3Mi akri-opcua-discovery-daemonset-9bvh8 0m 2Mi akri-opcua-discovery-daemonset-wxl6c 0m 2Mi akri-udev-discovery-daemonset-cjbqv 0m 2Mi akri-udev-discovery-daemonset-nqmxq 0m 2Mi ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully