[Neo4j] Parallelism

2011-06-17 Thread Norbert Tausch
Hi,

is it possible to traverse on a Neo4J graph DB using the Java API in
parallel threads? Is this possible within one transaction or does every
thread has to use its own transaction? Is the API thread-safe concerning
read-only access?
Is there any advantage of concerning parallelism when using Neo4j as an
embedded DB?

Best regards

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Parallelism

2011-06-17 Thread Johan Svensson
Hi,

That is possible (and even recommended). The Java API is thread safe
(with the exception of batch inserter) both for reads and writes.

Each thread may use its own transaction but it is not required to have
a transaction when performing read operations (only for writes).
Reading is lock free and will always read the last committed value. A
multi core CPU is required to let the threads execute in parallel with
the advantage of scaling reads with the available number of cores.

It is not possible to have a transaction associated with more than one
thread at a time (but you can suspend a transaction and resume it in
another thread if needed).

Regards,
Johan

On Fri, Jun 17, 2011 at 2:23 PM, Norbert Tausch w...@ntausch.de wrote:
 Hi,

 is it possible to traverse on a Neo4J graph DB using the Java API in
 parallel threads? Is this possible within one transaction or does every
 thread has to use its own transaction? Is the API thread-safe concerning
 read-only access?
 Is there any advantage of concerning parallelism when using Neo4j as an
 embedded DB?

 Best regards
___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


Re: [Neo4j] Parallelism

2011-06-17 Thread Chris Gioran
Hi,

Keep in mind that Neo4j is a fully ACID database. As such, it is safe
to use in the same manner as any other ACID database, since it makes
use of locking over primitives, deadlock detection, isolation between
transactions etc. Having said that:

Yes, the API Neo4j exposes is suitable for manipulation by
concurrently running threads.
Each thread will run in its own transaction - the XA standard that
Neo4j implements enforces a 1-1 correspondence between transaction
context and thread.
Yes, the API is thread safe. Of course, objects that maintain state,
such as Iterators, are still not safe to publish outside the thread.

The advantage of having multiple threads is dependent on your use case.
If you have lots of I/O blocking operations, read-only threads that
work with the memory resident set will progress faster.
Or if you have multiple cores to dedicate, it probably makes sense to
have one thread per such.
Or simply if you want the transaction isolation offered by working in
discreet threads such as when serving client requests.
Or whatever other scenario you might have where multiple threads make sense.

For example, building a web site over Neo4j is a good use case for
having multiple threads, one per request. Creating a bulk data import
tool on the other hand is not a good case to apply parallelism - since
it will be constantly writing to disk, a single thread is fast enough,
adding more does not increase throughput.

The reasoning behind multithreaded access to Neo4j is pretty much the
same as for any other use case. Whatever you choose however is well
supported.

cheers,
CG

On Fri, Jun 17, 2011 at 3:23 PM, Norbert Tausch w...@ntausch.de wrote:
 Hi,

 is it possible to traverse on a Neo4J graph DB using the Java API in
 parallel threads? Is this possible within one transaction or does every
 thread has to use its own transaction? Is the API thread-safe concerning
 read-only access?
 Is there any advantage of concerning parallelism when using Neo4j as an
 embedded DB?

 Best regards

 ___
 Neo4j mailing list
 User@lists.neo4j.org
 https://lists.neo4j.org/mailman/listinfo/user

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user