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

resource management with systemd
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Resource Management with systemd

LinuxCon North America 2013 Lennart Poettering September 2013

Lennart Poettering Resource Management with systemd

slide-2
SLIDE 2

Resource Management?

Lennart Poettering Resource Management with systemd

slide-3
SLIDE 3

Distributing available CPU, IO, and memory resources between services/applications

Lennart Poettering Resource Management with systemd

slide-4
SLIDE 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

slide-5
SLIDE 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

slide-6
SLIDE 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

slide-7
SLIDE 7

Control Groups

Lennart Poettering Resource Management with systemd

slide-8
SLIDE 8

Control Groups First used by systemd merely for grouping processes

Lennart Poettering Resource Management with systemd

slide-9
SLIDE 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

slide-10
SLIDE 10

systemd hides the fact that cgroups is used underneath

Lennart Poettering Resource Management with systemd

slide-11
SLIDE 11

systemd hides the fact that cgroups is used underneath cgroups are now an implementation detail

Lennart Poettering Resource Management with systemd

slide-12
SLIDE 12

(Can I still use cgroups without systemd?)

Lennart Poettering Resource Management with systemd

slide-13
SLIDE 13

(Can I still use cgroups without systemd?) (Why is this a job for systemd?)

Lennart Poettering Resource Management with systemd

slide-14
SLIDE 14

systemd’s resource management is based on units

Lennart Poettering Resource Management with systemd

slide-15
SLIDE 15

systemd’s resource management is based on units Services, Scopes, Slices

Lennart Poettering Resource Management with systemd

slide-16
SLIDE 16

Service = A group of processes, which systemd started based on unit configuration. (Example: apache.service)

Lennart Poettering Resource Management with systemd

slide-17
SLIDE 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

slide-18
SLIDE 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

slide-19
SLIDE 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

slide-20
SLIDE 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

slide-21
SLIDE 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

slide-22
SLIDE 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

slide-23
SLIDE 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

slide-24
SLIDE 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

slide-25
SLIDE 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

slide-26
SLIDE 26

Every user automatically gets his own slice when he logs in

Lennart Poettering Resource Management with systemd

slide-27
SLIDE 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

slide-28
SLIDE 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

slide-29
SLIDE 29

Example: + customer1.slice + customer1-apache.slice + apache@website1.service + apache@website2.service

Lennart Poettering Resource Management with systemd

slide-30
SLIDE 30

Arranging units in slices

Lennart Poettering Resource Management with systemd

slide-31
SLIDE 31

Arranging units in slices Slice=

Lennart Poettering Resource Management with systemd

slide-32
SLIDE 32

Setting resources on units

Lennart Poettering Resource Management with systemd

slide-33
SLIDE 33

Setting resources on units CPUAccounting=1, CPUShares=

Lennart Poettering Resource Management with systemd

slide-34
SLIDE 34

Setting resources on units CPUAccounting=1, CPUShares= MemoryAccounting=1, MemoryLimit=, MemorySoftLimit=

Lennart Poettering Resource Management with systemd

slide-35
SLIDE 35

Setting resources on units CPUAccounting=1, CPUShares= MemoryAccounting=1, MemoryLimit=, MemorySoftLimit= BlockIOAccounting=1, BlockIOWeight=, BlockIODeviceWeight=, BlockIOReadBandwidth=, BlockIOWriteBandwidth=

Lennart Poettering Resource Management with systemd

slide-36
SLIDE 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

slide-37
SLIDE 37

For services and slices in unit files or drop-ins:

Lennart Poettering Resource Management with systemd

slide-38
SLIDE 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

slide-39
SLIDE 39

At runtime with systemctl:

Lennart Poettering Resource Management with systemd

slide-40
SLIDE 40

At runtime with systemctl: $ systemctl set-property httpd.service CPUShares=600 MemoryLimit=500M

Lennart Poettering Resource Management with systemd

slide-41
SLIDE 41

. . . from your app via bus calls

Lennart Poettering Resource Management with systemd

slide-42
SLIDE 42

Monitoring

Lennart Poettering Resource Management with systemd

slide-43
SLIDE 43

Monitoring systemd-cgtop

Lennart Poettering Resource Management with systemd

slide-44
SLIDE 44

Monitoring systemd-cgtop Don’t forget to enable CPU/Memory/BlockIO accounting!

Lennart Poettering Resource Management with systemd

slide-45
SLIDE 45

There’s more to resource management! Nice=, IOSchedulingClass=, IOSchedulingPriority=, CPUSchedulingPolicy=, CPUSchedulingPriority=, CPUAffinity=, TimerSlackNS=, LimitCPU=, . . . ,

Lennart Poettering Resource Management with systemd

slide-46
SLIDE 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

slide-47
SLIDE 47

That’s all, folks!

Lennart Poettering Resource Management with systemd