Pavel Trukhanov. Memantau Postgres dengan USE dan RED. Dekripsi dengan PGConf.Russia

Pavel Trukhanov, "Monitoring Postgres oleh USE dan RED"



Ada dua metodologi pemantauan kinerja: USE (Utilization, Saturation, Errors) oleh Brendan Gregg dan RED (Requests, Errors, Durations) oleh Tom Wilkie. Dalam pembicaraan tersebut, saya ingin berbicara tentang bagaimana kami dibimbing oleh mereka dan terus dipandu saat kami menerapkan pemantauan Postgres di okmeter.io.





. 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 .



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



Cara kedua kami melawan adalah pengoptimalan. Kami mengoptimalkan apa yang kami lakukan. Secara efektif, Okmeter membuat permintaan ke tampilan ini secara teratur, tetapi sangat jarang, sekali dalam satu menit.



Artinya, ini bukan waktu nyata?



Ini adalah pertanyaan yang sulit, apa itu waktu nyata. Mari kita bahas ini secara terpisah. Tetapi bebannya dibatasi oleh berapa banyak permintaan yang Anda buat. Permintaan ini tidak terlalu berat sama sekali. Ada beberapa lusin. Dan bahkan jika Anda melakukannya dalam waktu yang lebih nyata daripada sekali dalam satu menit, beban ini masih sangat terbatas. Berikut adalah contoh berapa banyak query yang dikirim ke database. Ada beberapa ribu dari mereka. Karenanya, bahkan jika beberapa lusin ini disurvei sekali dalam satu detik, itu masih merupakan sebagian kecil.



Oke, terima kasih!




All Articles