Pavel Trukhanov, "Ăśberwachung von Postgres durch USE und RED"
Es gibt zwei Methoden zur Leistungsüberwachung: USE (Utilization, Saturation, Errors) von Brendan Gregg und RED (Requests, Errors, Durations) von Tom Wilkie. In meinem Vortrag möchte ich darüber sprechen, wie wir uns auf sie konzentriert haben, und weiter navigieren, wenn wir die Postgres-Überwachung in okmeter.io implementieren.

. Okmeter. , , Postgres , . , , , , , USE RED , Postgres.

, . , .

, , , , . - . performance - , , , , .

, , , Postgres – , , . , - , , , . - , . - , , .

USE. , . , , . , , saturation , .

, ? , pg_stat_activity . ? , . , - , . , , . - , - , , .

? «», CPU Usage, , iostat – . , . , , . , , . .

, , , Postgres. , Postgres . . , , . Data Egret. , .

- ?

. . , Postgres , connection connection .

. . , . – - . , , . , , , .
: « ?». , SpinLock - , , , . CPU usage , .
– . , , , , - , , , , - .
? , capacity. 100 %, , , . .
. , . , . . , . , . . .
. - , capacity. , capacity ? . . saturation, . , . , .
Postgres.

pg_stat_activity. - . , . . : 300 connection . , - . , , - .

, . , , . - , , capacity , . . , Postgres max connections.

, state connection, , , idle, . . connection , . - idle in transaction. , , . active, - .

, , . , . ? . , - , . – pool connections, – , , , , . – , . - : locks - .

, , , .

- , , active 5 % connections. 95 % . . , .

, . , connections .
?

, . ? 100 connections, max connections , setting’, . , . , 100 %. , – . - . , . - , - .

saturation, util ? Saturation , utilization 100 % . , , , utilization 100? , .
, , CPU usage , load avarage . , 100 %, saturation . Load avarage — saturation, - . runnable , . . , , , .
, CPU usage . ? . load avarage. Load avarage , . , - . . response .

. - – idle in transaction.

. . - , . saturation .

idle. max connections, . , . -.

, select’ pg_stat_activity connections, waiting try. . . active state, - , -. waiting.
, . utilization connection pool 100 %.

, .

waiting ? . , - saturation , . . stack Postgres, , - - . .

– locks. , lock. , locks - , , connections. , locks.

. . . - lock , .

lock – space , – . , , lock . , , connections, locks, — saturation lock.

Postgres , connection . TCP-. TCP-. Post master . , , , «reset». time wait .
? , connections .

connections .

, connection pool . , , , , . ? - . ? -, . connections 5 000. Postgres . ? - connections. , , .

TCP . time wait, , - Postgres - , .

, connect? postmaster , connections backlog list . , search, backlog 100. . 100 %. – , - – saturation. – .

, backlog , reset.

, . Postgres , TCP «».

RED, USE? DBA, , , , - . , - . - , . . , Postgres .

RED, , , , :
- ,
- ,
- .

Postgres. , . , - . . - , .

rollbacks, , 6 , , , , , search , . . , - .
, RED . , . ? , . , , . , .

queries . - - . 8 , .

, - . . select , .

. , - , . . - . . - . , . . . : « , », , .

, . pg_stat_statements , . . , , . . , . – . . , , - , , . .

slow log. Slow log – durations . , . . , , - , .

, . , - , .

. , - . . , , . – , .

. - .

, , - . - , .

, . , . , , . .

, . USE, RED, ad-hoc , ad-hoc tools - , , , , .
.
Postgres, USE, RED ? . . .
Okmeter, . , - , . , , , , . , - , USE, RED. , . , , , saturation . , , , saturation . , . , - . , , , . , , .
! ! , 4- .
4 – USE RED. , USE, durations. errors . RED , requests durations. - , USE RED . . . - . , , .
– instance.
, ? – . – , requests . .
, !
! . – , - , , . , , . .? . . ?
, . , . , . . , , , , , USE . , , , , , selects, , , requests . , requests .
, , , , ?
. , . , , . , . . , . . . , . - , , . . , queries . - . , .
, , Postgres . , . , .
! , instance Postgres - . , ? , BD .
. – . , , , , , . , , - . , . .
Der zweite Weg, den wir bekämpfen, ist die Optimierung. Wir optimieren, was wir tun. Tatsächlich fordert Okmeter diese Ansichten regelmäßig, aber ziemlich selten, einmal pro Minute an.
Das heiĂźt, es ist nicht Echtzeit?
Es ist eine schwierige Frage, was Echtzeit ist. Lassen Sie uns dies separat diskutieren. Die Auslastung ist jedoch durch die Anzahl der von Ihnen gestellten Anfragen begrenzt. Diese Anfragen sind ĂĽberhaupt nicht sehr schwer. Es gibt mehrere Dutzend von ihnen. Und selbst wenn Sie sie in gewisser Weise mehr in Echtzeit als einmal pro Minute ausfĂĽhren, ist diese Belastung immer noch recht begrenzt. Hier ist ein Beispiel dafĂĽr, wie viele Abfragen an die Datenbank gesendet werden. Es gibt mehrere tausend von ihnen. Selbst wenn diese mehreren Dutzend einmal pro Sekunde abgefragt werden, ist dies dementsprechend immer noch ein Bruchteil.
Alles Klar, Danke!