Python Forum
Little Help with Design of a Pooling Application
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Little Help with Design of a Pooling Application
#1
So this will take some explanation. I'll try to get to the point as quickly as possible.

I'm new to Python, but programming a while. We use a database that is not a typical one. The company just released a python package to connect to the db. We basically get one connection. Of course, we can spin up 20 connections, but the creation of these are slow. I know many companies that use this database have created a pool to manage the connections and I'm wondering the best way to set that up.

I created a basic object pool with 5 sessions. Works fine, but I suspect if we get many users things may break down.

Here's the gist of it.

On startup, we open 5 connections to the db and start up a grpc server
Request comes in to grpc server
We find a free connection to use and use it, data is retrieved from the db and sent back
If no connection is available, we wait and try again in a second or possibly spin up a couple new sessions

I worry about a few things.

If we do nothing, does that mean every time a request comes in we aren't really using the pool, just the same session over and over because Python is synchronous?

1. What if we get 100 grpc requests at one time. Should we be using async or threads or even some other type of parallel solution?
2. Do we need to set some type of lock when we retrieve the next session from the pool to prevent race conditions or is everything synchronous? If it's all synchronous by default, seems like a bottleneck which is why I think we need some type of concurrency or parallelism.

Hope this is clear. If not, please let me know.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  application design 67kap 0 394 Dec-27-2023, 03:38 PM
Last Post: 67kap
  How to send data from a python application to an external application aditya_rajiv 1 2,173 Jul-26-2021, 06:00 AM
Last Post: ndc85430
  Using Connection pooling suds-jurkok with python 3.5 pratiksingal13 0 3,227 Jun-23-2017, 10:07 AM
Last Post: pratiksingal13

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020