Skip to content

Commit

Permalink
Add self-hosting recommendations (#1191)
Browse files Browse the repository at this point in the history
* Adds table for self-hosting recommendations/considerations
* New shortcodes: icon/yes, icon/no, format-number
  • Loading branch information
nydr committed Oct 6, 2023
1 parent 099137f commit 2678bfe
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 31 deletions.
2 changes: 1 addition & 1 deletion content/en/apps/guides/hosting/4.x/_index.md
Expand Up @@ -11,6 +11,6 @@ relatedContent: >

Before beginning any of these guides, be sure to meet all of the [CHT hosting requirements]({{< relref "apps/guides/hosting/requirements" >}}) first.

To host a production instance of CHT, use either the [Self Hosting in CHT 4.x]({{< relref "apps/guides/hosting/4.x/self-hosting-single-node" >}}) guide. To do app development, see our [App Developer]({{< relref "apps/guides/hosting/4.x/app-developer" >}}) hosting guide.
To host a production instance of CHT, use the [Self Hosting in CHT 4.x]({{< relref "apps/guides/hosting/4.x/self-hosting" >}}) guide. To do app development, see our [App Developer]({{< relref "apps/guides/hosting/4.x/app-developer" >}}) hosting guide.

To view 3.x hosting options, see the [3.x hosting section]({{< relref "apps/guides/hosting/3.x" >}})
2 changes: 1 addition & 1 deletion content/en/apps/guides/hosting/4.x/backups.md
Expand Up @@ -33,7 +33,7 @@ Therefore, you do **not** need to back up the docker images for:

## Assumptions

This guide assumes you have an Ubuntu server running CHT 4.x in Docker as described in our [Self Hosting in CHT 4.x - Single CouchDB Node]({{< relref "apps/guides/hosting/4.x/self-hosting-single-node" >}}) guide. If you run `docker ps --format '{{.Names}}'` you should see something like this:
This guide assumes you have an Ubuntu server running CHT 4.x in Docker as described in our [Self Hosting in CHT 4.x - Single CouchDB Node]({{< relref "apps/guides/hosting/4.x/self-hosting/single-node" >}}) guide. If you run `docker ps --format '{{.Names}}'` you should see something like this:

```
cht_nginx_1
Expand Down
31 changes: 31 additions & 0 deletions content/en/apps/guides/hosting/4.x/self-hosting/_index.md
@@ -0,0 +1,31 @@
---
title: "Self Hosting in CHT 4.x"
linkTitle: "Self Hosting"
weight: 10
description: >
Details for hosting the CHT on self run infrastructure
---

# Recommendations and considerations

## Multi vs Single node couchdb requirements

For smaller deployments a [single node CouchDB][single-couch] instance can be used, for larger deployments a [multi-node CouchDB][multi-couch] cluster is generally recommended

| Consideration | [Single node CouchDB][single-couch] | [Multi-node clustered CouchDB][multi-couch] |
| -------------------------------------------------------- | ----------------------------------- | ------------------------------------------- |
| Less than {{< format-number 4_000 >}} users | {{< icon/yes >}} | {{< icon/yes >}} |
| More than {{< format-number 4_000 >}} users | {{< icon/no >}} | {{< icon/yes >}} |
| Less than {{< format-number 10_000 >}} documents per day | {{< icon/yes >}} | {{< icon/yes >}} |
| More than {{< format-number 10_000 >}} documents per day | {{< icon/no >}} | {{< icon/yes >}} |
| Seamless upgrade with multi-node docker compose | {{< icon/yes >}} | {{< icon/no >}} |
| Seamless upgrade with multi-node kubernetes/k3s | {{< icon/yes >}} | {{< icon/yes >}} |

[single-couch]: {{< relref "apps/guides/hosting/4.x/self-hosting/single-node" >}}
[multi-couch]: {{< relref "apps/guides/hosting/4.x/self-hosting/multiple-nodes" >}}

## Cloud provider vs Bare metal

| Consideration | Cloud provider | Bare Metal |
| --------------------------- | --------------- | ---------------- |
| Data needs to be in-country | {{< icon/no >}} | {{< icon/yes >}} |
@@ -1,17 +1,18 @@
---
title: "Self Hosting in CHT 4.x - Multiple CouchDB Nodes"
linkTitle: "Self Hosting - Multiple Nodes"
linkTitle: "Multiple Nodes"
weight: 20
aliases:
- ../self-hosting-multiple-nodes
description: >
Hosting the CHT on self run infrastructure with horizontally scaled CouchDB nodes
---

{{% pageinfo %}}
The clustered multi-node hosting described below is only recommended for deployments that need extreme performance gains. These gains will greatly increase the complexity of troubleshooting and decrease the ease ongoing maintenance.
The clustered multi-node hosting described below is recommended for deployments that need increased performance gains. These gains will increase the complexity of troubleshooting and decrease the ease ongoing maintenance.

Instead, we recommended most deployment go with the [single node hosting]({{< ref "apps/guides/hosting/4.x/self-hosting-single-node" >}}).
If you are unsure which deployment to use check out [Self-hosting recommendations]({{< ref "apps/guides/hosting/4.x/self-hosting#recommendations-and-considerations" >}}).

As well, there's the [self hosted guide for 3.x]({{< relref "apps/guides/hosting/3.x/self-hosting" >}}).
{{% /pageinfo %}}

### About clustered deployments
Expand Down
@@ -1,14 +1,15 @@
---
title: "Self Hosting in CHT 4.x - Single CouchDB Node"
linkTitle: "Self Hosting - Single Node"
linkTitle: "Single Node"
weight: 10
aliases:
- ../self-hosting-single-node
description: >
Self Hosting in CHT 4.x - Single CouchDB Node
---

[//]: # (todo - fix this link to multi-node)
{{% pageinfo %}}
This for a single node CHT 4.x instance and is the recommended solution for most deployments. While not recommended, if you want a more powerful setup, check out [the 4.x multi-node install docs]({{< relref "apps/guides/hosting/requirements" >}}). As well, there's the [self hosted guide for CHT 3.x]({{< relref "apps/guides/hosting/3.x/self-hosting" >}}).
This for a single node CHT 4.x instance and is the recommended solution for small deployments. If you want a more powerful setup, check out [the 4.x multi-node install docs]({{< relref "apps/guides/hosting/4.x/self-hosting/multiple-nodes" >}}).
{{% /pageinfo %}}

## Prerequisites
Expand Down
2 changes: 1 addition & 1 deletion content/en/apps/guides/hosting/monitoring/integration.md
Expand Up @@ -144,7 +144,7 @@ services:

Now that we have all the config files in place, you need to have Docker start everything together. This is so that the containers can see each other on the same `CHT Net` Docker network. You will need to specify each of the compose files every time you start, stop or restart CHT instance so all the services stay running and connected.

Assuming you followed the [production steps]({{< relref "apps/guides/hosting/4.x/self-hosting-single-node" >}}) to install the CHT, you use this Compose call to first stop all containers and then start them all up, including the new services:
Assuming you followed the [production steps]({{< relref "apps/guides/hosting/4.x/self-hosting" >}}) to install the CHT, you use this Compose call to first stop all containers and then start them all up, including the new services:

```shell
cd /home/ubuntu/cht/upgrade-service
Expand Down
36 changes: 18 additions & 18 deletions content/en/apps/guides/hosting/requirements.md
Expand Up @@ -9,7 +9,6 @@ relatedContent: >
apps/guides/hosting/3.x/ec2-setup-guide
---


{{% pageinfo %}}
For production CHT deployments, Linux is recommended, with [Ubuntu](https://ubuntu.com/server) the most commonly used. For CHT development, Linux or macOS may be used. Windows can be used for either, but without recommendation.
{{% /pageinfo %}}
Expand All @@ -26,30 +25,30 @@ Hosting a CHT instance in a cloud provider like AWS or on bare-metal requires yo
- A DNS Entry pointing to the IP
- TLS certificates

## Hardware Requirements
## Minimum Hardware Requirements

- 4 GiB RAM
- 2 CPU/vCPU
- 8 GB Hard Disk (SSD preferred)
- Root Access
- Root Access

Depending on the scale of your operation these may need to be adjusted. Be sure to monitor disk usage so that the 8 GB can be increased as needed.
Depending on the scale of your operation these may need to be increased. Be sure to monitor disk usage so that the 8 GB can be increased as needed.

## Docker
## Docker

Install both `docker` and `docker-compose` to run CHT and related containers.

{{% alert title="Note" %}}
Skip this step if you're following the [EC2 guide 3.x]({{< relref "apps/guides/hosting/3.x/ec2-setup-guide#create-and-configure-ec2-instance" >}}) as `docker` and `docker-compose` are automatically installed when following the setup scripts.
Skip this step if you're following the [EC2 guide 3.x]({{< relref "apps/guides/hosting/3.x/ec2-setup-guide#create-and-configure-ec2-instance" >}}) as `docker` and `docker-compose` are automatically installed when following the setup scripts.
{{% /alert %}}

### Linux

Depending on which distro you run, install the Docker packages from [Docker's Linux options](https://docs.docker.com/engine/install/#server). Historically, Medic runs Ubuntu: see [Docker CE](https://docs.docker.com/engine/install/ubuntu/) and [Docker-compose](https://docs.docker.com/compose/install/) install pages.
Depending on which distro you run, install the Docker packages from [Docker's Linux options](https://docs.docker.com/engine/install/#server). Historically, Medic runs Ubuntu: see [Docker CE](https://docs.docker.com/engine/install/ubuntu/) and [Docker-compose](https://docs.docker.com/compose/install/) install pages.

### Windows
### Windows

Docker Desktop for Windows needs either Hyper-V support or Windows Subsystem for Linux 2 (WSL 2). [Docker's Windows Docker Desktop install page](https://docs.docker.com/docker-for-windows/install/) covers both scenarios.
Docker Desktop for Windows needs either Hyper-V support or Windows Subsystem for Linux 2 (WSL 2). [Docker's Windows Docker Desktop install page](https://docs.docker.com/docker-for-windows/install/) covers both scenarios.

### macOS

Expand All @@ -72,13 +71,14 @@ Finally, confirm you can run the "hello world" docker container: `sudo docker ru

## Considerations

There are serious implications to consider when deploying a CHT instance beyond the above requirements. Be sure to account for:
There are serious implications to consider when deploying a CHT instance beyond the above requirements. Be sure to account for:

- Alerting - How will alerts be sent in the case of downtime or degraded service?
- Power failures and unplanned restarts - Will the server cleanly restart such that the CHT resumes service correctly?
- Backups - What happens to the CHT data if there's a hard drive failure?
- Disaster Recovery - What happens if there is a flood at the facility and on-site active and backup data are destroyed?
- Scale - What happens when the hardware deployed needs to be upgraded to increase capacity?
- Updates - By definition TLS certificates expire and software needs to be updated - how will the deployment get these updates on a regular basis?
- Security - While the TLS certificate will protect data on the LAN, is the server hard drive encrypted in the event of property theft?
- Privacy - The CHT inherently carries sensitive patient medical information in the database. Are there sufficient measures in place to protect this sensitive data?

* Alerting - How will alerts be sent in the case of downtime or degraded service?
* Power failures and unplanned restarts - Will the server cleanly restart such that the CHT resumes service correctly?
* Backups - What happens to the CHT data if there's a hard drive failure?
* Disaster Recovery - What happens if there is a flood at the facility and on-site active and backup data are destroyed?
* Scale - What happens when the hardware deployed needs to be upgraded to increase capacity?
* Updates - By definition TLS certificates expire and software needs to be updated - how will the deployment get these updates on a regular basis?
* Security - While the TLS certificate will protect data on the LAN, is the server hard drive encrypted in the event of property theft?
* Privacy - The CHT inherently carries sensitive patient medical information in the database. Are there sufficient measures in place to protect this sensitive data?
2 changes: 1 addition & 1 deletion content/en/apps/guides/hosting/vertical-vs-horizontal.md
Expand Up @@ -5,7 +5,7 @@ weight: 20
description: >
The power of clustered CouchDB to horizontally scale the CHT
relatedContent: >
apps/guides/hosting/4.x/self-hosting-multiple-nodes
apps/guides/hosting/4.x/self-hosting/multiple-nodes
apps/guides/hosting/4.x/data-migration
core/overview/architecture/
---
Expand Down
2 changes: 1 addition & 1 deletion content/en/apps/tutorials/_partial_docker_setup.md
Expand Up @@ -15,7 +15,7 @@ echo "export DOCKER_HOST=unix:///run/user/1000/docker.sock" >> ~/.$(basename $SH
```
{{% /tab %}}
{{% tab header="macOS" %}}
Download and install [Docker Desktop](https://www.docker.com/products/docker-desktop).
Download and install [Docker Desktop](https://www.docker.com/products/docker-desktop) or [Colima](https://github.com/abiosoft/colima#readme).
{{% /tab %}}
{{% tab header="Windows (WSL2)" %}}
Download and install [Docker Desktop](https://www.docker.com/products/docker-desktop).
Expand Down
2 changes: 1 addition & 1 deletion content/en/apps/tutorials/local-setup.md
Expand Up @@ -51,7 +51,7 @@ Before you begin, ensure you have the following tools:

### Initialize project directory

Using the terminal (or the WLS shell on Windows: _Start > wsl_), run the following commands to create a new project directory for your CHT app:
Using the terminal (or the WSL shell on Windows: _Start > wsl_), run the following commands to create a new project directory for your CHT app:

```shell
mkdir -p ~/cht-project
Expand Down
2 changes: 2 additions & 0 deletions layouts/shortcodes/format-number.html
@@ -0,0 +1,2 @@
{{/* Replace _ with unicode character Thin Space (U+2009) for international number formating */}}
{{ with .Get 0 }}{{ replace . "_" " " }}{{ end }}
1 change: 1 addition & 0 deletions layouts/shortcodes/icon/no.html
@@ -0,0 +1 @@
<span title="No"></span>
1 change: 1 addition & 0 deletions layouts/shortcodes/icon/yes.html
@@ -0,0 +1 @@
<span title="Yes"></span>

0 comments on commit 2678bfe

Please sign in to comment.