PostgreSQL-Lastmanagement, wenn ein Server nicht ausreicht. Andrey Salnikov

Ich schlage vor, mich mit der Entschlüsselung des Berichts von Anfang 2019 durch Andrey Salnikov vertraut zu machen: "Verwalten der Last auf PostgreSQL, wenn ein Server bereits nicht ausreicht".


Wichtige Punkte:
1) PostgreSQL-Standardverfahren für den Lastausgleich. Zunächst diskutieren wir die Gründe für die hohe Belastung der Datenbank. Der nächste Schritt besteht darin, diese Lastausgleichsmethoden zu berücksichtigen.
2) Es werden Fragen dazu diskutiert, wie die Replikation in PostgreSQL organisiert ist, welche Unterschiede zwischen synchronen und asynchronen Replikaten bestehen und wie Replikate korrekt konfiguriert werden.




, . – Data Egret. . . HeadHunter, Lamoda. DBA PostgreSQL. DBA – . . , .


, - , .


Postgres open source’ community, . , Postgres.


, RDBMS . – enterprise: Oracle MSSQL, open source: MySQL Posgres, .


- . . . – Postgres .


– .


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



. ? , . , -, .



, .



, , . . , , , , , , .


. , ? , raid 1 raid 0. . -. , , . , . , .



, , – 20 000-30 000. 40 000, , - . .


, . 50 000 . .



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



. . , , . . , . .


, . – «exclusive», «share».


20 000 ( ), , - .


: HH Lamoda. , ? 10-20-50 , .


. , .



, , . , , . - . , , , , , , . .


, , Postgres , . . Postgres Posix, , , . – . , , : «, » sleep. , . , . , .



. .



timestamps.


, 30 . . . . RDBMS , . , - . , . , . .



-. , . .


, – idle-. Idle- , - pool connection. , , . , , , , , , , . overhead, , -, .


– . – , .


– , . - , : , . .


– - , . , , , .


? . .


, . ? -, . -, - Postgres ( MVCC), . update/delete, , , , .


idle in transaction , , Postgres . , . . , . , . , . - ( ), 10 , 300 , 400 . . Postgres, .


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


, . . : - , . , Ruby, Python. , . , , - , . idle in transaction.


instances , . . - . . . , .



-. , pool connection . pools, . Hibernate pools. , pool. , pool .


, . , , idle-. . . , . , , , . , . , . . .


, , .



, , , . , .



.


, . . , , – . , - .


, , , . . , .


, 2,5 . 2 – transaction log. . , . , . . . 1,5 . : « . ». 0,5 . 2,5 0,5 . , .


. , . , , . .


. ORM-. . , , , . .


, , 2 , , 490 , . 490 , , . - . .


, , . , , , , , .


. , , , . . , - . , , , - , .


, , . , , . , . . , , . . , , – 3-4 , .


. . , .


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


. Json, , . . . - Json . . , .


. , , , , . . . . , , , . , Json, . Json, . , .



. , join. . , , , , , .


Java , hibernate . Hibernate, , . . , 2 , . , . 2 – , .


, , Python, 490 , . . 5 . . . , . , - , , .


2 . , , . .


, , , . . , , , , . . , , . . . LEFT JOIN, DISTINCT , , - .


GROUP BY – DISTINCT. . . , . .


– COUNT, MAX, MIN , . . , , . , , . , . . . - . . , MIN, MAX . . .


, . «WHERE id IN (SELECT id FROM)», . «NOT EXISTS». id, , .


, . SELECT ids. id , – .


NOT EXISTS , . , : «, id, ». WHERE, . , WHERE , , , .


– . . , - , , . cron- ( ) , , , . , .


. , -, , . - . , , . PIDs . , , .


, HH , cron …, . . cron . , , – .



. . , : Kafka, RabbitMQ, ZeroMQ, .


, . . Skype SkyTools PGQ. . . . . 20 000-30 000 .


– . , . , , .


. . DBA, , Postgres. .


. , , idles. , .


idle-. . . , 10 , 15, 15 , . . idle 15 . , , .


pgbouncer . . , .


PgBouncer transaction-, . . : start transaction commit rollback. , … – . – . , , , .


Pgpool-II, , .


PgBouncer , . . Odyssey. . , . . . . -, , , - Odyssey Pgbouncer. PgBouncer – .


. , COUNT 200 , 200 . MIN , .


200 , 100 . . .


– , . . . , . , , , . , .


, . ? , 100 , 2 200 . , . , 90 % 10 % . 200 , .


. . Oracle, partition. «» . - – .


. .



?



. , , .


. , : , , , . , . , , . , , . , , . , .


. , , , , .


– . , , , : HDD SSD. NVMe . – , . , NVMe, .



? WHERE , , , .


, - . . .



– . – , . – , , . . – drop table, .


. - , , . - . , – Coca-Cola, Pepsi, Nike, Adidas . . , . . . .


, , , . . . , . . . . , . , , .



, , , 4 , 2 , 2 , , : « ?».


, - . , . , RDBMS .



. , , , .


: .


– , . INSERT. INSERT INSERT’ . DELETE DELETE SQL . .


. INSERT . , . . . . , .


, .


9.4 . . 9.6 . 10-11 . , , , , .


Postgres . , – , . .


Postgres, , , , . – . INSERTS DELETES.


, . Slony, Londiste Burcado.


Burcado – . – Slony. Londiste – , . , .


, , SQL? . , , . , - . , .


, Postgres , . .


? .


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


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


. . .


, , , , , , .


. , . , , 10-20 .


. , , .


? -, . , -, 20 , , , , . - . . , . -.


. . , Postgres, . .


. delayed . , . , 8 , 8 , . , 6 , . . . , . . . , 200 – .


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



. ?


wal_keep_segments. , . - , , , wal- – 16 . . . 1 000 , , 1,5 . , .


, …, , -, , , . , «0» . , .


Max_standby_streaming_delay. . ? , . , - . , , . , , , .


, , , , . , Postgres , .


Synchronous_standby_names. - . . . . . . . . . .


Hot_standby_feedback. , , . , , , . .


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


. . Hot_standby_feedback , -, . , . .


Recovery_min_apply_delay. CI/CD , , - , . 6 . 6 , . 8 .


, . , .



.



Postgres , . .


, full story , -, - . -. .


? , , . , COUNT, MAX - , , .



. 20 , . . . , , - . Join, .



- , KPI -. . , . max_standby_streaming_delay. , 4 , .


, 2 , . . . OLAP-, , -, , . , OLAP-. .


, , HeadHunter , . - . . , , . .


RDBMS , , , RDBMS, . , ClickHouse, .



. , latency. , , , , - . , . , . . . , . , , , .


, - , . - . , . .


, , , , . . . .


Das Schema „Last Addiction Stage“ auf HeadHunter sieht ungefähr so ​​aus. Dort haben sie 11 Server in Kaskade für den Hauptdienst. Und es funktioniert. Sie haben so einen verrückten Monolithen, der problemlos wie eine Uhr funktioniert. Teilweise aufgrund der Tatsache, dass das Support-Team eine Prämie hat, die von der Ausfallzeit abhängt. Sie haben Ausfallzeiten erlaubt. Und wie viel sie von dieser erlaubten Zeit gespart haben, damit sie einen guten Bonus haben. Und sie versuchen es. Sie haben Ausfallzeiten.


Ich habe alles zu diesem Thema. Es ist mehr Panorama, aber ich denke, es wird nützlich sein.


Video:



All Articles