Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion to increase speed of sync #77

Closed
OSSDeveloper opened this issue Jun 18, 2015 · 6 comments
Closed

Suggestion to increase speed of sync #77

OSSDeveloper opened this issue Jun 18, 2015 · 6 comments

Comments

@OSSDeveloper
Copy link

Hi,
Right now, the sync process is quiet slow. Reason for this is Node being a single threaded technology, is unable to do utilize the processing power available on machine(in which bitcore-node is running) to the extent it should be utilizing.

Right now, its become difficult to run sync for days(especially for start-ups) & going farward, after an year or two, it will be impossible to do it.

Need to increase the sync speed is obvious(hope you are of the same perspective).

We can achieve this by using node cluster in the following manner :-

The entire bitcore-node should be split into 2 separate node processes.

a. First process reads the data from bitcoin-qt and, passes the result to second process. This will be a single threaded process. No use of cluster needed.

This thread can also be used to store the data to bitcore-node DB and go for next block.

b. Second node process which uses node-cluster and, does all the processing intensive work. This process should by default use "Number of processors available -2".

This passes the entire block along with transactions to the first process which stores the block to bitcore-node DB and, goes to fetch the next block.

By doing this, we won't have the problem of database lock as, single thread will be using the level-db operations(1st process) and, processor intensive work would be delegated to another node-process using cluster. This definitely will increase the sync process.

Hope you find the suggestion helpful.

@braydonf
Copy link
Contributor

Using multiple processes I think is a good idea. Also take a look chainlib-bitcoin, we're using batch for database writes and I think significantly helps, from our tests it takes around 5 hours to sync on testnet3.

@braydonf
Copy link
Contributor

Also you'll notice that blocks with many transactions is a bottleneck, and could benefit from multiple processes, as well as optimizations for transaction serialization.

@OSSDeveloper
Copy link
Author

@braydonf I actually did not understand what https://github.com/bitpay/chainlib-bitcoin does from the documentation. Can you pls let me know?

Can I run it in production / livenet mode?

@braydonf
Copy link
Contributor

Yep, you can run livenet and testnet. Docs have been updated with base API methods.

@OSSDeveloper
Copy link
Author

Yup, you are right. Batch processing or querying transactions increased the speed considerably. That was a good improvisation.

As the project itself is moving towards becoming all-in-one kind of app, i.e. bitcoin-qt+bitcore-node in one application, it would become essential to use node cluster. Hope you come up with an optimum solution. :)

@braydonf
Copy link
Contributor

Syncronization is done all in bitcoind now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants