Skip to main content

introduction

Jo aapde bau moti large scale application banavta hoie to possible 6e k aapde bau badha database na connection ni jarur pade.

Ek large scale application ne ghani vakhat 100,000s of connection ni jarur padti hoi 6e.

PostgreSQL na benchmark pramane ek standard PostgreSQL 350 transactions/second kari sake 6e. pan aapde vadhare, bau vadhare transaction ni expectations rakhie je 1000s of process kare to ae case ma aapde connection pooler ne maintain karvo jaruri 6e.

Aa case ma PgBouncer jeva connection pooler no aapde aapda system na performance ne improve karva mate use kari sakie 6ie.

PgBouncer khub saari rite kaam kare 6e ane aa ghana varso thi available 6e.

PgBouncer no main use real database sathe connections ne o6u karva no 6e.

jyare user ek real database sathe connection establish kare 6e to aa connection sari aevi memory utilize kare 6e. actually ma chalo memory consumption pan ek problem na kahi sakay for example, to aa je connection establish karva ni je time consumption 6e ae khub high 6e.

Jyare connection thay 6e tyare PostMaster ek fork no system call kare 6e j ek space, ek file descriptor and memory na segments ni ek copy create kare 6e and jyare terminate thay 6e tyare aa channel process terminate thai jaay 6e.

create 1 backend connection
call fork -> create address space -> create file descriptor -> copy memory segment
end 1 backend connection

aa process 1000s of time thatu hoi 6e generally.

jo tame matra thoda j connection create karso to maybe tame time bhi notice nahi karo, pan ghani vakhat jetlu time and resources ek connection ni madad thi query karva ma nathi thatu aena karta vadhare ghani vakhat connection create karva ma thai jay 6e.

PgBouncer ne application and real database vacche mukva thi aa problem ne solve kari sakay 6e.

Application ne PgBouncer PostgreSQL server ni jem j lagse. PgBouncer simply open connection no array create karse and jyare bhi application request karse tyare ae aa connection ni madad thi pull karse, jyare bhi application mathi data ni request aavse tyare PgBouncer aene connection aapi dese pan ae real database nu connection nahi hoi pan PgBouncer nuj connection hase.

Inshort mane jya sudhi samjanu tya sudhi PgBouncer ek prakare connection proxy 6e.

Aa sivay bau low memory ma aa kaam complete thai jase, like 2kb ni aas paas me ek connection pool complete thai jase. aa karno thi PgBouncer bau badha connection banava mate ideal 6e.

PgBoucer ne aapde proxy tarike to gani sakay pan aane load balancer samji ne misunderstand na karvu, kem k PgBouncer ek sathe ek database matej connection handle karse. matlab k ek PgBouncer ne tame multiple database sathe set kari ne load balancer ni jem replicas ne manage karva mate use na kari sako. PgBouncer no use High Availability mate ek rite thai sake 6e kem k ae connection time optimize kare 6e pan highly availability ma infrastructure level ae jo kahie to multiple instances ne handle na kari sake, ek rite aane per database adapter kahi sako jene aapde ek cluster sathe set kari sakie 6ie. Load balancing mate HAProxy and Pg Pool II no use thay 6e je aapde pa6i josu.

PgBouncer ni responsibility real PostgreSQL database ni sathe connection establish kari ae connection ne reuse karva ni 6e.