Java Driver Concurrency

44 views
Skip to first unread message

Chase

unread,
Feb 27, 2010, 6:33:51 PM2/27/10
to mongodb-user
Hello - Wanted to post this message to the group on whether people
have noticed problems with the concurrency in the Java driver.
Specifically when we have tested with a small number of threads (10)
the throughput declines to 1/2 of running with just one connection and
having 10 threads feed one connection via a queue. It appears that
most of the problems are in the ByterDecoder / ByteEncoder (since
these are static and shared by all connections and they use a
SimplePool which is heavily synchronized) and the use of static
objects that are synchronized (I think there is one byte array that is
also syncrhonized across all member variables). Just wondering if
anyone else has seen the same problems?

Thanks

Eliot Horowitz

unread,
Feb 27, 2010, 6:38:54 PM2/27/10
to mongod...@googlegroups.com
At least in my tests I haven't seen that. If you could send some
sample code can take a look.

> --
> You received this message because you are subscribed to the Google
> Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en
> .
>

Chase

unread,
Mar 2, 2010, 12:16:58 AM3/2/10
to mongodb-user
Hi Eliot - I am still building a better test case to demonstrate the
issues without exporting all of the code we have here (right now the
drop in throughput starts around 4 threads and the mongo interface
becomes unusable around 20 threads). In the meantime, a quick
explanation of the problems I found :

* Use of the Collections.synchronizedMap- I believe it is much more
efficient to use the ConcurrentHashMap in place of the synchronized
maps.
* SimplePool<T> has a tremendous amount of synchronization and it is
used in a number of places (ByteEncoder / Decoder, etc.) . I believe
you can replace all of this code with a LinkedBlockingQueue (to act as
an object pool) and an AtomicInteger (to count creation totals).
* RawDBObject uses a static shared byte array that is synchronized on
access - I believe the code only accesses it in one place and this
array could be created locally in that method eliminating the need for
the synchronization.


Is there a way to upload the patch file here I created for you to
examine ? or should I enter a Jira bug ?

Thanks

On Feb 27, 4:38 pm, Eliot Horowitz <eliothorow...@gmail.com> wrote:
> At least in my tests I haven't seen that.    If you could send some  
> sample code can take a look.
>

Eliot Horowitz

unread,
Mar 2, 2010, 12:20:16 AM3/2/10
to mongod...@googlegroups.com
The best thing to do is open a Jira case or fork on github. Just make
sure to put some timing tests in with it.
Reply all
Reply to author
Forward
0 new messages