CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
Performance ¡Tuning ¡and ¡ Debugging ¡
Don ¡Porter ¡
Performance Tuning and Debugging Don Porter CSE/ISE 311: - - PowerPoint PPT Presentation
CSE/ISE 311: Systems Administra5on Performance Tuning and Debugging Don Porter CSE/ISE 311: Systems Administra5on Why is my applica3on slow? No silver
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
Don ¡Porter ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
– Science: ¡Measure ¡performance, ¡test ¡hypotheses ¡ – Art: ¡Finding ¡prac3cal ¡balances ¡of ¡concerns ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
– Requests ¡per ¡second ¡ – Transac3ons ¡per ¡minute ¡ – Higher ¡is ¡beMer ¡
– My ¡server ¡can ¡complete ¡an ¡HTTP ¡GET ¡in ¡.01 ¡seconds ¡ – Lower ¡is ¡beMer ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
0 ¡ 20 ¡ 40 ¡ 60 ¡ 80 ¡ 100 ¡ 120 ¡ 0 ¡ 25 ¡ 50 ¡ 75 ¡ 100 ¡ 125 ¡ 150 ¡ 175 ¡ 200 ¡
% ¡Maximum ¡Throughput ¡
Load ¡(%) ¡ Ideal ¡ Realis3c ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
0 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ 0 ¡ 25 ¡ 50 ¡ 75 ¡ 100 ¡ 125 ¡ 150 ¡ 175 ¡ 200 ¡
Latency ¡
Load ¡(%) ¡
Ideal ¡
Ideal ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
0 ¡ 100 ¡ 200 ¡ 300 ¡ 400 ¡ 500 ¡ 600 ¡ 0 ¡ 25 ¡ 50 ¡ 75 ¡ 100 ¡ 125 ¡ 150 ¡ 175 ¡ 200 ¡
Latency ¡
Load ¡(%) ¡ Ideal ¡ Realis3c ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
throughput ¡would ¡stay ¡constant ¡
they ¡are ¡overloaded ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
hMp://lwn.net/images/2010/atop/atopshot.png ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
– CPU ¡ – Memory ¡ – Disk ¡ – Network ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
– Actually ¡degrades ¡gracefully ¡in ¡most ¡cases ¡
responsive ¡
is ¡used ¡trying ¡to ¡compensate ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
CPU ¡
– Less ¡than ¡1, ¡the ¡CPU ¡is ¡idle ¡ – Higher ¡than ¡1 ¡is ¡ok, ¡just ¡means ¡CPU ¡is ¡fully ¡u3lized ¡ – Very ¡high ¡values ¡(>8) ¡can ¡indicate ¡a ¡problem ¡
$ uptime 20:10:13 up 20 days, 11:08, 5 users, load average: 0.00, 0.03, 0.05
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
– OSes ¡over-‑commit ¡memory ¡to ¡applica3ons ¡ – In ¡other ¡words, ¡if ¡I ¡have ¡1GB ¡RAM, ¡I ¡can ¡have ¡5 ¡ applica3ons ¡that ¡all ¡think ¡they ¡have ¡300 ¡MB ¡ – How ¡is ¡this ¡possible? ¡ – Swapping ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
away ¡from ¡applica3ons ¡ ¡
– Save ¡the ¡contents ¡to ¡disk ¡ – Reuse ¡the ¡RAM ¡
memory, ¡the ¡applica3on ¡is ¡interrupted, ¡OS ¡no3fied ¡
– OS ¡has ¡to ¡then ¡find ¡free ¡RAM, ¡replace ¡contents ¡for ¡app ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
– You ¡very ¡rarely ¡wait ¡for ¡them ¡before ¡making ¡progress ¡ – Except ¡when ¡swapping ¡
unlikely-‑to-‑be-‑used ¡data ¡to ¡swap ¡out ¡
– In ¡the ¡best ¡case, ¡things ¡slow ¡down ¡a ¡bit, ¡and ¡then ¡return ¡to ¡ normal ¡
RAM ¡
– Called ¡thrashing ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
RAM ¡
– It ¡is ¡cheap, ¡and ¡more ¡RAM ¡is ¡cheaper ¡now ¡than ¡when ¡you ¡ bought ¡the ¡computer ¡
cache ¡the ¡file ¡system ¡contents, ¡so ¡don’t ¡be ¡mislead ¡if ¡ total ¡RAM ¡usage ¡is ¡near ¡100% ¡
– Look ¡at ¡swap ¡to ¡detect ¡insufficient ¡RAM ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
enough ¡memory ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
crisis ¡
swap ¡data. ¡ ¡This ¡can ¡get ¡out ¡of ¡whack ¡
– /proc/sys/vm/swappiness ¡
release ¡that ¡set ¡the ¡default ¡too ¡high, ¡in ¡order ¡for ¡a ¡ nearly ¡idle ¡system ¡to ¡be ¡usable ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
dropped ¡
– But ¡the ¡other ¡end ¡usually ¡retries ¡
– AMack ¡(denial ¡of ¡service, ¡brute-‑force ¡password ¡guessing, ¡ spam, ¡etc) ¡ – Legi3mate ¡overload ¡(slashdoMed ¡website, ¡peak ¡usage ¡ 3me) ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
prac3ce ¡can ¡help ¡to ¡reduce ¡wasteful ¡traffic ¡
– Firewall, ¡denyhosts, ¡spam ¡filter, ¡etc. ¡ – For ¡DoS, ¡there ¡are ¡also ¡quality-‑of-‑service ¡tools ¡on ¡many ¡ network ¡devices ¡to ¡limit ¡the ¡share ¡of ¡packets ¡delivered ¡ from ¡any ¡one ¡source ¡
servers ¡and ¡a ¡load-‑balancer ¡
– Like ¡round-‑robin ¡DNS ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
– (Implicitly ¡when ¡thrashing ¡swap) ¡ – Actual ¡disk-‑intensive ¡workloads ¡(e.g., ¡database) ¡ – And ¡when ¡disk ¡is ¡nearing ¡end-‑of-‑life ¡
– Most ¡disk ¡requests ¡are ¡asynchronous ¡ – Most ¡disk-‑intensive ¡applica3ons ¡inherently ¡rate-‑limited ¡
– Heavy ¡remapping ¡yields ¡poor ¡scheduling ¡ – For ¡SSDs, ¡internal ¡bookkeeping ¡can ¡take ¡longer ¡as ¡the ¡ device ¡ages ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
replace ¡it ¡
– You ¡also ¡don’t ¡want ¡to ¡lose ¡data ¡
these ¡are ¡increasingly ¡uncommon ¡
– Running ¡a ¡“defragmenter” ¡can ¡help ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
– Applica3on ¡performance ¡ – Microbenchmarks ¡(e.g., ¡lmbench) ¡
– Has ¡my ¡disk ¡bandwidth ¡degraded? ¡
CSE/ISE ¡311: ¡Systems ¡Administra5on ¡
useful ¡system ¡sta3s3cs ¡
– Lots ¡of ¡goodies ¡in ¡/proc ¡
CPU ¡3me ¡to ¡important ¡applica3ons ¡