mooglinux
mooglinux

Reputation: 845

Monitoring real-time changes to results of a neo4j query?

I have an incoming event stream of player interactions from an MMO. I want to construct a graph of the player's moment-to-moment interactions, continuously run queries on the activities of the past ~30-240 seconds, and update a graphical view, all in real-time.


Some more details about my particular case:

where every event is time-stamped. Timestamps are accurate to the second. I plan on attaching every event to a node representing a timestamp, so I can restrict queries to the events attached to a set of X most recent timestamps.


My main questions are:

Upvotes: 1

Views: 1751

Answers (1)

FylmTM
FylmTM

Reputation: 2007

Answers

1) No. You can only execute query and get results.

2) No. Currently you can only make client -> server requests.

3) Yes.

Details

Let's get to the bottom of this one. Neo4j by default can offer you:

  • REST API
  • Transactional Cypher ednpoint
  • Traversal endpoint
  • Custom plugins
  • Custom unmanaged extensions

In your case you should implement unmanaged extension. This is best option to get desired functionality - develop it by yourself.

More information on extensions:

In extension you can do everything you want:

  • Use Core API to make efficient queries for latest data
  • Create WebSocket endpoint for full-duplex communication channel between client and server
  • Implement any additional logic to format/represent your data correctly

Queries and performance

Cypher queries are compiled and cached on first execution. After that - cached query version is used. And query execution by itself is quite fast.

Recommendations:

  • Always use query parameters where it is possible. This allow Neo4j to efficiently reuse queries
  • Be smart on writing queries. Try to lower cardinality where possible.
  • Think about data model. Probably you can model your data in such way, when query always fetches only latest data. In you case probably relationship :LAST_EVENT, :PREVIOUS_EVENT and etc. can help.

Upvotes: 2

Related Questions