Scalable replication and change listening for CouchDB
50K+
Scalable replication and change listening for CouchDB
Spiegel was designed to provide scalable replication and change listening for Quizster, a photo-based feedback and submission system. Without Spiegel, a lot of complicated logic would need to exist in the Quizster application layer.
We recommend that you install Spiegel via Docker, especially Docker Swarm, as this will allow you to easily scale up or down as your needs change. Moreover, Docker will take care of automatically restarting the processes in the event of a permanent error. You can of course run Spiegel via npm, but then the scaling and auto restarting will be up to you to implement.
{
"yourapi.com": {
"apiuser": "apipassword"
}
}
{
"yourcouchdb.com": {
"user": "password"
}
}
$ docker run -it \
-e TYPE='install' \
-e URL='http://user:[email protected]:5984' \
redgeoff/spiegel
$ docker service create \
--name update-listener \
--detach=true \
--replicas 2 \
-e TYPE='update-listener' \
-e URL='http://user:[email protected]:5984' \
redgeoff/spiegel
$ docker service create \
--name change-listener \
--detach=true \
--replicas 2 \
-e TYPE='change-listener' \
-e URL='http://user:[email protected]:5984' \
--mount type=bind,source=change-listener-passwords.json,destination=/usr/src/app/passwords.json \
-e PASSWORDS_FILE=/usr/src/app/passwords.json \
redgeoff/spiegel
$ docker service create \
--name replicator \
--detach=true \
--replicas 2 \
-e TYPE='replicator' \
-e URL='http://user:[email protected]:5984' \
--mount type=bind,source=replicator-passwords.json,destination=/usr/src/app/passwords.json \
-e PASSWORDS_FILE=/usr/src/app/passwords.json \
redgeoff/spiegel
on_change docs in the spiegel DBreplicator docs in the spiegel DBNote: for extra security, use the Docker Secrets to encrypt the URL parameter.
You can then scale up (or down), e.g.:
$ docker service scale update-listener=3
$ docker service scale change-listener=3
$ docker service scale replicator=3
$ npm install -g spiegel
{
"yourapi.com": {
"apiuser": "apipassword"
}
}
{
"yourcouchdb.com": {
"user": "password"
}
}
$ spiegel \
--type='install' \
--url='http://user:[email protected]:5984'
$ spiegel \
--type='update-listener' \
--url='http://user:[email protected]:5984'
$ spiegel \
--type='change-listener' \
--url='http://user:[email protected]:5984' \
--passwords-file=change-listener-passwords.json
$ spiegel \
--type='replicator' \
--url='http://user:[email protected]:5984' \
--passwords-file=replicator-passwords.json
on_change docs in the spiegel DBreplicator docs in the spiegel DBUsage: spiegel --type=type --url=couchdb-url options
--type=type The type of the process: update-listener, change-listener, replicator,
install or uninstall. The install and uninstall processes run and then
exit, but the update-listener, change-listener and replicator will run
indefinitely. You can run as many update-listeners, change-listeners and
replicators as your DB setup can handle. In most cases you'll want to run
at least 2 of each of these processes for redundancy. In general, if you
need to listen to more changes or respond to these changes faster, add a
change-listener. Similarly, if you need to perform more replications or
replicate faster, add a replicator.
install Creates the spiegel DB and sieve
uninstall Destroys the spiegel DB and sieve
update-listener The update-listener listens for all DB updates and then
schedules on_changes and replications accordingly.
change-listener The change-listener runs on_change rules for all
matching changes
replicator The replicator performs replications
--url=couchdb-url The URL to the CouchDB instance
For a complete list of options see Usage
Note: the Docker image's environment variables are equal to the uppercase snake case of the options available on the command line, e.g. use LOG_LEVEL instead of --log-level
Content type
Image
Digest
sha256:a3c3bf3df…
Size
377 MB
Last updated
over 3 years ago
docker pull redgeoff/spiegel