If you want to update this page or add new content, please submit a pull request to the Homepage.
Self-Hosted Server
This page explains how to run your own Yorkie Server.
To run a Yorkie Server, you need to install the CLI. If you haven't installed it yet, please refer to CLI.
Running a Server via CLI
Start a Server with the following command:
$ yorkie serverbackend created: db: memoryserving RPC on 8080serving profiling on 8081
The Server handles administrative requests such as project maintenance and continues to run until it receives termination commands such as Ctrl+C. The Server stores its data using an in-memory database, which does not provide durability by default.
Persistence
If you start the Server with a MongoDB address, you can permanently save the data stored by Yorkie.
To start MongoDB, run docker compose -f build/docker/docker-compose.yml up -d in the project root.
Then, start a Yorkie Server with --mongo-connection-uri flag to connect the MongoDB.
$ yorkie server --mongo-connection-uri mongodb://localhost:27017MongoDB connected, URI: mongodb://localhost:27017, DB: yorkie-metabackend created: db: mongodb://localhost:27017serving profiling on 8081serving RPC on 8080
The Server prints the MongoDB URI with any password in it masked.
Production Settings
The defaults above suit local development. Before you run the Server anywhere else, configure the following:
- Admin token signing key: The Server signs admin (Dashboard and CLI) tokens with the key given by
--backend-secret-keyor theYORKIE_BACKEND_SECRET_KEYenvironment variable. If neither is set, it generates a random key at startup, so admin tokens stop working whenever the Server restarts. Every node of a cluster must use the same key, and the key must be at least 32 characters. - Default admin user: On first start, the Server creates the admin user
adminwith the passwordadmin. Set--backend-admin-userand--backend-admin-passwordbefore the first start, or log in and change the password withyorkie passwd. The flags only apply when the user is created, so changing them later does not change an existing password. - Credentials: Flag values are visible to anyone who can list the processes on the host. Pass credentials through environment variables instead:
YORKIE_MONGO_CONNECTION_URIfor--mongo-connection-uri,YORKIE_CLUSTER_SECRETfor--cluster-secret, andYORKIE_AUTH_GITHUB_CLIENT_SECRETfor--auth-github-client-secret.
$ export YORKIE_BACKEND_SECRET_KEY="$(openssl rand -base64 32)"$ export YORKIE_MONGO_CONNECTION_URI="mongodb://<user>:<password>@<host>:27017"$ yorkie server
Monitoring
The Server exports metrics under the /metrics path on its profiling port. Fetch the metrics with curl:
$ curl http://localhost:8081/metricsyorkie_server_version{server_version="0.7.28"} 1# HELP yorkie_pushpull_received_changes_total The total count of changes included# TYPE yorkie_pushpull_received_changes_total counteryorkie_pushpull_received_changes_total 6...
These metrics can be collected by Prometheus.
The profiling port also serves Go runtime profiles under /debug/pprof/ when you start the Server with --pprof-enabled.
Running Prometheus and Grafana is the easiest way to monitor the Server's metrics.
The docker folder of the Yorkie repository has a Compose file that starts Prometheus, Grafana, MongoDB, and a Yorkie Server built from source. Clone the repository and start the applications with Docker Compose:
$ git clone https://github.com/yorkie-team/yorkie$ cd yorkie/build/docker$ docker compose -f docker-compose-full.yml up --build -d[+] Running 4/4✔ Container yorkie-mongo-1 Started✔ Container yorkie-prometheus-1 Started✔ Container yorkie-grafana-1 Started✔ Container yorkie-yorkie-1 Started
yorkie server or MongoDB you started earlier on this page first, or the ports clash.Now, Prometheus will collect Server metrics every 5 seconds.
Grafana runs on http://localhost:3000, and you can log in with admin and admin. The Prometheus data source is already provisioned with the name Prometheus, so you do not need to add it.
Then, import the default Yorkie dashboard template and customize it. Select the Prometheus data source when you import it. If you use a data source with a different name, such as my-prometheus, the datasource field values in JSON also need to be my-prometheus.
Sample dashboard:
Sharded Cluster
In a production environment, a server cluster is necessary to handle large workloads while ensuring high availability, reliability, and scalability.
Yorkie provides a sharded cluster in Kubernetes environments to support production environments.
This section describes how to set up a sharded cluster. An example of the sharded cluster architecture:
- L7 Load Balancer: It is responsible for routing requests to servers based on the computed request’s hash key and consistent hashing algorithm.
- Service Registry: It is responsible for storing metadata and configuration settings for Yorkie servers.
- MongoDB: It stores the data of Yorkie. It can be configured to use sharding, just like Yorkie sharded cluster.
Yorkie provides a Helm Chart, a package manager for Kubernetes, to easily deploy a Yorkie cluster on Kubernetes with the above components configured.
Below are guides for deploying Yorkie cluster on Kubernetes with Helm Charts on various platforms.
- Minikube Installation: Guide to install Yorkie cluster on Minikube.
- AWS EKS Installation: Guide to install Yorkie cluster on AWS EKS.
Also, you can additionally deploy Yorkie cluster addons on Kubernetes with Helm Charts on your own environment.
Yorkie cluster addons include:
- Monitoring: Provides Yorkie metrics and logging via Grafana dashboard.
- Analytics: Collects usage events of Yorkie cluster with Kafka and StarRocks.
- GitOps: Provides Yorkie Continuous Delivery via ArgoCD.
Below is guide for deploying Yorkie cluster addons on Kubernetes with Helm Charts.
- Cluster Addons Installation: Guide to install Yorkie cluster addons on Kubernetes.