database - Understanding DB Connection Pools in python -


I'm not sure that I understand the use of the DB connection pool (eg: psycopg2.pool and mysql connector .pooling) It appears in Python that parallelism is generally achieved in Python using multi-process rather than a multi-thread approach due to GIL, and in the case of multi-process these pools are not very useful because Each process will start its pool and only A walk one thread at a time. is this correct? There is a strategy to share the DB connection pool while using multiple processes, and if multi-threaded Python applications do not have the capacity of pooling limited or are there other scenarios where you will use them?

Keith,

You are on the right track as outlined in the SO post ", ":

  Creating a separate pool for each process is redundant and opens a lot of connections   

See other SEO posts," " There is sample pooling solution. This post also discusses the limitations of DB-pooling if your application has to be multi-threaded:

  Building your connection pool is a bad idea if your app never uses multi-threading Decides to do Creating a connection pool for a multi-threaded application is more complex than the one-threaded application. You can use something like PySQLPool in that situation.   

In the case of implementing DB pooling in Python, as outlined in "," if your database supports it, then the best implementation will include:

  Let the connection pool be maintained and managed by the database itself (Example: Oracle's DRCP) and the calling module only asks the connection to the connection broker described by Oracle DRCP.   

If you have any questions, please let me know!

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -