resource management with systemd
play

Resource Management with systemd LinuxCon North America 2013 - PowerPoint PPT Presentation

Resource Management with systemd LinuxCon North America 2013 Lennart Poettering September 2013 Lennart Poettering Resource Management with systemd Resource Management? Lennart Poettering Resource Management with systemd Distributing


  1. Resource Management with systemd LinuxCon North America 2013 Lennart Poettering September 2013 Lennart Poettering Resource Management with systemd

  2. Resource Management? Lennart Poettering Resource Management with systemd

  3. Distributing available CPU, IO, and memory resources between services/applications Lennart Poettering Resource Management with systemd

  4. Distributing available CPU, IO, and memory resources between services/applications On embedded: limited resources, lots of things to run Lennart Poettering Resource Management with systemd

  5. Distributing available CPU, IO, and memory resources between services/applications On embedded: limited resources, lots of things to run On servers: a lot of resources, maximization of density Lennart Poettering Resource Management with systemd

  6. Distributing available CPU, IO, and memory resources between services/applications On embedded: limited resources, lots of things to run On servers: a lot of resources, maximization of density Underlying technology for systemd: Linux kernel control groups Lennart Poettering Resource Management with systemd

  7. Control Groups Lennart Poettering Resource Management with systemd

  8. Control Groups First used by systemd merely for grouping processes Lennart Poettering Resource Management with systemd

  9. Control Groups First used by systemd merely for grouping processes Original purpose from the kernel side though: resource management Lennart Poettering Resource Management with systemd

  10. systemd hides the fact that cgroups is used underneath Lennart Poettering Resource Management with systemd

  11. systemd hides the fact that cgroups is used underneath cgroups are now an implementation detail Lennart Poettering Resource Management with systemd

  12. (Can I still use cgroups without systemd?) Lennart Poettering Resource Management with systemd

  13. (Can I still use cgroups without systemd?) (Why is this a job for systemd?) Lennart Poettering Resource Management with systemd

  14. systemd’s resource management is based on units Lennart Poettering Resource Management with systemd

  15. systemd’s resource management is based on units Services, Scopes, Slices Lennart Poettering Resource Management with systemd

  16. Service = A group of processes, which systemd started based on unit configuration. (Example: apache.service) Lennart Poettering Resource Management with systemd

  17. Service = A group of processes, which systemd started based on unit configuration. (Example: apache.service) Scope = A group of processes, which others have started and registered using runtime APIs (Example: fedora17.scope) Lennart Poettering Resource Management with systemd

  18. Service = A group of processes, which systemd started based on unit configuration. (Example: apache.service) Scope = A group of processes, which others have started and registered using runtime APIs (Example: fedora17.scope) Slice = A unit to build a hierarchy to place service and scope units in (Example: customer1.slice) Lennart Poettering Resource Management with systemd

  19. Service = A group of processes, which systemd started based on unit configuration. (Example: apache.service) Scope = A group of processes, which others have started and registered using runtime APIs (Example: fedora17.scope) Slice = A unit to build a hierarchy to place service and scope units in (Example: customer1.slice) (User sessions, containers, VMs are exposed as scopes.) Lennart Poettering Resource Management with systemd

  20. Service = A group of processes, which systemd started based on unit configuration. (Example: apache.service) Scope = A group of processes, which others have started and registered using runtime APIs (Example: fedora17.scope) Slice = A unit to build a hierarchy to place service and scope units in (Example: customer1.slice) (User sessions, containers, VMs are exposed as scopes.) Slices do not contain process, they simply organize a hierarchy in which scopes and services may be placed, which in turn contain the processes Lennart Poettering Resource Management with systemd

  21. Slices are organized in a hierarchy, the name of a slice unit corresponds with the path to the location in the hierarchy. Lennart Poettering Resource Management with systemd

  22. Slices are organized in a hierarchy, the name of a slice unit corresponds with the path to the location in the hierarchy. Examples: foo.slice, foo-bar.slice customer1.slice, customer1-departmentA.slice, customer1-departmentA-projectalpha.slice Lennart Poettering Resource Management with systemd

  23. Slices are organized in a hierarchy, the name of a slice unit corresponds with the path to the location in the hierarchy. Examples: foo.slice, foo-bar.slice customer1.slice, customer1-departmentA.slice, customer1-departmentA-projectalpha.slice systemd-cgls is your friend! Lennart Poettering Resource Management with systemd

  24. Default: + system.slice | + systemd-udevd.service | + systemd-logind.service | + systemd-journald.service | + apache.service | + mysql.service + user.slice | + user-100.slice | + session-1.scope + machine.slice + fedora-20.scope Lennart Poettering Resource Management with systemd

  25. Example: + customer1.slice | + customer1-apache.service | + customer1-mariadb.service + customer2.slice + customer2-departmentA.slice | + customer2-departmentA-apache.service | + customer2-departmentA-mariadb.service + customer2-departmentB.slice + customer2-departmentA-postgresql.service + customer2-departmentA-rhel7.scope + customer2-departmentA-rhel6.scope Lennart Poettering Resource Management with systemd

  26. Every user automatically gets his own slice when he logs in Lennart Poettering Resource Management with systemd

  27. Every user automatically gets his own slice when he logs in Every user session automatically gets its own scope within that slice Lennart Poettering Resource Management with systemd

  28. Every user automatically gets his own slice when he logs in Every user session automatically gets its own scope within that slice Every templated service automatically gets a slice for grouping all instances Lennart Poettering Resource Management with systemd

  29. Example: + customer1.slice + customer1-apache.slice + apache@website1.service + apache@website2.service Lennart Poettering Resource Management with systemd

  30. Arranging units in slices Lennart Poettering Resource Management with systemd

  31. Arranging units in slices Slice= Lennart Poettering Resource Management with systemd

  32. Setting resources on units Lennart Poettering Resource Management with systemd

  33. Setting resources on units CPUAccounting=1, CPUShares= Lennart Poettering Resource Management with systemd

  34. Setting resources on units CPUAccounting=1, CPUShares= MemoryAccounting=1, MemoryLimit=, MemorySoftLimit= Lennart Poettering Resource Management with systemd

  35. Setting resources on units CPUAccounting=1, CPUShares= MemoryAccounting=1, MemoryLimit=, MemorySoftLimit= BlockIOAccounting=1, BlockIOWeight=, BlockIODeviceWeight=, BlockIOReadBandwidth=, BlockIOWriteBandwidth= Lennart Poettering Resource Management with systemd

  36. Setting resources on units CPUAccounting=1, CPUShares= MemoryAccounting=1, MemoryLimit=, MemorySoftLimit= BlockIOAccounting=1, BlockIOWeight=, BlockIODeviceWeight=, BlockIOReadBandwidth=, BlockIOWriteBandwidth= DeviceAllow=, DevicePolicy= Lennart Poettering Resource Management with systemd

  37. For services and slices in unit files or drop-ins: Lennart Poettering Resource Management with systemd

  38. For services and slices in unit files or drop-ins: [Unit] Description=Foobar Daemon [Service] ExecStart=/usr/bin/foobard CPUShares=600 MemoryLimit=500M Lennart Poettering Resource Management with systemd

  39. At runtime with systemctl: Lennart Poettering Resource Management with systemd

  40. At runtime with systemctl: $ systemctl set-property httpd.service CPUShares=600 MemoryLimit=500M Lennart Poettering Resource Management with systemd

  41. . . . from your app via bus calls Lennart Poettering Resource Management with systemd

  42. Monitoring Lennart Poettering Resource Management with systemd

  43. Monitoring systemd-cgtop Lennart Poettering Resource Management with systemd

  44. Monitoring systemd-cgtop Don’t forget to enable CPU/Memory/BlockIO accounting! Lennart Poettering Resource Management with systemd

  45. There’s more to resource management! Nice=, IOSchedulingClass=, IOSchedulingPriority=, CPUSchedulingPolicy=, CPUSchedulingPriority=, CPUAffinity=, TimerSlackNS=, LimitCPU=, . . . , Lennart Poettering Resource Management with systemd

  46. There’s more to resource management! Nice=, IOSchedulingClass=, IOSchedulingPriority=, CPUSchedulingPolicy=, CPUSchedulingPriority=, CPUAffinity=, TimerSlackNS=, LimitCPU=, . . . , Not dynamically changable for units Lennart Poettering Resource Management with systemd

  47. That’s all, folks! Lennart Poettering Resource Management with systemd

Recommend


More recommend