Luttant avec la charge dans PostgreSQL, la réplication aide-t-elle à cela. Andrey Salnikov (Data Egret)



Que faire lorsque le serveur maître PostgreSQL meurt sous la charge?



Il arrive assez souvent que la base de données ne prenne pas en charge la charge existante et que la mise à l'échelle verticale du matériel n'aide pas. Changer PostgreSQL pour une autre base de données ou repenser l'architecture de l'application et abandonner le SGBD?



Laisse moi me présenter.





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



. . Postgres – open source , , , . . . .





– - , . , , , . .





– . , . . .





, , . 50 000 - – Postgres. – 20 000-30 000. . , , , - .





, CPU. , , CPU , , .





. , 20 000 . .



, . , .



. , Postgres, , . , , , , , . . , . , , . . . .





, . . 40 000 , .



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





– , . , 10-20 .





, , . , - .





, – , idle in transaction.



Idle in transaction – , transaction id . : , . . , .





, , , .



, pool connections. pool connections, : Hibernate , Python . , , . .



, , . PgBouncer Odyssey, , .





- . .



, . , , . , , - , .





, . 100 % .



  • 50 % . - , , , 80 % 90 % . ? , , , . , , - , , . . , . , . - , . RDBMS . RDBMS - -, , , , . – - , -, .



  • , 50 % . , , . , , , , , -. , 10 , , 10 . , , . - , , 50 % .



  • – , . , , , 10 , . . , , , . , , , , . , , . , , , , .



  • , . , .



    • , , . ID, ID . , , . Postgres , . , . . JSON, , JSON, JSON. JSON – , , Postgres.
    • . . JSON - , , JSON. , , . - , - , . . , . , , , . , , , - - . , . , . . . .






  • . – , . . , , . , , - . ORM, . , 1 , 200 . . , , 20 , , , , - . . . , , , , . Postgres, , , , .



  • , DISTINCT n*JOIN. , DISTINCT GROUP BY , , - . , JOIN, JOIN , . . , , , , . , JOIN . , . - , DISTINCT, . - , 10 . – , , .



  • – COUNT, MAX, MIN, SUM , . , . , , 5 . 5 , , - – , - . , , , .



  • , . WHERE id IN SELECT . . EXISTS (SELECT…). . SELECT - , . , .



  • LEFT JOIN , EXISTS (SELECT…) , LEFT JOIN. ? LEFT JOIN , . EXISTS. . . , LEFT JOIN, EXISTS, , .



    —



  • . , . . , , - -, , - , , , , -, . . , , . , , Postgres. , . , superuser. , . , . -, - . . , . cron. report . , - , - , , , , . . - , .







  • , Postgres. . . , . . RabbitMQ, ZeroMQ, Kafka. , , . DBA , . . , . . . , , .



    • PgQ – , , . , , . PgQ , microsoft’ .


  • . - .



    • , - , idle- . , . Postgres . 100-200-300 – , . 1 000 – , pools . idle-, . , , .
    • – PgBouncer transaction . . . prepared statements . set- PgBouncer. , , , . , , , , , . . , Odyssey PgBouncer .


  • . ? , , wraparound vacuum, vacuum, .



    • . - , , . . - . : , . , 99 % . 1 %. , , . . , – .
    • (). «», . - – . . , . .






, , 100 % . , . - . , , . .



  • , , , , , , - Data Lake, Big Data. . . , , . , . , . . .




? , .



, , , , . - , web-. , , . . - ID, - JOIN. -.



, . , .



. , . . , . , . , Fault Tolerance, . . , . , .





. ? , , COUNT, MAX, MIN, . . , , . , , , . , .



? - . , . . . , .



, – max_streaming_delay, . , – , . , .



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





? . , , - . , . , max_streaming_delay. , . , , . .



, - -, . , . , .





? , , . , -, , latency. latency – 10-20 . .



, . , . , .



. , . , , , , .



«() »? . . bloat . . - . - , , .





, Postgres?



Max_standby_streaming_delay – . , , , . . , . , . . , , , . . , . . , . , .



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



hot_standby_feedback , , , , .



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



– max_standby_streaming_delay, . – , .





, Postgres, . . .



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



, , , , . . , .



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



, delayed . recovery.conf Postgres , , , . -.



? deploy. , , - , , . delayed , .



. . , deploy. , , , – . , .



. , . , . , .



. , , .





, ! WAL . , , , , - ? , .



, . . . , , . . - , , - , . . , - . , . . WAL . - . .



?



-, . , . . . . , WAL-G, - . , , , - , . , , . .



!



! ! . , – PgBouncer ? ? per_request ? . . , , PgBouncer , PgBouncer – ?



, . transaction PgBouncer -. . . - - idle-, , . , , . . , , - , . , , , , . , , , , .



. . ?



PgBouncer . . PgBouncer . . , . , .



!



, ! ! , , , . . ?



– .



, 100 % ?



, , - . WAL-, - , . . . . , .



- ?



. , . , . . . .



!



, ! . , . , . - . failover? . . – ? ?



, , tools, auto_failover Postgres , - , - . , . . - , . . , . , WAL . -. , auto_failover, . , .



!



- , ? , , , - .



. instance Postgres . , . , : , , . , . . , . . – , , .



! ! , COUNT, - ? , , ?



COUNT, , -, – ? , , , . , , 10 . COUNT . , 10 5 . 10 . – ? . , 3-5 .



-, .



. COUNT 100 000 , 100 000 5 100 000 , , , COUNT . . , - , . .



, , !



, ! , . . , ? PgBouncer - , instance , instance? - , ?



. . , - . - , , . ? SELECT, . ? , ? , , , . , , . . . , , . . , .



? Discovery, . , . , , . .



, ! , , , , , , - . , ? , .



PgPool , , .



, !




All Articles