Hi Norbert and Mariano,

thanks for the important input.
I will use voyage now, just loading :-)

BTW: it is really great, getting answers in the forum so quick and
profound!!! I am very happy about that.

Sabine

On Thu, Jul 18, 2013 at 2:57 PM, Norbert Hartl [via Smalltalk]
<ml-node+s1294792n4699354...@n4.nabble.com> wrote:
>
> Am 18.07.2013 um 12:33 schrieb Sabine Knöfel <[hidden email]>:
>
>> Hi,
>>
>> Currently, I create one single Instance of Mongo when starting the Image.
>>
>> | theRoot  |
>> theRoot := Mongo default.
>> theRoot open.
>>
>> and use it for all requests. In my development environment that works
>> fine.
>>
>> My question is: is this the right way and will it work for production?
>
> No, certainly not. If you restart mongo db e.g. due a system update the
> connection from the image would be stale serving you errors.
>> Or is it better to create one Mongo instance for each request (and close
>> it
>> after the request)?
> That is theoretically the safest thing but very expensive. Opening a
> connection always takes time and consume quite some resources. So reuse is
> king.
>> And, btw: what would happen if I would open many Mongo connections but
>> never
>> close any?
> You would run out of external semaphores in the image. The image is
> "somewhat broken" in this regard because it cannot expand the semaphore
> table. As each connection uses three semaphores you are running out of
> semaphores after 85 requests.
>
>> Or better one Instance per user session?
>>
> That can be a good idea but it doesn't solve your actual problem.
>
> You also need to take care of concurrent requests. The line protocol to the
> mongo database needs to be aligned and it is binary. If more threads try to
> write on the same connection the connection will break. I'm not sure if this
> is still possible in the newest MongoTalk driver nor do I know if I managed
> it to release my thread safe mongo instance.
>
> The pool Mariano is talking about sounds like a good idea. Otherwise wrap
> your store method with an exception handler to reopen a connection on
> failure.
>
> Norbert
>
>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://forum.world.st/MongoDB-open-close-in-production-singleton-or-not-tp4699322p4699354.html
> To unsubscribe from MongoDB open close in production (singleton or not),
> click here.
> NAML




--
View this message in context: 
http://forum.world.st/MongoDB-open-close-in-production-singleton-or-not-tp4699322p4699356.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply via email to