I'm thinking about how large exchanges handles customer deposits, it appears there are two available solutions, one is to use external notification apis, like blockchain.info 's notification api, another is run a full node and use the walletnotify feature. Since the first approach brings dependency to an third party service, also, it does not support testnet notification, which we use during development, so I'm trying to run a full node. My question is how scalable is it? Suppose there are 10,000 users, and platform must support add more addresses for a user, say in average each user generate 10 addresses, that's 100,000 address to watch. If I add those 100,000 address as watch only to the full node and enables walletnotify, is that a good way to handle it? Will there be any technical issues?
3 Answers
Using walletnotify
has proven to work and is used by a lot of scalable apps today. I would not rely on it completely though. walletnotify
's job is to execute a shell command every time it receives a wallet transaction. This means data is flowing between processes, which does not make me entirely comfortable as a developer. After all, it only takes one error for someone to be missing their funds.
I would recommend not only using walletnotify
, but to also check X blocks after Y minutes. You can keep track of blocks passed and if any transactions were not processed by walletnotify
, your cronjob of checking transactions will recover the transaction. You can use listsinceblock
RPC command and keep track of the block height each time you check transactions. You could store transactions processed in a DB somewhere.
After all, this is a financial application so I think a backup check is vital.
Probably there's no technical problems and its highly depending on your server.
if your server is having no issues so nothing to worry about.
I have tried to send 1000 request to bitcoin-core server in the same time with a basic server and everything is worked great.
Also you can get like more than one bitcoin core server and deal the requests to these servers.
-
I think wallet notification is different than sending rpc requests, also 1000 is in a different scale factor than 100,000, but if you really handled a bitcoin platform like ecommerce site e.g. an amazon like site or a cryptocurrency exchange I'd trust your answer.– fluterDec 4, 2017 at 10:34
-
No, it's not different, RPC meaning Remote_procedure_call so its just passing the request to your app. so sending commands through RPC is the same. You could try with like 2000 address and see what will happen.– AdamDec 4, 2017 at 10:56
Since the time taken to process a given request will be greater than zero milliseconds, there will come a point where enough requests will result in the CPU reaching 100% utilisation, or you might hit I/O or network bounds first, but in whatever case when you find a bottleneck what you will need to do is split the workload up among multiple machines using some sort of load balancing schema.