pdonorio / restangulask

FRONTEND(Flask and Angular interface) + BACKEND(Flask Rest API)
MIT License
3 stars 2 forks source link

Backend optimizations for Neo4j #26

Open pdonorio opened 8 years ago

pdonorio commented 8 years ago

We are trying to get the most tight integration with graphdb as possible in the basic blueprint of this framework. We are using neomodel python library to map Graph nodes&relationships to Python Classes.

Also great news, neomodel will support the latest neo4j 3.0 native python driver, see the issue i opened here. Until then we will stick with version 2.3.3.

Models should be made customizable, for the moment the base version is in some kind of limbo, between backend and vanilla code.

On the backend side some things should be done to verify what is the best way to handle connections and models injections. I expect this to be on @mdantonio shoulders, and @dpaoletti could help to get some understanding of the graphdb as well.

mdantonio commented 8 years ago

neomodel will support the latest neo4j 3.0 native python driver

Very good news... we expect a huge performance boost

Speaking about neo4j optimizations I start by linking this little guide to tune neo4j: performance tuning

pdonorio commented 8 years ago

this little guide to tune neo4j

It seems like the ulimit is a problem here too 😨

pdonorio commented 8 years ago

Neo4j 3 is available with neomodel. How can we test it?

pdonorio commented 8 years ago

How can we test it?

We just need as root inside the backend container:

pip install --upgrade git+git://github.com/robinedwards/neomodel.git@HEAD#egg=neomodel-dev

and change the main variable for connection into

os.environ['NEO4J_BOLT_URL'] = "bolt://neo4j:chooseapassword@gdb"
# note: no port and the rest
mdantonio commented 8 years ago

To upgrade from neo4j 2.x to 3.0:

https://neo4j.com/guides/upgrade/

To upgrade using the docker image:

http://neo4j.com/docs/operations-manual/current/deployment/single-instance/docker/

Now i'm unable to test it because:

The Compose file ... is invalid because: NEO4J_dbms_allowFormatMigration contains true, which is an invalid type, it should be a string, number, or null

with: docker-compose version 1.8.1, build 878cff1

with NEO4J_dbms_allowFormatMigration: 'true' is ignored by neo4j with NEO4J_dbms_allowFormatMigration: 1 gives an error

Any idea?

mdantonio commented 8 years ago

with NEO4J_dbms_allowFormatMigration: 'true' is ignored by neo4j

I found the real probelm.

The migration flag is not ignored, is the old graphdb that is not recognized. In the old data folder we have a three sub folders: dbms, graph.db and log After the startup of neo4j3 a fourth folder is created: database with a graph.db created into I created a database folder and moved the graph.db Now the old graph is recognized

What is really strange is that the migration process not start at all. But the graph works. The migration is not required? And why? I cannot find any guide saying "no migration is required from 2.3.3 to 3.x" Everywhere "the migration is required from 2.x to 3.x"

mdantonio commented 8 years ago

I found a problem with the id property.

In the previous neomodel version the internal node id was accessed as node._id So we added to models an id String property containing an uuid

Now the internal id is accessed as node.id and we have a collision

We have to rename all id properties to uid (both in models and in base.py: getJsonResponse starting at line 508)

mdantonio commented 8 years ago

An other difference is found in the docker image env variables

NEO4J_CACHE_MEMORY became NEO4J_dbms_memory_pagecache_size NEO4J_HEAP_MEMORY became NEO4J_dbms_memory_heap_maxSize

NEO4J_AUTH does not change

mdantonio commented 8 years ago

At the moment i'm unable to perform more tests

So the final migration guide is:

mdantonio commented 8 years ago

Created a branch in mdantonio/http-api-base

New migration guide

Migrate DB:

Migrate source code

mdantonio commented 7 years ago

Install last neomodel tag:

pip install --upgrade git+git://github.com/robinedwards/neomodel.git@3.0.3

To connect from python add in graph.py:

from neomodel import config
config.DATABASE_URL = "bolt://%s:%s@%s" % (USER, PW, HOST)