Visit this page here also
Splitting up databases in bunch of different databases are known as SHARDING
.
Split up your tables store some rows in one shard and certain rows in other shard.
Example Any payment coming from USA is going shard 1 and any payment coming from India goes to shard 2.
Some shard get more data than other. In order to solve the problem we should use consistent hashing
. If DB go down then you need Replica
you can not use consistent hashing
Open new powershell in admin mode from the root of this project. And run below script:
- Run
$env:PORT="3000"; $env:DATA_DIR="aedb_data_0"; node aedb.mjs
Open new powershell in admin mode from the root of this project. And run below script.
- Run
$env:PORT="3001"; $env:DATA_DIR="aedb_data_1"; node aedb.mjs
Open new powershell in admin mode from the root of this project. And run below script:
- Run
node aedb_proxy.mjs
Use fiddler or postman to make Http Post to http://localhost:8000/a
address and using below JSON.
{
"data":"Rupesh how are you?"
}
Use fiddler or postman to make Http Get to http://localhost:8000/a
address.
Use fiddler or postman to make Http Post to http://localhost:8000/b
address and using below JSON.
{
"data":"Hello data in shard 0?"
}
Use fiddler or postman to make Http Get to http://localhost:8000/b
address.