Connection problem

424 views
Skip to first unread message

Anton Frolov

unread,
Dec 8, 2010, 2:16:17 PM12/8/10
to mongodb-user
Error: "No connection could be made because the target machine
actively refused it myip:27017"

I have about 150 online users(average). I have built my repository
that every request create mongo connection retrieve or update data and
then dispose Mongo(connection) object.

I can't connect to the server from mongo, from http://myip:28017,
can't start mongostat.exe ? As far as i understand mongo has a
connection limit, which i have fully used. My repository strategy bad,
isn't it? Should i save my mongo object per every request and dispose
only when request is disposed. I think that creating Mongo object
doesn't heavy operation the more so because i use driver which support
connection pool.

Anton Frolov

unread,
Dec 8, 2010, 2:24:30 PM12/8/10
to mongodb-user
i have perform about 20 request to db per web request.

Nat

unread,
Dec 8, 2010, 7:14:52 PM12/8/10
to mongodb-user
Which driver do you use? Java driver? If so, try to use the latest one
from git master.

Andrew Armstrong

unread,
Dec 8, 2010, 7:21:03 PM12/8/10
to mongodb-user
You may want to update your code when possible to use a per-page
context anyway, not per-database request.

Remember that you've got some performance loss from opening/closing
the connection every time (I'm not sure if your driver pools
correctly).

- Andrew

Anton Frolov

unread,
Dec 9, 2010, 1:24:26 AM12/9/10
to mongodb-user
Thanks, for response.

I am using csharp-mongodb driver. it has connection pool.
Ok, i will refactor my repository.

Andrew Armstrong

unread,
Dec 9, 2010, 1:44:45 AM12/9/10
to mongodb-user
Ah; if you already use a connection pool then you may already be okay
as the driver will just pool the connection instead of really
'closing' it, so performance loss would be minor compared to using an
unpooled connection.

Two points though for you:
1) Are you sure you are hitting a limit on connections? 'Connection
refused' I am sure is the server explicitly saying to your client "I
dont have that port open for you to connect on". I would expect an
error like "Connection failed to respond in a suitable time" or
another timeout related message when trying to connect, if you were at
a connection limit on the server, instead of a flat out refusal. I
could be wrong though. Perhaps you should check whether a firewall or
something is kicking in and blocking your connections?

2) If you do have excessive amount of connections though, this could
be attributed to you not really closing the connection when you were
finished with it inside your application code, although disposing of
the connection should do it.

You could try reloading the same page over and over and seeing whether
your connections count on mongo (if you can check some how) keeps
increasing?

- Andrew

Anton Frolov

unread,
Dec 9, 2010, 3:21:05 AM12/9/10
to mongodb-user
Thanks, Anrew

I am using mongo for about 3 web project. 2 web project use
relateional database as main db and cache some data in mongo. This
project does not high load: about 1 request per 3 seconds to mongodb -
it work very good, i could run mongo shell, mongostat or http://myip:28017
for monitoring mongodb perfomance. But when i connect my third web
project mongo goes down.

>You could try reloading the same page over and over and seeing whether
>your connections count on mongo (if you can check some how) keeps
>increasing?

I try, but yesterday could not do this.

>2) If you do have excessive amount of connections though, this could
>be attributed to you not really closing the connection when you were
>finished with it inside your application code, although disposing of
>the connection should do it.

As far as i understood you mean that i have not to dispose my
connection manually even if web-server make response to client? Or use
the such mechanism:

client -> make request -> server open connection

make some operation with data:
op1()
op2()
op3()
op4()
etc
close connection
server -> make response to client
Reply all
Reply to author
Forward
0 new messages