mongorover icon indicating copy to clipboard operation
mongorover copied to clipboard

pool support

Open malexzx opened this issue 8 years ago • 4 comments

one nice feature - mongo pool as must have be in mongorover. it might be a simple implemented for short lived lua sessions for example. (while gc on destroy - return connection to back to pool). Does any known issues, that this idea won't work, or maybe hard to implemented on that way? I'm may be try to implement this feature (since it may be needed me in production).

malexzx avatar Dec 02 '16 08:12 malexzx

Can you tell me more about your idea? I think the C Driver's mongoc_client_pool_t is useful only for multithreaded applications. A single-threaded application can just use one mongoc_client_t for all operations. But I don't know much about Lua so perhaps your idea is useful.

ajdavis avatar Dec 02 '16 21:12 ajdavis

Hello @ajdavis ! In my case short lived lua scripts is executed in multiple threads (web server with lua handle requests by lua for example). For this purpose first of all, we need init a pool by providing mongo url (may be outside lua code or by lazy technique). Then pool may be used per query execution, i.e. get client from pool for execute query then return back to pool. Another proposed use case is get pooled client and release it after gc (may be at lua state destroy). Another use case may be use this approach in coroutines (but it is more complex to implement). It requires to overlap mongo-c driver with coroutine too. That method is would allow us to send and receive data (mongo query) in asynchronous manner.

malexzx avatar Dec 03 '16 05:12 malexzx

Sounds interesting, and it resembles how the new PHP driver does connection pooling. Let me dig up some documentation about that....

ajdavis avatar Dec 03 '16 15:12 ajdavis

Thank you for pointing me about PHP. http://php.net/manual/en/mongo.connecting.pools.php is said, that now pooling is not used. I'm try to investigate now why that needs.

malexzx avatar Dec 04 '16 01:12 malexzx