Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: gohan elasticsearch jvm heap options file #231

Merged
merged 4 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ lib/public/*
!lib/public/.gitkeep
!lib/public/docker-compose.public.yaml

# gohan_elasticsearch
lib/gohan/es_jvm_options/*
!lib/gohan/es_jvm_options/.gitkeep
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens when the user runs gohan without anything in here; does it work, or should we have a default editable file here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works with nothing in it as well. This dir binds to /usr/share/elasticsearch/config/jvm.options.d/, which is always empty by default . Only files with the .options suffix are read by ES there, so whatever is in .gitkeep is ignored.

https://www.elastic.co/guide/en/elasticsearch/reference/current/advanced-configuration.html#set-jvm-options

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding the content of options file, per the docs:

Blank lines are ignored. Lines beginning with # are treated as comments and ignored. Lines that aren’t commented out and aren’t recognized as valid JVM arguments are rejected and Elasticsearch will fail to start.


# temp test stuff
etc/tests/*/__pycache__
etc/tests/*/*/__pycache__
Expand Down
38 changes: 38 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,44 @@ cp ./etc/katsu.config.example.json ./lib/katsu/config.json
```


### `gohan` configuration

#### Production

When deploying a Bento node that needs to serve variants data, it is recommended to allot larger portions of your
compute resources to both `bentov2-gohan-api` and `bentov2-gohan-elasticsearch`.
Since variants are stored in memory in Elasticsearch, set the `BENTOV2_GOHAN_ES_MEM_LIM` variable to an
appropriate value.


Alloting additional CPUs with `BENTOV2_GOHAN_API_CPUS` and `BENTOV2_GOHAN_ES_CPUS` will result in shorter ingestion
times. Consider this option if you need to ingest a large number of VCFs.

Go through the official Elasticsearch
[checklist](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-prod-prerequisites)
for production deployments on Docker.

The following configurations **MUST** be applied to the host machine deploying the Elasticsearch container:
* [Set vm.max_map_count](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#_set_vm_max_map_count_to_at_least_262144)
* [Disable swapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration-memory.html#swappiness)


#### Elasticsearch JVM options

In **production**, using the default JVM options provided by Elasticsearch is **recommended**.

In **development**, modifying the JVM heap size could be needed if Elasticsearch's memory limit
is low and you are trying to ingest VCFs.
The heap size can be modified by providing a config file to the `bentov2_gohan-elasticsearch` container:

```bash
cp ./etc/default.gohan.es.jvm.options ./lib/gohan/es_jvm_options/jvm.options
```

Set `Xms` and `Xmx` to no more than 50% of the `BENTOV2_GOHAN_ES_MEM_LIM` value.
For more details, check the official Elasticsearch doc on
[heap size](https://www.elastic.co/guide/en/elasticsearch/reference/current/advanced-configuration.html#set-jvm-heap-size).

v-rocheleau marked this conversation as resolved.
Show resolved Hide resolved
## 3. *Development only:* create self-signed TLS certificates

First, set up your local Bento and Keycloak hostnames (something like `bentov2.local`, `portal.bentov2.local`, and
Expand Down
2 changes: 1 addition & 1 deletion etc/bento.env
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ BENTOV2_GOHAN_ES_MEM_LIM=4G
BENTOV2_GOHAN_ES_CPUS=4

# allocate a little bit less memory than what is stated in `mem_limit` ^^
BENTOV2_GOHAN_ES_JAVA_OPTS="ES_JAVA_OPTS=-Xms3800m -Xmx3800m"
BENTOV2_GOHAN_ES_DATA_DIR=${BENTOV2_GOHAN_DATA_ROOT}/elasticsearch
BENTO_GOHAN_ES_JVM_OPTIONS_DIR=${PWD}/lib/gohan/es_jvm_options

# -- API-DRS Bridge
BENTOV2_GOHAN_API_DRS_BRIDGE_HOST_DIR=${BENTOV2_GOHAN_DATA_ROOT}/api_drs_bridge
Expand Down
9 changes: 9 additions & 0 deletions etc/default.gohan.es.jvm.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#########################################################
## FOR DEVELOPMENT ONLY
## Xms and Xmx MUST have the same value
## Use no more than 50% of BENTOV2_GOHAN_ES_MEM_LIM
## Default options assume 'BENTOV2_GOHAN_ES_MEM_LIM=4G'
#########################################################

-Xms2g
-Xmx2g
2 changes: 1 addition & 1 deletion lib/gohan/docker-compose.gohan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ services:
- BENTO_UID
- ELASTIC_USERNAME=${BENTOV2_GOHAN_ES_USERNAME}
- ELASTIC_PASSWORD=${BENTOV2_GOHAN_ES_PASSWORD}
- ${BENTOV2_GOHAN_ES_JAVA_OPTS}
- xpack.security.enabled=true
- discovery.type=${BENTOV2_GOHAN_ES_DISC_TYP}
- ingest.geoip.downloader.enabled=false
volumes:
- ${BENTOV2_GOHAN_ES_DATA_DIR}:/usr/share/elasticsearch/data
- ${BENTO_GOHAN_ES_JVM_OPTIONS_DIR}:/usr/share/elasticsearch/config/jvm.options.d
healthcheck:
test: [ "CMD", "curl", "http://localhost:${BENTOV2_GOHAN_ES_INTERNAL_PORT_1}" ]
timeout: ${BENTOV2_HEALTHCHECK_TIMEOUT}
Expand Down
Empty file.
Loading