jadell / neo4jphp

PHP wrapper of the Neo4j REST interface
Other
533 stars 137 forks source link

Improved REST performance with HTTP Streaming #90

Closed flip111 closed 11 years ago

flip111 commented 11 years ago

According to this blog http://blog.neo4j.org/2012/04/streaming-rest-api-interview-with.html the performance increases when http streaming is enabled. I tested a query and everything still seems to be functional. However i don't have a large enough graph to really test performance with this at the moment.

Documentation: http://docs.neo4j.org/chunked/snapshot/rest-api-streaming.html

alexbilbie commented 11 years ago

Should there not be a request header of X-Stream: true instead? Looking at the docs stream=true is added to the response not the request

flip111 commented 11 years ago

Hmm yes curious case. The blog post is using curl to connect to the database and the curl is like this:

curl -i -o streamed.txt -XPOST -d'{ "query" : "start n=node(*) match p=n-[r:TYPE]->m return n,r,m,p" }' -H "accept:application/json;stream=true" -H content-type:application/json http://localhost:7474/db/data/cypher

Appreciate any input on this matter !

jadell commented 11 years ago

I'd like to see some benchmarks pulling down thousands of objects. I'm not sure this will actually improve performance much, since the client still needs to receive the entire JSON document before it can be parsed, which is where the performance hit is. The only way to get any real improvement is to parse the partial JSON response as it streams in. I know the py2neo project does this, if anyone wants to look into how that works.

jadell commented 11 years ago

This should be combined with #96. Keep the "stream=true" on the Accept header for older server versions, and also add the "X-Stream: true header" for the newer servers.

Should also be done for Transport/Stream.php.

@alexbilbie, please add the "stream=true" in your pull request in the Stream transport. @flip111, please add the "X-Stream: true" header to this pull request for the Curl transport.

flip111 commented 11 years ago

I will close this because the discussion in https://github.com/jadell/neo4jphp/pull/96 and the changes in https://github.com/jadell/neo4jphp/pull/99 look much better